From cee1e54e75889fb069014f7de9ad83dddc6f223e Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Tue, 16 Apr 2019 14:14:29 -0700 Subject: [PATCH] Add ability to cross compile (#9374) `-CrossGen` won`t work, but this gives basic ability to build for another platform. This also means you cannot really package for another platform. --- PowerShell.Common.props | 2 +- build.psm1 | 44 ++++++++++++------- .../engine/Help/UpdatableHelpSystem.Tests.ps1 | 6 ++- 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/PowerShell.Common.props b/PowerShell.Common.props index 86430f2f08..42656d777e 100644 --- a/PowerShell.Common.props +++ b/PowerShell.Common.props @@ -111,7 +111,7 @@ $(DefineConstants);CORECLR - true + true diff --git a/build.psm1 b/build.psm1 index f84b4faa94..6d3192e946 100644 --- a/build.psm1 +++ b/build.psm1 @@ -237,7 +237,8 @@ function Start-PSBuild { [ValidatePattern("^v\d+\.\d+\.\d+(-\w+(\.\d+)?)?$")] [ValidateNotNullOrEmpty()] - [string]$ReleaseTag + [string]$ReleaseTag, + [switch]$Detailed ) if ($PsCmdlet.ParameterSetName -eq "Default" -and !$NoPSModuleRestore) @@ -327,10 +328,22 @@ Fix steps: $Arguments += "--output", (Split-Path $Options.Output) } + if ($Options.Runtime -like 'win*' -or ($Options.Runtime -eq 'fxdependent' -and $Environment.IsWindows)) { + $Arguments += "/property:IsWindows=true" + } + else { + $Arguments += "/property:IsWindows=false" + } + $Arguments += "--configuration", $Options.Configuration $Arguments += "--framework", $Options.Framework - if (-not $SMAOnly -and $Options.Runtime -ne 'fxdependent') { + if ($Detailed.IsPresent) + { + $Arguments += '--verbosity', 'd' + } + + if (-not $SMAOnly -and $Options.Runtime -notlike 'fxdependent*') { # libraries should not have runtime $Arguments += "--runtime", $Options.Runtime } @@ -653,19 +666,6 @@ function New-PSOptions { } Write-Verbose "Using configuration '$Configuration'" - $PowerShellDir = if (!$Environment.IsWindows) { - "powershell-unix" - } else { - "powershell-win-core" - } - $Top = [IO.Path]::Combine($PSScriptRoot, "src", $PowerShellDir) - Write-Verbose "Top project directory is $Top" - - if (-not $Framework) { - $Framework = "netcoreapp2.1" - Write-Verbose "Using framework '$Framework'" - } - if (-not $Runtime) { if ($Environment.IsLinux) { $Runtime = "linux-x64" @@ -691,6 +691,20 @@ function New-PSOptions { } } + $PowerShellDir = if ($Runtime -like 'win*' -or ($Runtime -eq 'fxdependent' -and $Environment.IsWindows)) { + "powershell-win-core" + } else { + "powershell-unix" + } + + $Top = [IO.Path]::Combine($PSScriptRoot, "src", $PowerShellDir) + Write-Verbose "Top project directory is $Top" + + if (-not $Framework) { + $Framework = "netcoreapp2.1" + Write-Verbose "Using framework '$Framework'" + } + $Executable = if ($Runtime -eq 'fxdependent') { "pwsh.dll" } elseif ($Environment.IsLinux -or $Environment.IsMacOS) { diff --git a/test/powershell/engine/Help/UpdatableHelpSystem.Tests.ps1 b/test/powershell/engine/Help/UpdatableHelpSystem.Tests.ps1 index 177294d245..687d39d367 100644 --- a/test/powershell/engine/Help/UpdatableHelpSystem.Tests.ps1 +++ b/test/powershell/engine/Help/UpdatableHelpSystem.Tests.ps1 @@ -329,11 +329,13 @@ function ValidateSaveHelp $compressedFile = GetFiles -fileType "*$extension" -path $path | ForEach-Object {Split-Path $_ -Leaf} $expectedCompressedFile = $testCases[$moduleName].CompressedFiles - $expectedCompressedFile | Should -Be $compressedFile + $expectedCompressedFile | Should -Not -BeNullOrEmpty -Because "Test data (expectedCompressedFile) should never be null" + $compressedFile | Should -Be $expectedCompressedFile -Because "Save-Help for $module should download '$expectedCompressedFile'" $helpInfoFile = GetFiles -fileType "*HelpInfo.xml" -path $path | ForEach-Object {Split-Path $_ -Leaf} $expectedHelpInfoFile = $testCases[$moduleName].HelpInfoFiles - $expectedHelpInfoFile | Should -Be $helpInfoFile + $expectedHelpInfoFile | Should -Not -BeNullOrEmpty -Because "Test data (expectedHelpInfoFile) should never be null" + $helpInfoFile | Should -Be $expectedHelpInfoFile -Because "Save-Help for $module should download '$expectedHelpInfoFile'" } Describe "Validate Update-Help from the Web for one PowerShell Core module." -Tags @('CI', 'RequireAdminOnWindows', 'RequireSudoOnUnix') {