Merge pull request #655 from PowerShell/vors/build
Incorporate build.FullCLR.ps1 in PowerShellGitHubDev.psm1
This commit is contained in:
commit
2213a64e25
|
@ -13,7 +13,7 @@ before_install:
|
|||
- sudo sh -c 'echo "deb [arch=amd64] http://apt-mo.trafficmanager.net/repos/dotnet/ trusty main" > /etc/apt/sources.list.d/dotnetdev.list'
|
||||
- sudo apt-key adv --keyserver apt-mo.trafficmanager.net --recv-keys 417A0893
|
||||
- sudo apt-get -qq update
|
||||
- sudo apt-get install -y dotnet=1.0.0.001638-1
|
||||
- sudo apt-get install -y dotnet=1.0.0.001425-1
|
||||
script:
|
||||
- dotnet restore
|
||||
- ./build.sh
|
||||
|
|
|
@ -19,10 +19,12 @@ try {
|
|||
|
||||
function Start-PSBuild
|
||||
{
|
||||
[CmdletBinding(DefaultParameterSetName='CoreCLR')]
|
||||
param(
|
||||
[switch]$Restore,
|
||||
[switch]$Clean,
|
||||
[string]$Output = "$PSScriptRoot/bin",
|
||||
[string]$Output,
|
||||
|
||||
# These runtimes must match those in project.json
|
||||
# We do not use ValidateScript since we want tab completion
|
||||
[ValidateSet("ubuntu.14.04-x64",
|
||||
|
@ -31,61 +33,182 @@ function Start-PSBuild
|
|||
"win10-x64",
|
||||
"osx.10.10-x64",
|
||||
"osx.10.11-x64")]
|
||||
[string]$Runtime
|
||||
[Parameter(ParameterSetName='CoreCLR')]
|
||||
[string]$Runtime,
|
||||
|
||||
[Parameter(ParameterSetName='FullCLR')]
|
||||
[switch]$FullCLR,
|
||||
|
||||
[Parameter(ParameterSetName='FullCLR')]
|
||||
[string]$cmakeGenerator = "Visual Studio 12 2013",
|
||||
|
||||
[Parameter(ParameterSetName='FullCLR')]
|
||||
[ValidateSet("Debug",
|
||||
"Release")]
|
||||
[string]$msbuildConfiguration = "Release"
|
||||
)
|
||||
|
||||
if (-Not (Get-Command "dotnet" -ErrorAction SilentlyContinue)) {
|
||||
throw "Build dependency 'dotnet' not found in PATH! See: https://dotnet.github.io/getting-started/"
|
||||
function precheck([string]$command, [string]$missedMessage)
|
||||
{
|
||||
$c = Get-Command $command -ErrorAction SilentlyContinue
|
||||
if (-not $c)
|
||||
{
|
||||
Write-Warning $missedMessage
|
||||
return $false
|
||||
}
|
||||
else
|
||||
{
|
||||
return $true
|
||||
}
|
||||
}
|
||||
|
||||
function log([string]$message)
|
||||
{
|
||||
Write-Host -Foreground Green $message
|
||||
}
|
||||
|
||||
# simplify ParameterSetNames, set output
|
||||
if ($PSCmdlet.ParameterSetName -eq 'FullCLR')
|
||||
{
|
||||
$FullCLR = $true
|
||||
}
|
||||
|
||||
if (-not $Output)
|
||||
{
|
||||
if ($FullCLR) { $Output = "$PSScriptRoot/binFull" } else { $Output = "$PSScriptRoot/bin" }
|
||||
}
|
||||
|
||||
# verify we have all tools in place to do the build
|
||||
$precheck = precheck 'dotnet' "Build dependency 'dotnet' not found in PATH! See: https://dotnet.github.io/getting-started/"
|
||||
if ($FullCLR)
|
||||
{
|
||||
# cmake is needed to build powershell.exe
|
||||
$precheck = $precheck -and (precheck 'cmake' 'cmake not found. You can install it from https://chocolatey.org/packages/cmake.portable')
|
||||
# msbuild is needed to build powershell.exe
|
||||
$precheck = $precheck -and (precheck 'msbuild' 'msbuild not found. Install Visual Studio and add msbuild to $env:PATH')
|
||||
}
|
||||
|
||||
if (-not $precheck) { return }
|
||||
|
||||
# handle clean
|
||||
if ($Clean) {
|
||||
Remove-Item -Force -Recurse $Output
|
||||
Remove-Item -Force -Recurse $Output -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
New-Item -Force -Type Directory $Output | Out-Null
|
||||
|
||||
$Top = "$PSScriptRoot/src/Microsoft.PowerShell.Linux.Host"
|
||||
# define key build variables
|
||||
if ($FullCLR)
|
||||
{
|
||||
$Top = "$PSScriptRoot\src\Microsoft.PowerShell.ConsoleHost"
|
||||
$framework = 'net451'
|
||||
}
|
||||
else
|
||||
{
|
||||
$Top = "$PSScriptRoot/src/Microsoft.PowerShell.Linux.Host"
|
||||
$framework = 'netstandardapp1.5'
|
||||
}
|
||||
|
||||
# handle Restore
|
||||
if ($Restore -Or -Not (Test-Path "$Top/project.lock.json")) {
|
||||
dotnet restore $PSScriptRoot
|
||||
log "Run dotnet restore"
|
||||
# restore is genuinely verbose.
|
||||
# we don't show it by default to keep CI build log size small
|
||||
if ($PSCmdlet.MyInvocation.BoundParameters["Verbose"].IsPresent)
|
||||
{
|
||||
dotnet restore $PSScriptRoot
|
||||
}
|
||||
else
|
||||
{
|
||||
dotnet restore $PSScriptRoot > $null
|
||||
}
|
||||
}
|
||||
|
||||
if ($IsLinux -Or $IsOSX) {
|
||||
$InstallCommand = if ($IsLinux) { "apt-get" } elseif ($IsOSX) { "brew" }
|
||||
foreach ($Dependency in "cmake", "g++") {
|
||||
if (-Not (Get-Command $Dependency -ErrorAction SilentlyContinue)) {
|
||||
throw "Build dependency '$Dependency' not found in PATH! Run '$InstallCommand install $Dependency'"
|
||||
# Build native components
|
||||
if (-not $FullCLR)
|
||||
{
|
||||
if ($IsLinux -Or $IsOSX) {
|
||||
log "Start building native components"
|
||||
$InstallCommand = if ($IsLinux) { "apt-get" } elseif ($IsOSX) { "brew" }
|
||||
foreach ($Dependency in "cmake", "g++") {
|
||||
if (-Not (Get-Command $Dependency -ErrorAction SilentlyContinue)) {
|
||||
throw "Build dependency '$Dependency' not found in PATH! Run '$InstallCommand install $Dependency'"
|
||||
}
|
||||
}
|
||||
|
||||
$Ext = if ($IsLinux) { "so" } elseif ($IsOSX) { "dylib" }
|
||||
$Native = "$PSScriptRoot/src/libpsl-native"
|
||||
$Lib = "$Native/src/libpsl-native.$Ext"
|
||||
Write-Verbose "Building $Lib"
|
||||
|
||||
try {
|
||||
Push-Location $Native
|
||||
cmake -DCMAKE_BUILD_TYPE=Debug .
|
||||
make -j
|
||||
make test
|
||||
} finally {
|
||||
Pop-Location
|
||||
}
|
||||
|
||||
if (-Not (Test-Path $Lib)) { throw "Compilation of $Lib failed" }
|
||||
Copy-Item $Lib $Output
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
log "Start building native powershell.exe"
|
||||
$build = "$PSScriptRoot/build"
|
||||
if ($Clean) {
|
||||
Remove-Item -Force -Recurse $build -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
$Ext = if ($IsLinux) { "so" } elseif ($IsOSX) { "dylib" }
|
||||
$Native = "$PSScriptRoot/src/libpsl-native"
|
||||
$Lib = "$Native/src/libpsl-native.$Ext"
|
||||
Write-Host "Building $Lib"
|
||||
mkdir $build -ErrorAction SilentlyContinue
|
||||
try
|
||||
{
|
||||
Push-Location $build
|
||||
|
||||
try {
|
||||
Push-Location $Native
|
||||
cmake -DCMAKE_BUILD_TYPE=Debug .
|
||||
make -j
|
||||
make test
|
||||
} finally {
|
||||
Pop-Location
|
||||
if ($cmakeGenerator)
|
||||
{
|
||||
cmake -G $cmakeGenerator ..\src\powershell-native
|
||||
}
|
||||
else
|
||||
{
|
||||
cmake ..\src\powershell-native
|
||||
}
|
||||
msbuild powershell.vcxproj /p:Configuration=$msbuildConfiguration
|
||||
cp -rec $msbuildConfiguration\* $Output
|
||||
}
|
||||
|
||||
if (-Not (Test-Path $Lib)) { throw "Compilation of $Lib failed" }
|
||||
Copy-Item $Lib $Output
|
||||
finally { Pop-Location }
|
||||
}
|
||||
|
||||
Write-Host "Building PowerShell"
|
||||
|
||||
$Arguments = "--framework", "netstandardapp1.5", "--output", $Output
|
||||
|
||||
log "Building PowerShell"
|
||||
$Arguments = "--framework", $framework, "--output", $Output
|
||||
if ($IsLinux -Or $IsOSX) { $Arguments += "--configuration", "Linux" }
|
||||
|
||||
if ($Runtime) { $Arguments += "--runtime", $Runtime }
|
||||
|
||||
if ($FullCLR)
|
||||
{
|
||||
# there is a problem with code signing:
|
||||
# AssemblyKeyFileAttribute file path cannot be correctly located, if `dotnet publish $TOP` syntax is used
|
||||
# we workaround it with calling `dotnet publish` from $TOP directory instead.
|
||||
Push-Location $Top
|
||||
}
|
||||
else
|
||||
{
|
||||
$Arguments += $Top
|
||||
}
|
||||
|
||||
$Arguments += $Top
|
||||
Write-Verbose "Run dotnet publish $Arguments from $pwd"
|
||||
|
||||
dotnet publish $Arguments
|
||||
# this try-finally is part of workaround about AssemblyKeyFileAttribute issue
|
||||
try
|
||||
{
|
||||
dotnet publish $Arguments
|
||||
}
|
||||
finally
|
||||
{
|
||||
if ($FullCLR) { Pop-Location }
|
||||
}
|
||||
}
|
||||
|
||||
function Start-PSPackage
|
||||
|
|
32
README.md
32
README.md
|
@ -76,7 +76,7 @@ non-Windows platforms). Install `dotnet` by following their [documentation][].
|
|||
|
||||
The version of .NET CLI is very important, you want a recent 1.0.0 beta
|
||||
(**not** 1.0.1). The following instructions will install precisely
|
||||
1.0.0.001638, though any 1.0.0 version *should* work.
|
||||
1.0.0.001718, though any 1.0.0 version *should* work.
|
||||
|
||||
> Previous installations of DNX, `dnvm`, or older installations of .NET CLI
|
||||
> can cause odd failures when running. Please check your version.
|
||||
|
@ -89,17 +89,28 @@ The version of .NET CLI is very important, you want a recent 1.0.0 beta
|
|||
|
||||
Tested on Ubuntu 14.04.
|
||||
|
||||
|
||||
This installs the .NET CLI package feed. The benefit to this is that
|
||||
installing `dotnet` using `apt-get` will also install all of its
|
||||
dependencies automatically.
|
||||
|
||||
```sh
|
||||
sudo sh -c 'echo "deb [arch=amd64] http://apt-mo.trafficmanager.net/repos/dotnet/ trusty main" > /etc/apt/sources.list.d/dotnetdev.list'
|
||||
sudo apt-key adv --keyserver apt-mo.trafficmanager.net --recv-keys 417A0893
|
||||
sudo apt-get update
|
||||
sudo apt-get install dotnet=1.0.0.001638-1
|
||||
sudo apt-get install dotnet=1.0.0.001675-1
|
||||
```
|
||||
|
||||
Then install the following additional build / debug tools:
|
||||
The drawback of using the feed is that it gets out of date. The pinned
|
||||
version is the most recent package published to the feed, but newer
|
||||
packages are available. To upgrade the package, install it by
|
||||
hand. Unfortunately, `dpkg` does not handle dependency resolution, so
|
||||
it is recommended to first install the older version from the feed,
|
||||
and then upgrade it.
|
||||
|
||||
```sh
|
||||
sudo apt-get install g++ cmake make lldb-3.6 strace
|
||||
wget https://dotnetcli.blob.core.windows.net/dotnet/beta/Installers/Latest/dotnet-ubuntu-x64.latest.deb
|
||||
sudo dpkg -i ./dotnet-ubuntu-x64.latest.deb
|
||||
```
|
||||
|
||||
#### OMI
|
||||
|
@ -119,7 +130,7 @@ An MSI installer also exists, but this script avoids touching your system.
|
|||
|
||||
```powershell
|
||||
Invoke-WebRequest -Uri https://raw.githubusercontent.com/dotnet/cli/rel/1.0.0/scripts/obtain/install.ps1 -OutFile install.ps1
|
||||
./install.ps1 -version 1.0.0.001638 -channel beta
|
||||
./install.ps1 -version 1.0.0.001718 -channel beta
|
||||
```
|
||||
|
||||
If you meet `Unable to cast COM object of type 'System.__ComObject' to
|
||||
|
@ -141,8 +152,9 @@ test on OS X, but some developers use PowerShell on 10.10 and 10.11.
|
|||
**The command `dotnet restore` must be done at least once from the top directory
|
||||
to obtain all the necessary .NET packages.**
|
||||
|
||||
Build with `./build.sh` on Linux and OS X, `./build.ps1` for Core PowerShell on
|
||||
Windows, and `./build.FullCLR.ps1` for Full PowerShell on Windows.
|
||||
Build with `./build.sh` on Linux and OS X.
|
||||
|
||||
`Start-PSBuild` from module `.\PowerShellGitHubDev.psm1` on Windows and Linux / OS X, if you self-hosting PowerShell.
|
||||
|
||||
Specifically:
|
||||
|
||||
|
@ -161,9 +173,13 @@ In PowerShell:
|
|||
```powershell
|
||||
cd PowerShell
|
||||
dotnet restore
|
||||
./build.ps1
|
||||
Import-Module .\PowerShellGitHubDev.psm1
|
||||
Start-PSBuild # build CoreCLR version
|
||||
Start-PSBuild -FullCLR # build FullCLR version
|
||||
```
|
||||
|
||||
**Tip:** use `Start-PSBuild -Verbose` switch to see more information about build process.
|
||||
|
||||
### PowerShellGitHubDev
|
||||
|
||||
Alternatively, the `PowerShellGitHubDev.psm1` module contains a `Start-PSBuild`
|
||||
|
|
37
appveyor.yml
37
appveyor.yml
|
@ -1,3 +1,5 @@
|
|||
version: 0.2.0.{build}
|
||||
|
||||
environment:
|
||||
priv_key:
|
||||
secure: <encryped-value>
|
||||
|
@ -18,7 +20,7 @@ install:
|
|||
- git config --global url.git@github.com:.insteadOf https://github.com/
|
||||
- git submodule update --init --recursive -- src/monad src/windows-build src/Microsoft.PowerShell.Linux.Host/Modules/Pester
|
||||
- ps: Invoke-WebRequest -Uri https://raw.githubusercontent.com/dotnet/cli/rel/1.0.0/scripts/obtain/install.ps1 -OutFile install.ps1
|
||||
- ps: ./install.ps1 -version 1.0.0.001638 -channel beta
|
||||
- ps: ./install.ps1 -version 1.0.0.001718 -channel beta
|
||||
|
||||
build_script:
|
||||
- ps: |
|
||||
|
@ -26,7 +28,7 @@ build_script:
|
|||
dotnet --version
|
||||
Import-Module .\PowerShellGitHubDev.psm1
|
||||
Start-PSBuild
|
||||
- ps: .\build.fullCLR.ps1
|
||||
Start-PSBuild -FullCLR
|
||||
|
||||
test_script:
|
||||
- ps: |
|
||||
|
@ -34,33 +36,38 @@ test_script:
|
|||
$ErrorActionPreference = 'Stop'
|
||||
#
|
||||
# CoreCLR
|
||||
$testResultsFile = ".\TestsResults.xml"
|
||||
Write-Host -Foreground Green 'Run CoreCLR tests'
|
||||
$testResultsFile = "$pwd\TestsResults.xml"
|
||||
.\bin\powershell.exe --noprofile -c "Import-Module .\bin\Modules\Microsoft.PowerShell.Platform; Invoke-Pester test/powershell -OutputFormat NUnitXml -OutputFile $testResultsFile"
|
||||
(New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path $testResultsFile))
|
||||
#
|
||||
# FullCLR
|
||||
Import-Module .\PowerShellGitHubDev.psm1
|
||||
$testResultsFile = ".\TestsResults.FullCLR.xml"
|
||||
Start-DevPSGitHub -binDir $pwd\binFull -NoNewWindow -ArgumentList '-command', "Import-Module .\bin\Modules\Pester; Import-Module .\bin\Modules\Microsoft.PowerShell.Platform; Invoke-Pester test/fullCLR -OutputFormat NUnitXml -OutputFile $testResultsFile"
|
||||
(New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path $testResultsFile))
|
||||
Write-Host -Foreground Green 'Run FullCLR tests'
|
||||
$testResultsFileFullCLR = "$pwd\TestsResults.FullCLR.xml"
|
||||
Start-DevPSGitHub -binDir $pwd\binFull -NoNewWindow -ArgumentList '-command', "Import-Module .\src\monad\monad\src\OSS\Pester; Import-Module .\bin\Modules\Microsoft.PowerShell.Platform; Invoke-Pester test/fullCLR -OutputFormat NUnitXml -OutputFile $testResultsFileFullCLR"
|
||||
(New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path $testResultsFileFullCLR))
|
||||
#
|
||||
# Fail the build, if tests failed
|
||||
$x = [xml](cat -raw .\TestsResults.FullCLR.xml)
|
||||
if ([int]$x.'test-results'.failures -gt 0)
|
||||
{
|
||||
throw "$($x.'test-results'.failures) tests in test/fullCLR failed"
|
||||
}
|
||||
$x = [xml](cat -raw .\TestsResults.xml)
|
||||
Write-Host -Foreground Green 'Upload CoreCLR test results'
|
||||
$x = [xml](cat -raw $testResultsFile)
|
||||
if ([int]$x.'test-results'.failures -gt 0)
|
||||
{
|
||||
throw "$($x.'test-results'.failures) tests in test/powershell failed"
|
||||
}
|
||||
Write-Host -Foreground Green 'Upload FullCLR test results'
|
||||
$x = [xml](cat -raw $testResultsFileFullCLR)
|
||||
if ([int]$x.'test-results'.failures -gt 0)
|
||||
{
|
||||
throw "$($x.'test-results'.failures) tests in test/fullCLR failed"
|
||||
}
|
||||
|
||||
|
||||
on_finish:
|
||||
- ps: |
|
||||
# Creating project artifact
|
||||
$zipFilePath = Join-Path $pwd "$(Split-Path $pwd -Leaf).zip"
|
||||
$zipFileFullPath = Join-Path $pwd "$(Split-Path $pwd -Leaf).FullCLR.zip"
|
||||
$name = git describe
|
||||
$zipFilePath = Join-Path $pwd "$name.zip"
|
||||
$zipFileFullPath = Join-Path $pwd "$name.FullCLR.zip"
|
||||
Add-Type -assemblyname System.IO.Compression.FileSystem
|
||||
[System.IO.Compression.ZipFile]::CreateFromDirectory("$pwd\bin", $zipFilePath)
|
||||
[System.IO.Compression.ZipFile]::CreateFromDirectory("$pwd\binFull", $zipFileFullPath)
|
||||
|
|
|
@ -1,74 +0,0 @@
|
|||
param(
|
||||
# "" is for default generator on the platform
|
||||
[ValidateSet(
|
||||
"",
|
||||
"Visual Studio 12 2013",
|
||||
"Visual Studio 12 2013 Win64",
|
||||
"Visual Studio 14 2015",
|
||||
"Visual Studio 14 2015 Win64")]
|
||||
[string]$cmakeGenerator = "Visual Studio 12 2013",
|
||||
|
||||
[ValidateSet(
|
||||
"Debug",
|
||||
"Release")]
|
||||
[string]$msbuildConfiguration = "Release"
|
||||
)
|
||||
|
||||
$origPWD = $pwd
|
||||
try
|
||||
{
|
||||
$prechecks = $true
|
||||
# check per-requests
|
||||
if (-not (get-command cmake -ErrorAction SilentlyContinue))
|
||||
{
|
||||
Write-Warning 'cmake not found. You can install it from https://chocolatey.org/packages/cmake.portable'
|
||||
$prechecks = $false
|
||||
}
|
||||
|
||||
if (-not (get-command msbuild -ErrorAction SilentlyContinue))
|
||||
{
|
||||
Write-Warning 'msbuild not found. Install Visual Studio and add msbuild to $env:PATH'
|
||||
$prechecks = $false
|
||||
}
|
||||
|
||||
if (-not (get-command dotnet -ErrorAction SilentlyContinue))
|
||||
{
|
||||
Write-Warning 'dotnet not found. Install it from http://dotnet.github.io/getting-started/'
|
||||
$prechecks = $false
|
||||
}
|
||||
|
||||
if (-not $prechecks)
|
||||
{
|
||||
return
|
||||
}
|
||||
# end per-requests
|
||||
|
||||
$BINFULL = "$pwd/binFull"
|
||||
$BUILD = "$pwd/build"
|
||||
|
||||
mkdir $BINFULL -ErrorAction SilentlyContinue
|
||||
|
||||
# Publish PowerShell
|
||||
cd src\Microsoft.PowerShell.ConsoleHost
|
||||
dotnet publish --framework net451 --output $BINFULL
|
||||
|
||||
mkdir $build -ErrorAction SilentlyContinue
|
||||
cd $build
|
||||
|
||||
if ($cmakeGenerator)
|
||||
{
|
||||
cmake -G "$cmakeGenerator" ..\src\powershell-native
|
||||
}
|
||||
else
|
||||
{
|
||||
cmake ..\src\powershell-native
|
||||
}
|
||||
|
||||
msbuild powershell.vcxproj /p:Configuration=$msbuildConfiguration
|
||||
|
||||
cp -rec $msbuildConfiguration\* $BINFULL
|
||||
}
|
||||
finally
|
||||
{
|
||||
cd $origPWD
|
||||
}
|
Loading…
Reference in a new issue