Skip to content

Commit cee1e54

Browse files
authored
Add ability to cross compile (PowerShell#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.
1 parent 73114ee commit cee1e54

3 files changed

Lines changed: 34 additions & 18 deletions

File tree

PowerShell.Common.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111

112112
<PropertyGroup>
113113
<DefineConstants>$(DefineConstants);CORECLR</DefineConstants>
114-
<IsWindows Condition="'$(OS)' == 'Windows_NT'">true</IsWindows>
114+
<IsWindows Condition="'$(IsWindows)' =='true' or ( '$(IsWindows)' == '' and '$(OS)' == 'Windows_NT')">true</IsWindows>
115115
</PropertyGroup>
116116

117117
<!-- Define non-windows, all configuration properties -->

build.psm1

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,8 @@ function Start-PSBuild {
237237

238238
[ValidatePattern("^v\d+\.\d+\.\d+(-\w+(\.\d+)?)?$")]
239239
[ValidateNotNullOrEmpty()]
240-
[string]$ReleaseTag
240+
[string]$ReleaseTag,
241+
[switch]$Detailed
241242
)
242243

243244
if ($PsCmdlet.ParameterSetName -eq "Default" -and !$NoPSModuleRestore)
@@ -327,10 +328,22 @@ Fix steps:
327328
$Arguments += "--output", (Split-Path $Options.Output)
328329
}
329330

331+
if ($Options.Runtime -like 'win*' -or ($Options.Runtime -eq 'fxdependent' -and $Environment.IsWindows)) {
332+
$Arguments += "/property:IsWindows=true"
333+
}
334+
else {
335+
$Arguments += "/property:IsWindows=false"
336+
}
337+
330338
$Arguments += "--configuration", $Options.Configuration
331339
$Arguments += "--framework", $Options.Framework
332340

333-
if (-not $SMAOnly -and $Options.Runtime -ne 'fxdependent') {
341+
if ($Detailed.IsPresent)
342+
{
343+
$Arguments += '--verbosity', 'd'
344+
}
345+
346+
if (-not $SMAOnly -and $Options.Runtime -notlike 'fxdependent*') {
334347
# libraries should not have runtime
335348
$Arguments += "--runtime", $Options.Runtime
336349
}
@@ -653,19 +666,6 @@ function New-PSOptions {
653666
}
654667
Write-Verbose "Using configuration '$Configuration'"
655668

656-
$PowerShellDir = if (!$Environment.IsWindows) {
657-
"powershell-unix"
658-
} else {
659-
"powershell-win-core"
660-
}
661-
$Top = [IO.Path]::Combine($PSScriptRoot, "src", $PowerShellDir)
662-
Write-Verbose "Top project directory is $Top"
663-
664-
if (-not $Framework) {
665-
$Framework = "netcoreapp2.1"
666-
Write-Verbose "Using framework '$Framework'"
667-
}
668-
669669
if (-not $Runtime) {
670670
if ($Environment.IsLinux) {
671671
$Runtime = "linux-x64"
@@ -691,6 +691,20 @@ function New-PSOptions {
691691
}
692692
}
693693

694+
$PowerShellDir = if ($Runtime -like 'win*' -or ($Runtime -eq 'fxdependent' -and $Environment.IsWindows)) {
695+
"powershell-win-core"
696+
} else {
697+
"powershell-unix"
698+
}
699+
700+
$Top = [IO.Path]::Combine($PSScriptRoot, "src", $PowerShellDir)
701+
Write-Verbose "Top project directory is $Top"
702+
703+
if (-not $Framework) {
704+
$Framework = "netcoreapp2.1"
705+
Write-Verbose "Using framework '$Framework'"
706+
}
707+
694708
$Executable = if ($Runtime -eq 'fxdependent') {
695709
"pwsh.dll"
696710
} elseif ($Environment.IsLinux -or $Environment.IsMacOS) {

test/powershell/engine/Help/UpdatableHelpSystem.Tests.ps1

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,11 +329,13 @@ function ValidateSaveHelp
329329

330330
$compressedFile = GetFiles -fileType "*$extension" -path $path | ForEach-Object {Split-Path $_ -Leaf}
331331
$expectedCompressedFile = $testCases[$moduleName].CompressedFiles
332-
$expectedCompressedFile | Should -Be $compressedFile
332+
$expectedCompressedFile | Should -Not -BeNullOrEmpty -Because "Test data (expectedCompressedFile) should never be null"
333+
$compressedFile | Should -Be $expectedCompressedFile -Because "Save-Help for $module should download '$expectedCompressedFile'"
333334

334335
$helpInfoFile = GetFiles -fileType "*HelpInfo.xml" -path $path | ForEach-Object {Split-Path $_ -Leaf}
335336
$expectedHelpInfoFile = $testCases[$moduleName].HelpInfoFiles
336-
$expectedHelpInfoFile | Should -Be $helpInfoFile
337+
$expectedHelpInfoFile | Should -Not -BeNullOrEmpty -Because "Test data (expectedHelpInfoFile) should never be null"
338+
$helpInfoFile | Should -Be $expectedHelpInfoFile -Because "Save-Help for $module should download '$expectedHelpInfoFile'"
337339
}
338340

339341
Describe "Validate Update-Help from the Web for one PowerShell Core module." -Tags @('CI', 'RequireAdminOnWindows', 'RequireSudoOnUnix') {

0 commit comments

Comments
 (0)