Skip to content

Commit e0612cb

Browse files
committed
utils: make -BuildTargets optional in build.ps1
This doesn't really add much to readability and is almost always `default`. Simply assume the default behaviour and allow callers to alter the behaviour if needed.
1 parent fc52f2f commit e0612cb

File tree

1 file changed

+10
-31
lines changed

1 file changed

+10
-31
lines changed

utils/build.ps1

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,7 +1172,7 @@ function Build-CMakeProject {
11721172
}
11731173
}
11741174

1175-
if ("" -ne $InstallTo) {
1175+
if ($BuildTargets.Length -eq 0 -and $InstallTo) {
11761176
Invoke-Program cmake.exe --build $Bin --target install
11771177
}
11781178
}
@@ -1309,7 +1309,6 @@ function Build-CMark($Arch) {
13091309
-Bin "$($Arch.BinaryCache)\cmark-gfm-0.29.0.gfm.13" `
13101310
-InstallTo "$($Arch.ToolchainInstallRoot)\usr" `
13111311
-Arch $Arch `
1312-
-BuildTargets default `
13131312
-Defines @{
13141313
BUILD_SHARED_LIBS = "YES";
13151314
BUILD_TESTING = "NO";
@@ -1477,7 +1476,6 @@ function Build-ZLib([Platform]$Platform, $Arch) {
14771476
-Arch $Arch `
14781477
-Platform $Platform `
14791478
-UseMSVCCompilers C `
1480-
-BuildTargets default `
14811479
-Defines @{
14821480
BUILD_SHARED_LIBS = "NO";
14831481
CMAKE_POSITION_INDEPENDENT_CODE = "YES";
@@ -1497,7 +1495,6 @@ function Build-XML2([Platform]$Platform, $Arch) {
14971495
-Arch $Arch `
14981496
-Platform $Platform `
14991497
-UseMSVCCompilers C,CXX `
1500-
-BuildTargets default `
15011498
-Defines @{
15021499
BUILD_SHARED_LIBS = "NO";
15031500
CMAKE_INSTALL_BINDIR = "bin/$Platform/$ArchName";
@@ -1564,7 +1561,6 @@ function Build-CURL([Platform]$Platform, $Arch) {
15641561
-Arch $Arch `
15651562
-Platform $Platform `
15661563
-UseMSVCCompilers C `
1567-
-BuildTargets default `
15681564
-Defines ($PlatformDefines + @{
15691565
BUILD_SHARED_LIBS = "NO";
15701566
BUILD_TESTING = "NO";
@@ -1687,7 +1683,6 @@ function Build-Runtime([Platform]$Platform, $Arch) {
16871683
-Platform $Platform `
16881684
-CacheScript $SourceCache\swift\cmake\caches\Runtime-$Platform-$($Arch.LLVMName).cmake `
16891685
-UseBuiltCompilers C,CXX,Swift `
1690-
-BuildTargets default `
16911686
-Defines ($PlatformDefines + @{
16921687
CMAKE_Swift_COMPILER_TARGET = $Arch.LLVMTarget.Replace("$AndroidAPILevel", "");
16931688
CMAKE_Swift_COMPILER_WORKS = "YES";
@@ -1728,7 +1723,6 @@ function Build-Dispatch([Platform]$Platform, $Arch, [switch]$Test = $false) {
17281723
-Arch $Arch `
17291724
-Platform $Platform `
17301725
-UseBuiltCompilers C,CXX,Swift `
1731-
-BuildTargets $Targets `
17321726
-Defines @{
17331727
ENABLE_SWIFT = "YES";
17341728
}
@@ -1772,7 +1766,6 @@ function Build-Foundation([Platform]$Platform, $Arch, [switch]$Test = $false) {
17721766

17731767
Isolate-EnvVars {
17741768
$TestingDefines = @{ ENABLE_TESTING = "NO" }
1775-
$Targets = @("default")
17761769
$InstallPath = "$($Arch.SDKInstallRoot)\usr"
17771770

17781771
Build-CMakeProject `
@@ -1782,7 +1775,7 @@ function Build-Foundation([Platform]$Platform, $Arch, [switch]$Test = $false) {
17821775
-Arch $Arch `
17831776
-Platform $Platform `
17841777
-UseBuiltCompilers ASM,C,CXX,Swift `
1785-
-BuildTargets $Targets `
1778+
-SwiftSDK:$SDKRoot `
17861779
-Defines (@{
17871780
FOUNDATION_BUILD_TOOLS = if ($Platform -eq "Windows") { "YES" } else { "NO" };
17881781
CURL_DIR = "$LibraryRoot\curl-8.9.1\usr\lib\$Platform\$ShortArch\cmake\CURL";
@@ -1832,15 +1825,11 @@ function Build-FoundationMacros() {
18321825
$SwiftSDK = $BuildArch.SDKInstallRoot
18331826
}
18341827

1835-
$Targets = if ($Build) {
1836-
@("default")
1837-
} else {
1838-
@("default", "install")
1839-
}
1840-
18411828
$InstallDir = $null
1829+
$Targets = @("default")
18421830
if (-not $Build) {
18431831
$InstallDir = "$($Arch.ToolchainInstallRoot)\usr"
1832+
$Targets = @()
18441833
}
18451834

18461835
$SwiftSyntaxCMakeModules = if ($Build -and $HostArch -ne $BuildArch) {
@@ -1857,7 +1846,7 @@ function Build-FoundationMacros() {
18571846
-Platform $Platform `
18581847
-UseBuiltCompilers Swift `
18591848
-SwiftSDK:$SwiftSDK `
1860-
-BuildTargets $Targets `
1849+
-BuildTargets:$Targets `
18611850
-Defines @{
18621851
SwiftSyntax_DIR = $SwiftSyntaxCMakeModules;
18631852
}
@@ -1882,7 +1871,7 @@ function Build-XCTest([Platform]$Platform, $Arch, [switch]$Test = $false) {
18821871
$env:Path = "$XCTestBinaryCache;$FoundationBinaryCache\bin;$DispatchBinaryCache;$(Get-TargetProjectBinaryCache $Arch Runtime)\bin;$env:Path;$UnixToolsBinDir"
18831872
} else {
18841873
$TestingDefines = @{ ENABLE_TESTING = "NO" }
1885-
$Targets = @("default")
1874+
$Targets = @("install")
18861875
$InstallPath = "$($Arch.XCTestInstallRoot)\usr"
18871876
}
18881877

@@ -1910,7 +1899,6 @@ function Build-Testing([Platform]$Platform, $Arch, [switch]$Test = $false) {
19101899
# TODO: Test
19111900
return
19121901
} else {
1913-
$Targets = @("default")
19141902
$InstallPath = "$($Arch.SwiftTestingInstallRoot)\usr"
19151903
}
19161904

@@ -1921,7 +1909,6 @@ function Build-Testing([Platform]$Platform, $Arch, [switch]$Test = $false) {
19211909
-Arch $Arch `
19221910
-Platform $Platform `
19231911
-UseBuiltCompilers C,CXX,Swift `
1924-
-BuildTargets $Targets `
19251912
-Defines (@{
19261913
BUILD_SHARED_LIBS = "YES";
19271914
CMAKE_BUILD_WITH_INSTALL_RPATH = "YES";
@@ -2020,7 +2007,6 @@ function Build-SQLite($Arch) {
20202007
-InstallTo $LibraryRoot\sqlite-3.46.0\usr `
20212008
-Arch $Arch `
20222009
-UseMSVCCompilers C `
2023-
-BuildTargets default `
20242010
-Defines @{
20252011
BUILD_SHARED_LIBS = "NO";
20262012
}
@@ -2035,7 +2021,6 @@ function Build-System($Arch) {
20352021
-Platform Windows `
20362022
-UseBuiltCompilers C,Swift `
20372023
-SwiftSDK (Get-HostSwiftSDK) `
2038-
-BuildTargets default `
20392024
-Defines @{
20402025
BUILD_SHARED_LIBS = "YES";
20412026
}
@@ -2055,7 +2040,6 @@ function Build-ToolsSupportCore($Arch) {
20552040
-Platform Windows `
20562041
-UseBuiltCompilers C,Swift `
20572042
-SwiftSDK (Get-HostSwiftSDK) `
2058-
-BuildTargets default `
20592043
-Defines @{
20602044
BUILD_SHARED_LIBS = "YES";
20612045
SwiftSystem_DIR = (Get-HostProjectCMakeModules System);
@@ -2081,7 +2065,7 @@ function Build-LLBuild($Arch, [switch]$Test = $false) {
20812065
$env:CLANG = ([IO.Path]::Combine((Get-HostProjectBinaryCache Compilers), "bin", "clang.exe"))
20822066
$InstallPath = ""
20832067
} else {
2084-
$Targets = @("default")
2068+
$Targets = @()
20852069
$TestingDefines = @{}
20862070
$InstallPath = "$($Arch.ToolchainInstallRoot)\usr"
20872071
}
@@ -2129,7 +2113,6 @@ function Build-ArgumentParser($Arch) {
21292113
-Platform Windows `
21302114
-UseBuiltCompilers Swift `
21312115
-SwiftSDK (Get-HostSwiftSDK) `
2132-
-BuildTargets default `
21332116
-Defines @{
21342117
BUILD_SHARED_LIBS = "YES";
21352118
BUILD_TESTING = "NO";
@@ -2145,7 +2128,6 @@ function Build-Driver($Arch) {
21452128
-Platform Windows `
21462129
-UseBuiltCompilers C,CXX,Swift `
21472130
-SwiftSDK (Get-HostSwiftSDK) `
2148-
-BuildTargets default `
21492131
-Defines @{
21502132
BUILD_SHARED_LIBS = "YES";
21512133
SwiftSystem_DIR = (Get-HostProjectCMakeModules System);
@@ -2185,7 +2167,6 @@ function Build-Collections($Arch) {
21852167
-Platform Windows `
21862168
-UseBuiltCompilers C,Swift `
21872169
-SwiftSDK (Get-HostSwiftSDK) `
2188-
-BuildTargets default `
21892170
-Defines @{
21902171
BUILD_SHARED_LIBS = "YES";
21912172
}
@@ -2235,7 +2216,6 @@ function Build-PackageManager($Arch) {
22352216
-Platform Windows `
22362217
-UseBuiltCompilers C,Swift `
22372218
-SwiftSDK (Get-HostSwiftSDK) `
2238-
-BuildTargets default `
22392219
-Defines @{
22402220
BUILD_SHARED_LIBS = "YES";
22412221
CMAKE_Swift_FLAGS = @("-DCRYPTO_v2");
@@ -2263,7 +2243,6 @@ function Build-Markdown($Arch) {
22632243
-Platform Windows `
22642244
-UseBuiltCompilers C,Swift `
22652245
-SwiftSDK (Get-HostSwiftSDK) `
2266-
-BuildTargets default `
22672246
-Defines @{
22682247
BUILD_SHARED_LIBS = "NO";
22692248
ArgumentParser_DIR = (Get-HostProjectCMakeModules ArgumentParser);
@@ -2281,7 +2260,6 @@ function Build-Format($Arch) {
22812260
-UseMSVCCompilers C `
22822261
-UseBuiltCompilers Swift `
22832262
-SwiftSDK (Get-HostSwiftSDK) `
2284-
-BuildTargets default `
22852263
-Defines @{
22862264
BUILD_SHARED_LIBS = "YES";
22872265
ArgumentParser_DIR = (Get-HostProjectCMakeModules ArgumentParser);
@@ -2318,7 +2296,6 @@ function Build-SourceKitLSP($Arch) {
23182296
-Platform Windows `
23192297
-UseBuiltCompilers C,Swift `
23202298
-SwiftSDK (Get-HostSwiftSDK) `
2321-
-BuildTargets default `
23222299
-Defines @{
23232300
SwiftSyntax_DIR = (Get-HostProjectCMakeModules Compilers);
23242301
SwiftSystem_DIR = (Get-HostProjectCMakeModules System);
@@ -2361,8 +2338,10 @@ function Build-TestingMacros() {
23612338
}
23622339

23632340
$InstallDir = $null
2341+
$Targets = @("default")
23642342
if (-not $Build) {
23652343
$InstallDir = "$($Arch.ToolchainInstallRoot)\usr"
2344+
$Targets = @()
23662345
}
23672346

23682347
$SwiftSyntaxCMakeModules = if ($Build -and $HostArch -ne $BuildArch) {
@@ -2379,7 +2358,7 @@ function Build-TestingMacros() {
23792358
-Platform $Platform `
23802359
-UseBuiltCompilers Swift `
23812360
-SwiftSDK:$SwiftSDK `
2382-
-BuildTargets $Targets `
2361+
-BuildTargets:$Targets `
23832362
-Defines @{
23842363
SwiftSyntax_DIR = $SwiftSyntaxCMakeModules;
23852364
}

0 commit comments

Comments
 (0)