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
42 changes: 25 additions & 17 deletions utils/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ param
# Debug Information
[switch] $DebugInfo,
[ValidateSet("codeview", "dwarf")]
[string] $CDebugFormat = "dwarf",
[string] $CDebugFormat = "codeview",
[ValidateSet("codeview", "dwarf")]
[string] $SwiftDebugFormat = "dwarf",
[string] $SwiftDebugFormat = "codeview",

# Android SDK Options
[switch] $Android = $false,
Expand Down Expand Up @@ -244,10 +244,11 @@ if ($WindowsSDKArchitectures.Length -eq 1) { $WindowsSDKArchitectures = $Windows

if ($Test.Length -eq 1) { $Test = $Test[0].Split(",") }

if ($Test -contains "*") {
# Explicitly don't include llbuild yet since tests are known to fail on Windows
$Test = @("lld", "lldb", "swift", "dispatch", "foundation", "xctest", "swift-format", "sourcekit-lsp")
}
#if ($Test -contains "*") {
# # Explicitly don't include llbuild yet since tests are known to fail on Windows
# $Test = @("lld", "lldb", "swift", "dispatch", "foundation", "xctest", "swift-format", "sourcekit-lsp")
#}
$Test = @("foundation")

if ($UseHostToolchain -is [string]) {
$UseHostToolchain = [System.Convert]::ToBoolean($UseHostToolchain)
Expand Down Expand Up @@ -1369,6 +1370,7 @@ function Build-CMakeProject {
[switch] $AddAndroidCMakeEnv = $false,
[switch] $UseGNUDriver = $false,
[string] $SwiftSDK = $null,
[switch] $IncludeDebugInfo = $DebugInfo,
[hashtable] $Defines = @{}, # Values are either single strings or arrays of flags
[string[]] $BuildTargets = @()
)
Expand Down Expand Up @@ -1435,7 +1437,7 @@ function Build-CMakeProject {
Add-KeyValueIfNew $Defines CMAKE_ASM_FLAGS @("--target=$($Platform.Triple)")
Add-KeyValueIfNew $Defines CMAKE_ASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL "/MD"

if ($DebugInfo) {
if ($IncludeDebugInfo) {
$ASMDebugFlags = if ($CDebugFormat -eq "dwarf") {
if ($UseGNUDriver) { @("-gdwarf") } else { @("-clang:-gdwarf") }
} else {
Expand Down Expand Up @@ -1485,7 +1487,7 @@ function Build-CMakeProject {
@("/GS-", "/Gw", "/Gy", "/Oy", "/Oi", "/Zc:inline")
}

if ($DebugInfo) {
if ($IncludeDebugInfo) {
if ($UsePinnedCompilers.Contains("C") -or $UseBuiltCompilers.Contains("C")) {
if ($CDebugFormat -eq "dwarf") {
$CFLAGS += if ($UseGNUDriver) {
Expand Down Expand Up @@ -1525,7 +1527,7 @@ function Build-CMakeProject {
@("/GS-", "/Gw", "/Gy", "/Oy", "/Oi", "/Zc:inline", "/Zc:__cplusplus")
}

if ($DebugInfo) {
if ($IncludeDebugInfo) {
if ($UsePinnedCompilers.Contains("CXX") -or $UseBuiltCompilers.Contains("CXX")) {
if ($CDebugFormat -eq "dwarf") {
$CXXFLAGS += if ($UseGNUDriver) {
Expand Down Expand Up @@ -1565,7 +1567,7 @@ function Build-CMakeProject {
@()
}

$SwiftFlags += if ($DebugInfo) {
$SwiftFlags += if ($IncludeDebugInfo) {
if ($SwiftDebugFormat -eq "dwarf") {
@("-g", "-debug-info-format=dwarf", "-use-ld=lld-link", "-Xlinker", "/DEBUG:DWARF")
} else {
Expand All @@ -1592,7 +1594,7 @@ function Build-CMakeProject {
@("/INCREMENTAL:NO", "/OPT:REF", "/OPT:ICF")
}

if ($DebugInfo) {
if ($IncludeDebugInfo) {
if ($UseASM -or $UseC -or $UseCXX) {
# Prefer `/Z7` over `/ZI`
# By setting the debug information format, the appropriate C/C++
Expand Down Expand Up @@ -1629,7 +1631,7 @@ function Build-CMakeProject {
Add-KeyValueIfNew $Defines CMAKE_C_COMPILER_TARGET $Platform.Triple

$CFLAGS = @("--sysroot=${AndroidSysroot}", "-ffunction-sections", "-fdata-sections")
if ($DebugInfo) {
if ($IncludeDebugInfo) {
$CFLAGS += @("-gdwarf")
}
Add-FlagsDefine $Defines CMAKE_C_FLAGS $CFLAGS
Expand All @@ -1639,7 +1641,7 @@ function Build-CMakeProject {
Add-KeyValueIfNew $Defines CMAKE_CXX_COMPILER_TARGET $Platform.Triple

$CXXFLAGS = @("--sysroot=${AndroidSysroot}", "-ffunction-sections", "-fdata-sections")
if ($DebugInfo) {
if ($IncludeDebugInfo) {
$CXXFLAGS += @("-gdwarf")
}
Add-FlagsDefine $Defines CMAKE_CXX_FLAGS $CXXFLAGS
Expand Down Expand Up @@ -1678,7 +1680,7 @@ function Build-CMakeProject {
"-Xclang-linker", "-resource-dir", "-Xclang-linker", "${AndroidPrebuiltRoot}\lib\clang\$($(Get-AndroidNDK).ClangVersion)"
)

$SwiftFlags += if ($DebugInfo) { @("-g") } else { @("-gnone") }
$SwiftFlags += if ($IncludeDebugInfo) { @("-g") } else { @("-gnone") }

Add-FlagsDefine $Defines CMAKE_Swift_FLAGS $SwiftFlags
# Workaround CMake 3.26+ enabling `-wmo` by default on release builds
Expand Down Expand Up @@ -1861,10 +1863,11 @@ function Build-SPMProject {
}
Test {
$ActionName = "test"
$Arguments += @("-v")
}
TestParallel {
$ActionName = "test"
$Arguments += @("--parallel")
$Arguments += @("--parallel", "-v")
}
}

Expand Down Expand Up @@ -2938,8 +2941,10 @@ function Test-Foundation {
-Src $SourceCache\swift-foundation `
-Bin "$ScratchPath" `
-Platform $BuildPlatform `
-Configuration $FoundationTestConfiguration `
--multiroot-data-file "$SourceCache\swift\utils\build_swift\resources\SwiftPM-Unified-Build.xcworkspace" `
--test-product swift-foundationPackageTests
--test-product swift-foundationPackageTests `
-j 2

Invoke-IsolatingEnvVars {
$env:DISPATCH_INCLUDE_PATH="$(Get-SwiftSDK $BuildPlatform.OS)/usr/include"
Expand All @@ -2953,8 +2958,10 @@ function Test-Foundation {
-Src $SourceCache\swift-corelibs-foundation `
-Bin "$ScratchPath" `
-Platform $BuildPlatform `
-Configuration $FoundationTestConfiguration `
--multiroot-data-file "$SourceCache\swift\utils\build_swift\resources\SwiftPM-Unified-Build.xcworkspace" `
--test-product swift-corelibs-foundationPackageTests
--test-product swift-corelibs-foundationPackageTests `
-j 2
}
}

Expand Down Expand Up @@ -3366,6 +3373,7 @@ function Build-Driver([Hashtable] $Platform) {
-Platform $Platform `
-UseBuiltCompilers C,CXX,Swift `
-SwiftSDK (Get-SwiftSDK $Platform.OS) `
-IncludeDebugInfo `
-Defines @{
BUILD_SHARED_LIBS = "YES";
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";
Expand Down