Skip to content

Commit ff025ec

Browse files
committed
utils: provide structure to settings
Use a structural definition of the settings and convert them to the appropriate serialised format as a delayed operation. This makes it easier to read the settings and modify them as we iterate on the toolchain. Take the opportunity to extract the PList conversion into a helper function.
1 parent a04a8d0 commit ff025ec

File tree

1 file changed

+38
-9
lines changed

1 file changed

+38
-9
lines changed

utils/build.ps1

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,6 +1564,20 @@ function Build-BuildTools($Arch) {
15641564
}
15651565
}
15661566

1567+
function Write-PList {
1568+
[CmdletBinding(PositionalBinding = $false)]
1569+
param
1570+
(
1571+
[Parameter(Mandatory = $true)]
1572+
[PSCustomObject] $Settings,
1573+
[Parameter(Mandatory = $true)]
1574+
[string] $Path
1575+
)
1576+
1577+
Invoke-Program "$(Get-PythonExecutable)" -c "import plistlib; print(str(plistlib.dumps($(($Settings | ConvertTo-JSON -Compress) -replace '"', "'")), encoding='utf-8'))" `
1578+
-OutFile $Path
1579+
}
1580+
15671581
function Build-Compilers() {
15681582
[CmdletBinding(PositionalBinding = $false)]
15691583
param
@@ -1716,8 +1730,13 @@ function Build-Compilers() {
17161730
})
17171731
}
17181732

1719-
Invoke-Program "$(Get-PythonExecutable)" -c "import plistlib; print(str(plistlib.dumps({ 'Identifier': '${ToolchainIdentifier}', 'FallbackLibrarySearchPaths': ['usr/bin'], 'Version': '${ProductVersion}' }), encoding='utf-8'))" `
1720-
-OutFile "$($Arch.ToolchainInstallRoot)\ToolchainInfo.plist"
1733+
$Settings = @{
1734+
FallbackLibrarySearchPaths = @("usr/bin")
1735+
Identifier = "${ToolchainIdentifier}"
1736+
Version = "${ProductVersion}"
1737+
}
1738+
1739+
Write-PList -Settings $Settings -Path "$($Arch.ToolchainInstallRoot)\ToolchainInfo.plist"
17211740
}
17221741

17231742
# Reference: https://github.com/microsoft/mimalloc/tree/dev/bin#minject
@@ -2139,13 +2158,14 @@ function Build-ExperimentalRuntime {
21392158
}
21402159

21412160
function Write-SDKSettingsPlist([Platform]$Platform, $Arch) {
2161+
$SDKSettings = @{
2162+
DefaultProperties = @{
2163+
}
2164+
}
21422165
if ($Platform -eq [Platform]::Windows) {
2143-
Invoke-Program "$(Get-PythonExecutable)" -c "import plistlib; print(str(plistlib.dumps({ 'DefaultProperties': { 'DEFAULT_USE_RUNTIME': 'MD' } }), encoding='utf-8'))" `
2144-
-OutFile "$($Arch.SDKInstallRoot)\SDKSettings.plist"
2145-
} else {
2146-
Invoke-Program "$(Get-PythonExecutable)" -c "import plistlib; print(str(plistlib.dumps({ 'DefaultProperties': { } }), encoding='utf-8'))" `
2147-
-OutFile "$($Arch.SDKInstallRoot)\SDKSettings.plist"
2166+
$SDKSettings.DefaultProperties.DEFAULT_USE_RUNTIME = "MD"
21482167
}
2168+
Write-PList -Settings $SDKSettings -Path "$($Arch.SDKInstallRoot)\SDKSettings.plist"
21492169

21502170
$SDKSettings = @{
21512171
CanonicalName = "$($Arch.LLVMTarget)"
@@ -2397,8 +2417,17 @@ function Build-Testing([Platform]$Platform, $Arch, [switch]$Test = $false) {
23972417
}
23982418

23992419
function Write-PlatformInfoPlist([Platform] $Platform) {
2400-
Invoke-Program "$(Get-PythonExecutable)" -c "import plistlib; print(str(plistlib.dumps({ 'DefaultProperties': { 'XCTEST_VERSION': 'development', 'SWIFT_TESTING_VERSION': 'development', 'SWIFTC_FLAGS': ['-use-ld=lld'] } }), encoding='utf-8'))" `
2401-
-OutFile ([IO.Path]::Combine((Get-PlatformRoot $Platform), "Info.plist"))
2420+
$Settings = @{
2421+
DefaultProperties = @{
2422+
SWIFT_TESTING_VERSION = "development"
2423+
XCTEST_VERSION = "development"
2424+
}
2425+
}
2426+
if ($Platform -eq [Platform]::Windows) {
2427+
$Settings.DefaultProperties.SWIFTC_FLAGS = @( "-use-ld=lld" )
2428+
}
2429+
2430+
Write-PList -Settings $Settings -Path "$(Get-PlatformRoot $Platform)\Info.plist"
24022431
}
24032432

24042433
# Copies files installed by CMake from the arch-specific platform root,

0 commit comments

Comments
 (0)