Skip to content

Commit adf3bde

Browse files
authored
Merge pull request #76290 from compnerd/targets
utils: make `-BuildTargets` optional in build.ps1
2 parents ada0ceb + 9819577 commit adf3bde

File tree

1 file changed

+18
-35
lines changed

1 file changed

+18
-35
lines changed

utils/build.ps1

Lines changed: 18 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,7 +1184,7 @@ function Build-CMakeProject {
11841184
}
11851185
}
11861186

1187-
if ("" -ne $InstallTo) {
1187+
if ($BuildTargets.Length -eq 0 -and $InstallTo) {
11881188
Invoke-Program cmake.exe --build $Bin --target install
11891189
}
11901190
}
@@ -1321,7 +1321,6 @@ function Build-CMark($Arch) {
13211321
-Bin "$($Arch.BinaryCache)\cmark-gfm-0.29.0.gfm.13" `
13221322
-InstallTo "$($Arch.ToolchainInstallRoot)\usr" `
13231323
-Arch $Arch `
1324-
-BuildTargets default `
13251324
-Defines @{
13261325
BUILD_SHARED_LIBS = "YES";
13271326
BUILD_TESTING = "NO";
@@ -1489,7 +1488,6 @@ function Build-ZLib([Platform]$Platform, $Arch) {
14891488
-Arch $Arch `
14901489
-Platform $Platform `
14911490
-UseMSVCCompilers C `
1492-
-BuildTargets default `
14931491
-Defines @{
14941492
BUILD_SHARED_LIBS = "NO";
14951493
CMAKE_POSITION_INDEPENDENT_CODE = "YES";
@@ -1509,7 +1507,6 @@ function Build-XML2([Platform]$Platform, $Arch) {
15091507
-Arch $Arch `
15101508
-Platform $Platform `
15111509
-UseMSVCCompilers C,CXX `
1512-
-BuildTargets default `
15131510
-Defines @{
15141511
BUILD_SHARED_LIBS = "NO";
15151512
CMAKE_INSTALL_BINDIR = "bin/$Platform/$ArchName";
@@ -1576,7 +1573,6 @@ function Build-CURL([Platform]$Platform, $Arch) {
15761573
-Arch $Arch `
15771574
-Platform $Platform `
15781575
-UseMSVCCompilers C `
1579-
-BuildTargets default `
15801576
-Defines ($PlatformDefines + @{
15811577
BUILD_SHARED_LIBS = "NO";
15821578
BUILD_TESTING = "NO";
@@ -1699,7 +1695,6 @@ function Build-Runtime([Platform]$Platform, $Arch) {
16991695
-Platform $Platform `
17001696
-CacheScript $SourceCache\swift\cmake\caches\Runtime-$Platform-$($Arch.LLVMName).cmake `
17011697
-UseBuiltCompilers C,CXX,Swift `
1702-
-BuildTargets default `
17031698
-Defines ($PlatformDefines + @{
17041699
CMAKE_Swift_COMPILER_TARGET = $Arch.LLVMTarget.Replace("$AndroidAPILevel", "");
17051700
CMAKE_Swift_COMPILER_WORKS = "YES";
@@ -1740,7 +1735,6 @@ function Build-Dispatch([Platform]$Platform, $Arch, [switch]$Test = $false) {
17401735
-Arch $Arch `
17411736
-Platform $Platform `
17421737
-UseBuiltCompilers C,CXX,Swift `
1743-
-BuildTargets $Targets `
17441738
-Defines @{
17451739
ENABLE_SWIFT = "YES";
17461740
}
@@ -1783,9 +1777,11 @@ function Build-Foundation([Platform]$Platform, $Arch, [switch]$Test = $false) {
17831777
$ShortArch = $Arch.LLVMName
17841778

17851779
Isolate-EnvVars {
1786-
$TestingDefines = @{ ENABLE_TESTING = "NO" }
1787-
$Targets = @("default")
1788-
$InstallPath = "$($Arch.SDKInstallRoot)\usr"
1780+
$SDKRoot = if ($Platform -eq "Windows") {
1781+
""
1782+
} else {
1783+
(Get-Variable "${Platform}$($Arch.ShortName)" -ValueOnly).SDKInstallRoot
1784+
}
17891785

17901786
$SDKRoot = if ($Platform -eq "Windows") {
17911787
""
@@ -1796,12 +1792,13 @@ function Build-Foundation([Platform]$Platform, $Arch, [switch]$Test = $false) {
17961792
Build-CMakeProject `
17971793
-Src $SourceCache\swift-corelibs-foundation `
17981794
-Bin $FoundationBinaryCache `
1799-
-InstallTo $InstallPath `
1795+
-InstallTo "$($Arch.SDKInstallRoot)\usr" `
18001796
-Arch $Arch `
18011797
-Platform $Platform `
18021798
-UseBuiltCompilers ASM,C,CXX,Swift `
1803-
-BuildTargets $Targets `
1799+
-SwiftSDK:$SDKRoot `
18041800
-Defines (@{
1801+
ENABLE_TESTING = "NO";
18051802
FOUNDATION_BUILD_TOOLS = if ($Platform -eq "Windows") { "YES" } else { "NO" };
18061803
CURL_DIR = "$LibraryRoot\curl-8.9.1\usr\lib\$Platform\$ShortArch\cmake\CURL";
18071804
LIBXML2_LIBRARY = if ($Platform -eq "Windows") {
@@ -1823,7 +1820,7 @@ function Build-Foundation([Platform]$Platform, $Arch, [switch]$Test = $false) {
18231820
_SwiftFoundationICU_SourceDIR = "$SourceCache\swift-foundation-icu";
18241821
_SwiftCollections_SourceDIR = "$SourceCache\swift-collections";
18251822
SwiftFoundation_MACRO = "$(Get-BuildProjectBinaryCache FoundationMacros)\bin"
1826-
} + $TestingDefines)
1823+
})
18271824
}
18281825
}
18291826
}
@@ -1850,15 +1847,11 @@ function Build-FoundationMacros() {
18501847
$SwiftSDK = $BuildArch.SDKInstallRoot
18511848
}
18521849

1853-
$Targets = if ($Build) {
1854-
@("default")
1855-
} else {
1856-
@("default", "install")
1857-
}
1858-
18591850
$InstallDir = $null
1851+
$Targets = @("default")
18601852
if (-not $Build) {
18611853
$InstallDir = "$($Arch.ToolchainInstallRoot)\usr"
1854+
$Targets = @()
18621855
}
18631856

18641857
$SwiftSyntaxCMakeModules = if ($Build -and $HostArch -ne $BuildArch) {
@@ -1875,7 +1868,7 @@ function Build-FoundationMacros() {
18751868
-Platform $Platform `
18761869
-UseBuiltCompilers Swift `
18771870
-SwiftSDK:$SwiftSDK `
1878-
-BuildTargets $Targets `
1871+
-BuildTargets:$Targets `
18791872
-Defines @{
18801873
SwiftSyntax_DIR = $SwiftSyntaxCMakeModules;
18811874
}
@@ -1900,7 +1893,7 @@ function Build-XCTest([Platform]$Platform, $Arch, [switch]$Test = $false) {
19001893
$env:Path = "$XCTestBinaryCache;$FoundationBinaryCache\bin;$DispatchBinaryCache;$(Get-TargetProjectBinaryCache $Arch Runtime)\bin;$env:Path;$UnixToolsBinDir"
19011894
} else {
19021895
$TestingDefines = @{ ENABLE_TESTING = "NO" }
1903-
$Targets = @("default")
1896+
$Targets = @("install")
19041897
$InstallPath = "$($Arch.XCTestInstallRoot)\usr"
19051898
}
19061899

@@ -1928,7 +1921,6 @@ function Build-Testing([Platform]$Platform, $Arch, [switch]$Test = $false) {
19281921
# TODO: Test
19291922
return
19301923
} else {
1931-
$Targets = @("default")
19321924
$InstallPath = "$($Arch.SwiftTestingInstallRoot)\usr"
19331925
}
19341926

@@ -1939,7 +1931,6 @@ function Build-Testing([Platform]$Platform, $Arch, [switch]$Test = $false) {
19391931
-Arch $Arch `
19401932
-Platform $Platform `
19411933
-UseBuiltCompilers C,CXX,Swift `
1942-
-BuildTargets $Targets `
19431934
-Defines (@{
19441935
BUILD_SHARED_LIBS = "YES";
19451936
CMAKE_BUILD_WITH_INSTALL_RPATH = "YES";
@@ -2038,7 +2029,6 @@ function Build-SQLite($Arch) {
20382029
-InstallTo $LibraryRoot\sqlite-3.46.0\usr `
20392030
-Arch $Arch `
20402031
-UseMSVCCompilers C `
2041-
-BuildTargets default `
20422032
-Defines @{
20432033
BUILD_SHARED_LIBS = "NO";
20442034
}
@@ -2053,7 +2043,6 @@ function Build-System($Arch) {
20532043
-Platform Windows `
20542044
-UseBuiltCompilers C,Swift `
20552045
-SwiftSDK (Get-HostSwiftSDK) `
2056-
-BuildTargets default `
20572046
-Defines @{
20582047
BUILD_SHARED_LIBS = "YES";
20592048
}
@@ -2073,7 +2062,6 @@ function Build-ToolsSupportCore($Arch) {
20732062
-Platform Windows `
20742063
-UseBuiltCompilers C,Swift `
20752064
-SwiftSDK (Get-HostSwiftSDK) `
2076-
-BuildTargets default `
20772065
-Defines @{
20782066
BUILD_SHARED_LIBS = "YES";
20792067
SwiftSystem_DIR = (Get-HostProjectCMakeModules System);
@@ -2099,7 +2087,7 @@ function Build-LLBuild($Arch, [switch]$Test = $false) {
20992087
$env:CLANG = ([IO.Path]::Combine((Get-HostProjectBinaryCache Compilers), "bin", "clang.exe"))
21002088
$InstallPath = ""
21012089
} else {
2102-
$Targets = @("default")
2090+
$Targets = @()
21032091
$TestingDefines = @{}
21042092
$InstallPath = "$($Arch.ToolchainInstallRoot)\usr"
21052093
}
@@ -2147,7 +2135,6 @@ function Build-ArgumentParser($Arch) {
21472135
-Platform Windows `
21482136
-UseBuiltCompilers Swift `
21492137
-SwiftSDK (Get-HostSwiftSDK) `
2150-
-BuildTargets default `
21512138
-Defines @{
21522139
BUILD_SHARED_LIBS = "YES";
21532140
BUILD_TESTING = "NO";
@@ -2163,7 +2150,6 @@ function Build-Driver($Arch) {
21632150
-Platform Windows `
21642151
-UseBuiltCompilers C,CXX,Swift `
21652152
-SwiftSDK (Get-HostSwiftSDK) `
2166-
-BuildTargets default `
21672153
-Defines @{
21682154
BUILD_SHARED_LIBS = "YES";
21692155
SwiftSystem_DIR = (Get-HostProjectCMakeModules System);
@@ -2203,7 +2189,6 @@ function Build-Collections($Arch) {
22032189
-Platform Windows `
22042190
-UseBuiltCompilers C,Swift `
22052191
-SwiftSDK (Get-HostSwiftSDK) `
2206-
-BuildTargets default `
22072192
-Defines @{
22082193
BUILD_SHARED_LIBS = "YES";
22092194
}
@@ -2253,7 +2238,6 @@ function Build-PackageManager($Arch) {
22532238
-Platform Windows `
22542239
-UseBuiltCompilers C,Swift `
22552240
-SwiftSDK (Get-HostSwiftSDK) `
2256-
-BuildTargets default `
22572241
-Defines @{
22582242
BUILD_SHARED_LIBS = "YES";
22592243
CMAKE_Swift_FLAGS = @("-DCRYPTO_v2");
@@ -2281,7 +2265,6 @@ function Build-Markdown($Arch) {
22812265
-Platform Windows `
22822266
-UseBuiltCompilers C,Swift `
22832267
-SwiftSDK (Get-HostSwiftSDK) `
2284-
-BuildTargets default `
22852268
-Defines @{
22862269
BUILD_SHARED_LIBS = "NO";
22872270
ArgumentParser_DIR = (Get-HostProjectCMakeModules ArgumentParser);
@@ -2299,7 +2282,6 @@ function Build-Format($Arch) {
22992282
-UseMSVCCompilers C `
23002283
-UseBuiltCompilers Swift `
23012284
-SwiftSDK (Get-HostSwiftSDK) `
2302-
-BuildTargets default `
23032285
-Defines @{
23042286
BUILD_SHARED_LIBS = "YES";
23052287
ArgumentParser_DIR = (Get-HostProjectCMakeModules ArgumentParser);
@@ -2336,7 +2318,6 @@ function Build-SourceKitLSP($Arch) {
23362318
-Platform Windows `
23372319
-UseBuiltCompilers C,Swift `
23382320
-SwiftSDK (Get-HostSwiftSDK) `
2339-
-BuildTargets default `
23402321
-Defines @{
23412322
SwiftSyntax_DIR = (Get-HostProjectCMakeModules Compilers);
23422323
SwiftSystem_DIR = (Get-HostProjectCMakeModules System);
@@ -2379,8 +2360,10 @@ function Build-TestingMacros() {
23792360
}
23802361

23812362
$InstallDir = $null
2363+
$Targets = @("default")
23822364
if (-not $Build) {
23832365
$InstallDir = "$($Arch.ToolchainInstallRoot)\usr"
2366+
$Targets = @()
23842367
}
23852368

23862369
$SwiftSyntaxCMakeModules = if ($Build -and $HostArch -ne $BuildArch) {
@@ -2397,7 +2380,7 @@ function Build-TestingMacros() {
23972380
-Platform $Platform `
23982381
-UseBuiltCompilers Swift `
23992382
-SwiftSDK:$SwiftSDK `
2400-
-BuildTargets $Targets `
2383+
-BuildTargets:$Targets `
24012384
-Defines @{
24022385
SwiftSyntax_DIR = $SwiftSyntaxCMakeModules;
24032386
}

0 commit comments

Comments
 (0)