Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 49 additions & 37 deletions utils/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,15 @@ param
[string] $AndroidNDKVersion = "r27c",
[ValidateRange(1, 36)]
[int] $AndroidAPILevel = 28,
[string] $AndroidSDKDefault = "Android",
[string[]] $AndroidSDKVersions = @("Android", "AndroidExperimental"),
[string[]] $AndroidSDKArchitectures = @("aarch64", "armv7", "i686", "x86_64"),

# Windows SDK Options
[switch] $Windows = $true,
[ValidatePattern("^\d+\.\d+\.\d+(?:-\w+)?")]
[string] $WinSDKVersion = "",
[string] $WindowsSDKDefault = "Windows",
[string[]] $WindowsSDKVersions = @("Windows", "WindowsExperimental"),
[string[]] $WindowsSDKArchitectures = @("X64","X86","Arm64"),

Expand Down Expand Up @@ -291,6 +293,7 @@ $KnownPlatforms = @{
};
BinaryDir = "bin64a";
Cache = @{};
DefaultSDK = $WindowsSDKDefault;
};

WindowsX64 = @{
Expand All @@ -304,6 +307,7 @@ $KnownPlatforms = @{
};
BinaryDir = "bin64";
Cache = @{};
DefaultSDK = $WindowsSDKDefault;
};

WindowsX86 = @{
Expand All @@ -317,6 +321,7 @@ $KnownPlatforms = @{
};
BinaryDir = "bin32";
Cache = @{};
DefaultSDK = $WindowsSDKDefault;
};

AndroidARMv7 = @{
Expand All @@ -330,6 +335,7 @@ $KnownPlatforms = @{
};
BinaryDir = "bin32a";
Cache = @{};
DefaultSDK = $AndroidSDKDefault;
};

AndroidARM64 = @{
Expand All @@ -343,6 +349,7 @@ $KnownPlatforms = @{
};
BinaryDir = "bin64a";
Cache = @{};
DefaultSDK = $AndroidSDKDefault;
};

AndroidX86 = @{
Expand All @@ -356,6 +363,7 @@ $KnownPlatforms = @{
};
BinaryDir = "bin32";
Cache = @{};
DefaultSDK = $AndroidSDKDefault;
};

AndroidX64 = @{
Expand All @@ -369,6 +377,7 @@ $KnownPlatforms = @{
};
BinaryDir = "bin64";
Cache = @{};
DefaultSDK = $AndroidSDKDefault;
};
}

Expand Down Expand Up @@ -1865,8 +1874,13 @@ function Build-SPMProject {
$Stopwatch = [Diagnostics.Stopwatch]::StartNew()

Invoke-IsolatingEnvVars {
$RuntimeInstallRoot = [IO.Path]::Combine((Get-InstallDir $BuildPlatform), "Runtimes", $ProductVersion)
$RuntimeInstallRoot = if ($BuildPlatform.DefaultSDK -match "Experimental") {
[IO.Path]::Combine((Get-InstallDir $Build), "Runtimes", "$ProductVersion.experimental");
} else {
[IO.Path]::Combine((Get-InstallDir $Build), "Runtimes", "$ProductVersion");
}

Write-Host "Path = $RuntimeInstallRoot\usr\bin;$($BuildPlatform.ToolchainInstallRoot)\usr\bin;${env:Path}"
$env:Path = "$RuntimeInstallRoot\usr\bin;$($BuildPlatform.ToolchainInstallRoot)\usr\bin;${env:Path}"
$env:SDKROOT = (Get-SwiftSDK $Platform.OS)
$env:SWIFTCI_USE_LOCAL_DEPS = "1"
Expand Down Expand Up @@ -2988,7 +3002,7 @@ function Build-FoundationMacros([Hashtable] $Platform) {
-InstallTo "$($Platform.ToolchainInstallRoot)\usr" `
-Platform $Platform `
-UseBuiltCompilers Swift `
-SwiftSDK (Get-SwiftSDK $Platform.OS) `
-SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) `
-Defines @{
SwiftSyntax_DIR = $SwiftSyntaxDir;
}
Expand All @@ -3001,40 +3015,31 @@ function Build-XCTest([Hashtable] $Platform) {
-InstallTo "$([IO.Path]::Combine((Get-PlatformRoot $Platform.OS), "Developer", "Library", "XCTest-$ProductVersion", "usr"))" `
-Platform $Platform `
-UseBuiltCompilers Swift `
-SwiftSDK (Get-SwiftSDK $Platform.OS) `
-SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) `
-Defines @{
BUILD_SHARED_LIBS = "YES";
CMAKE_INSTALL_BINDIR = $Platform.BinaryDir;
ENABLE_TESTING = "NO";
dispatch_DIR = $(Get-ProjectCMakeModules $Platform Dispatch);
Foundation_DIR = $(Get-ProjectCMakeModules $Platform DynamicFoundation);
XCTest_INSTALL_NESTED_SUBDIR = "YES";
}
}

function Test-XCTest {
Invoke-IsolatingEnvVars {
$env:SDKROOT = Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK
$env:Path = "$(Get-ProjectBinaryCache $BuildPlatform XCTest);$(Get-ProjectBinaryCache $BuildPlatform DynamicFoundation)\bin;$(Get-ProjectBinaryCache $BuildPlatform Dispatch);$(Get-ProjectBinaryCache $BuildPlatform Runtime)\bin;${env:Path};$UnixToolsBinDir"

$RuntimeBinaryCache = Get-ProjectBinaryCache $BuildPlatform Runtime
$SwiftRuntimeDirectory = "${RuntimeBinaryCache}\lib\swift"

Build-CMakeProject `
-Src $SourceCache\swift-corelibs-xctest `
-Bin (Get-ProjectBinaryCache $BuildPlatform XCTest) `
-Platform $BuildPlatform `
-UseBuiltCompilers C,CXX,Swift `
-SwiftSDK $null `
-SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) `
-BuildTargets default,check-xctest `
-Defines @{
CMAKE_Swift_FLAGS = @("-resource-dir", $SwiftRuntimeDirectory, "-vfsoverlay", "${RuntimeBinaryCache}\stdlib\windows-vfs-overlay.yaml");
BUILD_SHARED_LIBS = "YES";
ENABLE_TESTING = "YES";
dispatch_DIR = $(Get-ProjectCMakeModules $BuildPlatform Dispatch);
Foundation_DIR = $(Get-ProjectCMakeModules $BuildPlatform DynamicFoundation);
LLVM_DIR = "$(Get-ProjectBinaryCache $BuildPlatform LLVM)\lib\cmake\llvm";
XCTEST_PATH_TO_FOUNDATION_BUILD = $(Get-ProjectBinaryCache $BuildPlatform DynamicFoundation);
XCTEST_PATH_TO_LIBDISPATCH_BUILD = $(Get-ProjectBinaryCache $BuildPlatform Dispatch);
XCTEST_PATH_TO_LIBDISPATCH_SOURCE = "$SourceCache\swift-corelibs-libdispatch";
LLVM_MAIN_SRC_DIR = "$SourceCache/llvm-project/llvm";
}
}
}
Expand Down Expand Up @@ -3111,8 +3116,7 @@ function Build-SDK([Hashtable] $Platform) {
Invoke-BuildStep Build-Runtime $Platform
Invoke-BuildStep Build-Dispatch $Platform
Invoke-BuildStep Build-Foundation $Platform
Invoke-BuildStep Build-CompilerRuntime $Platform
Invoke-BuildStep Build-XCTest $Platform

Invoke-BuildStep Build-Testing $Platform
}

Expand Down Expand Up @@ -3241,7 +3245,7 @@ function Build-System([Hashtable] $Platform) {
-Bin (Get-ProjectBinaryCache $Platform System) `
-Platform $Platform `
-UseBuiltCompilers C,Swift `
-SwiftSDK (Get-SwiftSDK $Platform.OS) `
-SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) `
-BuildTargets default `
-Defines @{
BUILD_SHARED_LIBS = "NO";
Expand All @@ -3255,7 +3259,7 @@ function Build-Subprocess([Hashtable] $Platform) {
-Bin (Get-ProjectBinaryCache $Platform Subprocess) `
-Platform $Platform `
-UseBuiltCompilers C,Swift `
-SwiftSDK (Get-SwiftSDK $Platform.OS) `
-SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) `
-Defines @{
BUILD_SHARED_LIBS = "NO";
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";
Expand All @@ -3273,7 +3277,7 @@ function Build-Build([Hashtable] $Platform) {
-InstallTo "$($Platform.ToolchainInstallRoot)\usr" `
-Platform $Platform `
-UseBuiltCompilers C,CXX,Swift `
-SwiftSDK (Get-SwiftSDK $Platform.OS) `
-SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) `
-Defines (@{
BUILD_SHARED_LIBS = "YES";
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";
Expand All @@ -3294,7 +3298,7 @@ function Build-ToolsSupportCore([Hashtable] $Platform) {
-InstallTo "$($Platform.ToolchainInstallRoot)\usr" `
-Platform $Platform `
-UseBuiltCompilers C,Swift `
-SwiftSDK (Get-SwiftSDK $Platform.OS) `
-SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) `
-Defines @{
BUILD_SHARED_LIBS = "YES";
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";
Expand All @@ -3313,7 +3317,7 @@ function Build-LLBuild([Hashtable] $Platform) {
-UseMSVCCompilers $(if ($UseHostToolchain) { @("CXX") } else { @("") }) `
-UsePinnedCompilers $(if ($UseHostToolchain) { @("") } else { @("CXX") }) `
-UseBuiltCompilers Swift `
-SwiftSDK (Get-SwiftSDK $Platform.OS) `
-SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) `
-Defines @{
BUILD_SHARED_LIBS = "YES";
LLBUILD_SUPPORT_BINDINGS = "Swift";
Expand Down Expand Up @@ -3341,7 +3345,7 @@ function Test-LLBuild {
-UseMSVCCompilers $(if ($UseHostToolchain) { @("CXX") } else { @("") }) `
-UsePinnedCompilers $(if ($UseHostToolchain) { @("") } else { @("CXX") }) `
-UseBuiltCompilers Swift `
-SwiftSDK (Get-SwiftSDK $BuildPlatform.OS) `
-SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) `
-BuildTargets default,test-llbuild `
-Defines = @{
BUILD_SHARED_LIBS = "YES";
Expand All @@ -3361,7 +3365,7 @@ function Build-ArgumentParser([Hashtable] $Platform) {
-InstallTo "$($Platform.ToolchainInstallRoot)\usr" `
-Platform $Platform `
-UseBuiltCompilers Swift `
-SwiftSDK (Get-SwiftSDK $Platform.OS) `
-SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) `
-Defines @{
BUILD_SHARED_LIBS = "YES";
BUILD_TESTING = "NO";
Expand All @@ -3376,7 +3380,7 @@ function Build-Driver([Hashtable] $Platform) {
-InstallTo "$($Platform.ToolchainInstallRoot)\usr" `
-Platform $Platform `
-UseBuiltCompilers C,CXX,Swift `
-SwiftSDK (Get-SwiftSDK $Platform.OS) `
-SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) `
-Defines @{
BUILD_SHARED_LIBS = "YES";
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";
Expand All @@ -3398,7 +3402,7 @@ function Build-Crypto([Hashtable] $Platform) {
-Bin (Get-ProjectBinaryCache $Platform Crypto) `
-Platform $Platform `
-UseBuiltCompilers ASM, C, CXX, Swift `
-SwiftSDK (Get-SwiftSDK $Platform.OS) `
-SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) `
-BuildTargets default `
-Defines @{
BUILD_SHARED_LIBS = "NO";
Expand All @@ -3414,7 +3418,7 @@ function Build-Collections([Hashtable] $Platform) {
-InstallTo "$($Platform.ToolchainInstallRoot)\usr" `
-Platform $Platform `
-UseBuiltCompilers C,Swift `
-SwiftSDK (Get-SwiftSDK $Platform.OS) `
-SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) `
-Defines @{
BUILD_SHARED_LIBS = "YES";
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";
Expand All @@ -3427,7 +3431,7 @@ function Build-ASN1([Hashtable] $Platform) {
-Bin (Get-ProjectBinaryCache $Platform ASN1) `
-Platform $Platform `
-UseBuiltCompilers Swift `
-SwiftSDK (Get-SwiftSDK $Platform.OS) `
-SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) `
-BuildTargets default `
-Defines @{
BUILD_SHARED_LIBS = "NO";
Expand All @@ -3441,7 +3445,7 @@ function Build-Certificates([Hashtable] $Platform) {
-Bin (Get-ProjectBinaryCache $Platform Certificates) `
-Platform $Platform `
-UseBuiltCompilers Swift `
-SwiftSDK (Get-SwiftSDK $Platform.OS) `
-SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) `
-BuildTargets default `
-Defines @{
BUILD_SHARED_LIBS = "NO";
Expand All @@ -3464,7 +3468,7 @@ function Build-PackageManager([Hashtable] $Platform) {
-InstallTo "$($Platform.ToolchainInstallRoot)\usr" `
-Platform $Platform `
-UseBuiltCompilers C,Swift `
-SwiftSDK (Get-SwiftSDK $Platform.OS) `
-SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) `
-Defines @{
BUILD_SHARED_LIBS = "YES";
CMAKE_Swift_FLAGS = @("-DCRYPTO_v2");
Expand Down Expand Up @@ -3492,7 +3496,7 @@ function Build-Markdown([Hashtable] $Platform) {
-InstallTo "$($Platform.ToolchainInstallRoot)\usr" `
-Platform $Platform `
-UseBuiltCompilers C,Swift `
-SwiftSDK (Get-SwiftSDK $Platform.OS) `
-SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) `
-Defines @{
BUILD_SHARED_LIBS = "NO";
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";
Expand All @@ -3510,7 +3514,7 @@ function Build-Format([Hashtable] $Platform) {
-UseMSVCCompilers $(if ($UseHostToolchain) { @("C") } else { @("") }) `
-UsePinnedCompilers $(if ($UseHostToolchain) { @("") } else { @("C") }) `
-UseBuiltCompilers Swift `
-SwiftSDK (Get-SwiftSDK $Platform.OS) `
-SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) `
-Defines @{
BUILD_SHARED_LIBS = "YES";
ArgumentParser_DIR = (Get-ProjectCMakeModules $Platform ArgumentParser);
Expand Down Expand Up @@ -3569,7 +3573,7 @@ function Build-LMDB([Hashtable] $Platform) {
}

function Build-IndexStoreDB([Hashtable] $Platform) {
$SDKROOT = Get-SwiftSDK $Platform.OS
$SDKROOT = Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK
Build-CMakeProject `
-Src $SourceCache\indexstore-db `
-Bin (Get-ProjectBinaryCache $Platform IndexStoreDB) `
Expand All @@ -3593,7 +3597,7 @@ function Build-SourceKitLSP([Hashtable] $Platform) {
-InstallTo "$($Platform.ToolchainInstallRoot)\usr" `
-Platform $Platform `
-UseBuiltCompilers C,Swift `
-SwiftSDK (Get-SwiftSDK $Platform.OS) `
-SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) `
-Defines @{
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";
SwiftSyntax_DIR = (Get-ProjectCMakeModules $Platform Compilers);
Expand Down Expand Up @@ -3705,7 +3709,7 @@ function Build-TestingMacros([Hashtable] $Platform) {
-InstallTo "$($Platform.ToolchainInstallRoot)\usr" `
-Platform $Platform `
-UseBuiltCompilers Swift `
-SwiftSDK (Get-SwiftSDK $Platform.OS) `
-SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) `
-Defines @{
SwiftSyntax_DIR = (Get-ProjectCMakeModules $Platform Compilers);
}
Expand Down Expand Up @@ -3749,7 +3753,7 @@ function Build-Inspect([Hashtable] $Platform) {
$InstallPath = "$(Get-PlatformRoot $Platform.OS)\Developer\Library\$(Get-ModuleTriple $Platform)"
}

$SDKROOT = Get-SwiftSDK $Platform.OS
$SDKROOT = Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK

Build-CMakeProject `
-Src $SourceCache\swift\tools\swift-inspect `
Expand Down Expand Up @@ -4009,6 +4013,10 @@ if (-not $SkipBuild) {
}
}

foreach ($Build in $WindowsSDKBuilds) {
Invoke-BuildStep Build-XCTest $Build
}

Write-PlatformInfoPlist Windows
}

Expand Down Expand Up @@ -4062,6 +4070,10 @@ if (-not $SkipBuild) {
}
}

foreach ($Build in $AndroidSDKBuilds) {
Invoke-BuildStep Build-XCTest $Build
}

Write-PlatformInfoPlist Android

# Android swift-inspect only supports 64-bit platforms.
Expand Down