Skip to content

Commit bb65b08

Browse files
authored
Merge pull request #79561 from compnerd/structure
utils: provide structure to settings
2 parents f5dd557 + b1207ed commit bb65b08

File tree

1 file changed

+38
-9
lines changed

1 file changed

+38
-9
lines changed

utils/build.ps1

+38-9
Original file line numberDiff line numberDiff line change
@@ -1562,6 +1562,20 @@ function Build-BuildTools($Arch) {
15621562
}
15631563
}
15641564

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

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

17211740
# Reference: https://github.com/microsoft/mimalloc/tree/dev/bin#minject
@@ -2129,13 +2148,14 @@ function Build-ExperimentalRuntime {
21292148
}
21302149

21312150
function Write-SDKSettingsPlist([Platform]$Platform, $Arch) {
2151+
$SDKSettings = @{
2152+
DefaultProperties = @{
2153+
}
2154+
}
21322155
if ($Platform -eq [Platform]::Windows) {
2133-
Invoke-Program "$(Get-PythonExecutable)" -c "import plistlib; print(str(plistlib.dumps({ 'DefaultProperties': { 'DEFAULT_USE_RUNTIME': 'MD' } }), encoding='utf-8'))" `
2134-
-OutFile "$($Arch.SDKInstallRoot)\SDKSettings.plist"
2135-
} else {
2136-
Invoke-Program "$(Get-PythonExecutable)" -c "import plistlib; print(str(plistlib.dumps({ 'DefaultProperties': { } }), encoding='utf-8'))" `
2137-
-OutFile "$($Arch.SDKInstallRoot)\SDKSettings.plist"
2156+
$SDKSettings.DefaultProperties.DEFAULT_USE_RUNTIME = "MD"
21382157
}
2158+
Write-PList -Settings $SDKSettings -Path "$($Arch.SDKInstallRoot)\SDKSettings.plist"
21392159

21402160
$SDKSettings = @{
21412161
CanonicalName = "$($Arch.LLVMTarget)"
@@ -2387,8 +2407,17 @@ function Build-Testing([Platform]$Platform, $Arch, [switch]$Test = $false) {
23872407
}
23882408

23892409
function Write-PlatformInfoPlist([Platform] $Platform) {
2390-
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'))" `
2391-
-OutFile ([IO.Path]::Combine((Get-PlatformRoot $Platform), "Info.plist"))
2410+
$Settings = @{
2411+
DefaultProperties = @{
2412+
SWIFT_TESTING_VERSION = "development"
2413+
XCTEST_VERSION = "development"
2414+
}
2415+
}
2416+
if ($Platform -eq [Platform]::Windows) {
2417+
$Settings.DefaultProperties.SWIFTC_FLAGS = @( "-use-ld=lld" )
2418+
}
2419+
2420+
Write-PList -Settings $Settings -Path "$(Get-PlatformRoot $Platform)\Info.plist"
23922421
}
23932422

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

0 commit comments

Comments
 (0)