Skip to content

Commit 8b115a7

Browse files
Replace "Windows" string compares with [Platform]::Windows enum
1 parent 3b389d7 commit 8b115a7

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

utils/build.ps1

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,7 @@ function Build-CMakeProject {
926926
[string] $Src,
927927
[string] $Bin,
928928
[string] $InstallTo = "",
929-
[Platform] $Platform = "Windows",
929+
[Platform] $Platform = [Platform]::Windows,
930930
[hashtable] $Arch,
931931
[string] $Generator = "Ninja",
932932
[string] $CacheScript = "",
@@ -952,7 +952,7 @@ function Build-CMakeProject {
952952
# Enter the developer command shell early so we can resolve cmake.exe
953953
# for version checks.
954954
Isolate-EnvVars {
955-
if ($Platform -eq "Windows") {
955+
if ($Platform -eq [Platform]::Windows) {
956956
Invoke-VsDevShell $Arch
957957
}
958958

@@ -973,7 +973,7 @@ function Build-CMakeProject {
973973
# Add additional defines (unless already present)
974974
$Defines = $Defines.Clone()
975975

976-
if (($Platform -ne "Windows") -or ($Arch.CMakeName -ne $BuildArch.CMakeName)) {
976+
if (($Platform -ne [Platform]::Windows) -or ($Arch.CMakeName -ne $BuildArch.CMakeName)) {
977977
TryAdd-KeyValue $Defines CMAKE_SYSTEM_NAME $Platform
978978
TryAdd-KeyValue $Defines CMAKE_SYSTEM_PROCESSOR $Arch.CMakeName
979979
}
@@ -1021,14 +1021,14 @@ function Build-CMakeProject {
10211021
}
10221022

10231023
$CXXFlags = @()
1024-
if ($Platform -eq "Windows") {
1024+
if ($Platform -eq [Platform]::Windows) {
10251025
$CXXFlags += $CFlags.Clone() + @("/Zc:__cplusplus")
10261026
}
10271027

10281028
if ($UseMSVCCompilers.Contains("C") -Or $UseMSVCCompilers.Contains("CXX") -Or
10291029
$UseBuiltCompilers.Contains("C") -Or $UseBuiltCompilers.Contains("CXX") -Or
10301030
$UsePinnedCompilers.Contains("C") -Or $UsePinnedCompilers.Contains("CXX")) {
1031-
if ($DebugInfo -and $Platform -eq "Windows") {
1031+
if ($DebugInfo -and $Platform -eq [Platform]::Windows) {
10321032
Append-FlagsDefine $Defines CMAKE_MSVC_DEBUG_INFORMATION_FORMAT Embedded
10331033
Append-FlagsDefine $Defines CMAKE_POLICY_CMP0141 NEW
10341034
# Add additional linker flags for generating the debug info.
@@ -1066,7 +1066,7 @@ function Build-CMakeProject {
10661066
TryAdd-KeyValue $Defines CMAKE_ASM_COMPILER (Get-PinnedToolchainTool $Driver)
10671067
}
10681068
Append-FlagsDefine $Defines CMAKE_ASM_FLAGS "--target=$($Arch.LLVMTarget)"
1069-
if ($Platform -eq "Windows") {
1069+
if ($Platform -eq [Platform]::Windows) {
10701070
TryAdd-KeyValue $Defines CMAKE_ASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL "/MD"
10711071
}
10721072
}
@@ -1079,7 +1079,7 @@ function Build-CMakeProject {
10791079
}
10801080
TryAdd-KeyValue $Defines CMAKE_C_COMPILER_TARGET $Arch.LLVMTarget
10811081

1082-
if (-not (Test-CMakeAtLeast -Major 3 -Minor 26 -Patch 3) -and $Platform -eq "Windows") {
1082+
if (-not (Test-CMakeAtLeast -Major 3 -Minor 26 -Patch 3) -and $Platform -eq [Platform]::Windows) {
10831083
# Workaround for https://github.com/ninja-build/ninja/issues/2280
10841084
TryAdd-KeyValue $Defines CMAKE_CL_SHOWINCLUDES_PREFIX "Note: including file: "
10851085
}
@@ -1098,7 +1098,7 @@ function Build-CMakeProject {
10981098
}
10991099
TryAdd-KeyValue $Defines CMAKE_CXX_COMPILER_TARGET $Arch.LLVMTarget
11001100

1101-
if (-not (Test-CMakeAtLeast -Major 3 -Minor 26 -Patch 3) -and $Platform -eq "Windows") {
1101+
if (-not (Test-CMakeAtLeast -Major 3 -Minor 26 -Patch 3) -and $Platform -eq [Platform]::Windows) {
11021102
# Workaround for https://github.com/ninja-build/ninja/issues/2280
11031103
TryAdd-KeyValue $Defines CMAKE_CL_SHOWINCLUDES_PREFIX "Note: including file: "
11041104
}
@@ -1118,7 +1118,7 @@ function Build-CMakeProject {
11181118
} else {
11191119
TryAdd-KeyValue $Defines CMAKE_Swift_COMPILER (Get-PinnedToolchainTool "swiftc.exe")
11201120
}
1121-
if (-not ($Platform -eq "Windows")) {
1121+
if ($Platform -ne [Platform]::Windows) {
11221122
TryAdd-KeyValue $Defines CMAKE_Swift_COMPILER_WORKS = "YES"
11231123
}
11241124
TryAdd-KeyValue $Defines CMAKE_Swift_COMPILER_TARGET $Arch.LLVMTarget.Replace("$AndroidAPILevel", "")
@@ -1167,7 +1167,7 @@ function Build-CMakeProject {
11671167

11681168
# Debug Information
11691169
if ($DebugInfo) {
1170-
if ($Platform -eq "Windows") {
1170+
if ($Platform -eq [Platform]::Windows) {
11711171
if ($SwiftDebugFormat -eq "dwarf") {
11721172
$SwiftArgs += @("-g", "-Xlinker", "/DEBUG:DWARF", "-use-ld=lld-link")
11731173
} else {
@@ -1180,7 +1180,7 @@ function Build-CMakeProject {
11801180
$SwiftArgs += "-gnone"
11811181
}
11821182

1183-
if ($Platform -eq "Windows") {
1183+
if ($Platform -eq [Platform]::Windows) {
11841184
$SwiftArgs += @("-Xlinker", "/INCREMENTAL:NO")
11851185
# Swift requires COMDAT folding and de-duplication
11861186
$SwiftArgs += @("-Xlinker", "/OPT:REF")
@@ -1781,9 +1781,9 @@ function Build-CURL([Platform]$Platform, $Arch) {
17811781
CURL_USE_LIBSSH2 = "NO";
17821782
CURL_USE_MBEDTLS = "NO";
17831783
CURL_USE_OPENSSL = "NO";
1784-
CURL_USE_SCHANNEL = if ($Platform -eq "Windows") { "YES" } else { "NO" };
1784+
CURL_USE_SCHANNEL = if ($Platform -eq [Platform]::Windows) { "YES" } else { "NO" };
17851785
CURL_USE_WOLFSSL = "NO";
1786-
CURL_WINDOWS_SSPI = if ($Platform -eq "Windows") { "YES" } else { "NO" };
1786+
CURL_WINDOWS_SSPI = if ($Platform -eq [Platform]::Windows) { "YES" } else { "NO" };
17871787
CURL_ZLIB = "YES";
17881788
CURL_ZSTD = "NO";
17891789
ENABLE_ARES = "NO";
@@ -1804,8 +1804,8 @@ function Build-CURL([Platform]$Platform, $Arch) {
18041804
USE_NGTCP2 = "NO";
18051805
USE_QUICHE = "NO";
18061806
USE_OPENSSL_QUIC = "NO";
1807-
USE_WIN32_IDN = if ($Platform -eq "Windows") { "YES" } else { "NO" };
1808-
USE_WIN32_LARGE_FILES = if ($Platform -eq "Windows") { "YES" } else { "NO" };
1807+
USE_WIN32_IDN = if ($Platform -eq [Platform]::Windows) { "YES" } else { "NO" };
1808+
USE_WIN32_LARGE_FILES = if ($Platform -eq [Platform]::Windows) { "YES" } else { "NO" };
18091809
USE_WIN32_LDAP = "NO";
18101810
ZLIB_ROOT = "$LibraryRoot\zlib-1.3.1\usr";
18111811
ZLIB_LIBRARY = "$LibraryRoot\zlib-1.3.1\usr\lib\$Platform\$ArchName\zlibstatic.lib";
@@ -1852,7 +1852,7 @@ function Build-Runtime([Platform]$Platform, $Arch) {
18521852
SWIFT_NATIVE_SWIFT_TOOLS_PATH = (Join-Path -Path $CompilersBinaryCache -ChildPath "bin");
18531853
SWIFT_PATH_TO_LIBDISPATCH_SOURCE = "$SourceCache\swift-corelibs-libdispatch";
18541854
SWIFT_PATH_TO_STRING_PROCESSING_SOURCE = "$SourceCache\swift-experimental-string-processing";
1855-
CMAKE_SHARED_LINKER_FLAGS = if ($Platform -eq "Windows") { @("/INCREMENTAL:NO", "/OPT:REF", "/OPT:ICF") } else { @() };
1855+
CMAKE_SHARED_LINKER_FLAGS = if ($Platform -eq [Platform]::Windows) { @("/INCREMENTAL:NO", "/OPT:REF", "/OPT:ICF") } else { @() };
18561856
})
18571857
}
18581858

@@ -1918,13 +1918,13 @@ function Build-Foundation([Platform]$Platform, $Arch, [switch]$Test = $false) {
19181918
$ShortArch = $Arch.LLVMName
19191919

19201920
Isolate-EnvVars {
1921-
$SDKRoot = if ($Platform -eq "Windows") {
1921+
$SDKRoot = if ($Platform -eq [Platform]::Windows) {
19221922
""
19231923
} else {
19241924
(Get-Variable "${Platform}$($Arch.ShortName)" -ValueOnly).SDKInstallRoot
19251925
}
19261926

1927-
$SDKRoot = if ($Platform -eq "Windows") {
1927+
$SDKRoot = if ($Platform -eq [Platform]::Windows) {
19281928
""
19291929
} else {
19301930
(Get-Variable "${Platform}$($Arch.ShortName)" -ValueOnly).SDKInstallRoot
@@ -1940,16 +1940,16 @@ function Build-Foundation([Platform]$Platform, $Arch, [switch]$Test = $false) {
19401940
-SwiftSDK:$SDKRoot `
19411941
-Defines (@{
19421942
ENABLE_TESTING = "NO";
1943-
FOUNDATION_BUILD_TOOLS = if ($Platform -eq "Windows") { "YES" } else { "NO" };
1943+
FOUNDATION_BUILD_TOOLS = if ($Platform -eq [Platform]::Windows) { "YES" } else { "NO" };
19441944
CURL_DIR = "$LibraryRoot\curl-8.9.1\usr\lib\$Platform\$ShortArch\cmake\CURL";
1945-
LIBXML2_LIBRARY = if ($Platform -eq "Windows") {
1945+
LIBXML2_LIBRARY = if ($Platform -eq [Platform]::Windows) {
19461946
"$LibraryRoot\libxml2-2.11.5\usr\lib\$Platform\$ShortArch\libxml2s.lib";
19471947
} else {
19481948
"$LibraryRoot\libxml2-2.11.5\usr\lib\$Platform\$ShortArch\libxml2.a";
19491949
};
19501950
LIBXML2_INCLUDE_DIR = "$LibraryRoot\libxml2-2.11.5\usr\include\libxml2";
19511951
LIBXML2_DEFINITIONS = "-DLIBXML_STATIC";
1952-
ZLIB_LIBRARY = if ($Platform -eq "Windows") {
1952+
ZLIB_LIBRARY = if ($Platform -eq [Platform]::Windows) {
19531953
"$LibraryRoot\zlib-1.3.1\usr\lib\$Platform\$ShortArch\zlibstatic.lib"
19541954
} else {
19551955
"$LibraryRoot\zlib-1.3.1\usr\lib\$Platform\$ShortArch\libz.a"

0 commit comments

Comments
 (0)