Incorporate build.FullCLR.ps1 in PowerShellGitHubDev.psm1
This commit fixes #652
This commit is contained in:
parent
d7195fc258
commit
b28d96d700
@ -19,10 +19,12 @@ try {
|
|||||||
|
|
||||||
function Start-PSBuild
|
function Start-PSBuild
|
||||||
{
|
{
|
||||||
|
[CmdletBinding(DefaultParameterSetName='CoreCLR')]
|
||||||
param(
|
param(
|
||||||
[switch]$Restore,
|
[switch]$Restore,
|
||||||
[switch]$Clean,
|
[switch]$Clean,
|
||||||
[string]$Output = "$PSScriptRoot/bin",
|
[string]$Output,
|
||||||
|
|
||||||
# These runtimes must match those in project.json
|
# These runtimes must match those in project.json
|
||||||
# We do not use ValidateScript since we want tab completion
|
# We do not use ValidateScript since we want tab completion
|
||||||
[ValidateSet("ubuntu.14.04-x64",
|
[ValidateSet("ubuntu.14.04-x64",
|
||||||
@ -31,61 +33,172 @@ function Start-PSBuild
|
|||||||
"win10-x64",
|
"win10-x64",
|
||||||
"osx.10.10-x64",
|
"osx.10.10-x64",
|
||||||
"osx.10.11-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)) {
|
function precheck([string]$command, [string]$missedMessage)
|
||||||
throw "Build dependency 'dotnet' not found in PATH! See: https://dotnet.github.io/getting-started/"
|
{
|
||||||
|
$c = Get-Command $command -ErrorAction SilentlyContinue
|
||||||
|
if (-not $c)
|
||||||
|
{
|
||||||
|
Write-Warning $missedMessage
|
||||||
|
return $false
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return $true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 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) {
|
if ($Clean) {
|
||||||
Remove-Item -Force -Recurse $Output
|
Remove-Item -Force -Recurse $Output -ErrorAction SilentlyContinues
|
||||||
}
|
}
|
||||||
|
|
||||||
New-Item -Force -Type Directory $Output | Out-Null
|
New-Item -Force -Type Directory $Output | Out-Null
|
||||||
|
|
||||||
$Top = "$PSScriptRoot/src/Microsoft.PowerShell.Linux.Host"
|
# handle Restore
|
||||||
|
if ($FullCLR)
|
||||||
|
{
|
||||||
|
$Top = "$PSScriptRoot\src\Microsoft.PowerShell.ConsoleHost"
|
||||||
|
$framework = 'net451'
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$Top = "$PSScriptRoot/src/Microsoft.PowerShell.Linux.Host"
|
||||||
|
$framework = 'netstandardapp1.5'
|
||||||
|
}
|
||||||
|
|
||||||
if ($Restore -Or -Not (Test-Path "$Top/project.lock.json")) {
|
if ($Restore -Or -Not (Test-Path "$Top/project.lock.json")) {
|
||||||
dotnet restore $PSScriptRoot
|
dotnet restore $PSScriptRoot
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($IsLinux -Or $IsOSX) {
|
# Build native components
|
||||||
$InstallCommand = if ($IsLinux) { "apt-get" } elseif ($IsOSX) { "brew" }
|
if (-not $FullCLR)
|
||||||
foreach ($Dependency in "cmake", "g++") {
|
{
|
||||||
if (-Not (Get-Command $Dependency -ErrorAction SilentlyContinue)) {
|
Write-Verbose "Start CoreCLR build"
|
||||||
throw "Build dependency '$Dependency' not found in PATH! Run '$InstallCommand install $Dependency'"
|
|
||||||
|
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'"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$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
|
||||||
|
{
|
||||||
|
Write-Verbose "Start building native powershell.exe"
|
||||||
|
$build = "$PSScriptRoot/build"
|
||||||
|
if ($Clean) {
|
||||||
|
Remove-Item -Force -Recurse $build -ErrorAction SilentlyContinue
|
||||||
}
|
}
|
||||||
|
|
||||||
$Ext = if ($IsLinux) { "so" } elseif ($IsOSX) { "dylib" }
|
mkdir $build -ErrorAction SilentlyContinue
|
||||||
$Native = "$PSScriptRoot/src/libpsl-native"
|
$origPWD = $pwd
|
||||||
$Lib = "$Native/src/libpsl-native.$Ext"
|
try
|
||||||
Write-Host "Building $Lib"
|
{
|
||||||
|
cd $build
|
||||||
|
|
||||||
try {
|
if ($cmakeGenerator)
|
||||||
Push-Location $Native
|
{
|
||||||
cmake -DCMAKE_BUILD_TYPE=Debug .
|
cmake -G "$cmakeGenerator" ..\src\powershell-native
|
||||||
make -j
|
}
|
||||||
make test
|
else
|
||||||
} finally {
|
{
|
||||||
Pop-Location
|
cmake ..\src\powershell-native
|
||||||
|
}
|
||||||
|
msbuild powershell.vcxproj /p:Configuration=$msbuildConfiguration
|
||||||
|
cp -rec $msbuildConfiguration\* $BINFULL
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
cd $origPWD
|
||||||
}
|
}
|
||||||
|
|
||||||
if (-Not (Test-Path $Lib)) { throw "Compilation of $Lib failed" }
|
|
||||||
Copy-Item $Lib $Output
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Host "Building PowerShell"
|
Write-Verbose "Building PowerShell"
|
||||||
|
$Arguments = "--framework", $framework, "--output", $Output
|
||||||
$Arguments = "--framework", "netstandardapp1.5", "--output", $Output
|
|
||||||
|
|
||||||
if ($IsLinux -Or $IsOSX) { $Arguments += "--configuration", "Linux" }
|
if ($IsLinux -Or $IsOSX) { $Arguments += "--configuration", "Linux" }
|
||||||
|
|
||||||
if ($Runtime) { $Arguments += "--runtime", $Runtime }
|
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.
|
||||||
|
$origPWD = $pwd
|
||||||
|
cd $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) { cd $origPWD }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function Start-PSPackage
|
function Start-PSPackage
|
||||||
|
11
README.md
11
README.md
@ -141,8 +141,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
|
**The command `dotnet restore` must be done at least once from the top directory
|
||||||
to obtain all the necessary .NET packages.**
|
to obtain all the necessary .NET packages.**
|
||||||
|
|
||||||
Build with `./build.sh` on Linux and OS X, `./build.ps1` for Core PowerShell on
|
Build with `./build.sh` on Linux and OS X.
|
||||||
Windows, and `./build.FullCLR.ps1` for Full PowerShell on Windows.
|
|
||||||
|
`Start-PSBuild` from module `.\PowerShellGitHubDev.psm1` on Windows.
|
||||||
|
|
||||||
Specifically:
|
Specifically:
|
||||||
|
|
||||||
@ -161,9 +162,13 @@ In PowerShell:
|
|||||||
```powershell
|
```powershell
|
||||||
cd PowerShell
|
cd PowerShell
|
||||||
dotnet restore
|
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
|
### PowerShellGitHubDev
|
||||||
|
|
||||||
Alternatively, the `PowerShellGitHubDev.psm1` module contains a `Start-PSBuild`
|
Alternatively, the `PowerShellGitHubDev.psm1` module contains a `Start-PSBuild`
|
||||||
|
@ -26,7 +26,7 @@ build_script:
|
|||||||
dotnet --version
|
dotnet --version
|
||||||
Import-Module .\PowerShellGitHubDev.psm1
|
Import-Module .\PowerShellGitHubDev.psm1
|
||||||
Start-PSBuild
|
Start-PSBuild
|
||||||
- ps: .\build.fullCLR.ps1
|
Start-PSBuild -FullCLR
|
||||||
|
|
||||||
test_script:
|
test_script:
|
||||||
- ps: |
|
- ps: |
|
||||||
@ -39,7 +39,6 @@ test_script:
|
|||||||
(New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path $testResultsFile))
|
(New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path $testResultsFile))
|
||||||
#
|
#
|
||||||
# FullCLR
|
# FullCLR
|
||||||
Import-Module .\PowerShellGitHubDev.psm1
|
|
||||||
$testResultsFile = ".\TestsResults.FullCLR.xml"
|
$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"
|
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))
|
(New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path $testResultsFile))
|
||||||
|
@ -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 New Issue
Block a user