Skip to content

Commit 2d89111

Browse files
authored
Merge pull request #84970 from hjyamauchi/buildps1cas
Add CAS support
2 parents 5eb4ab2 + 377057d commit 2d89111

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

utils/build.ps1

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@ param
158158
[ValidatePattern('^\d+(\.\d+)*$')]
159159
[string] $SCCacheVersion = "0.10.0",
160160

161+
# Build with CAS
162+
[switch] $EnableCAS = $false,
163+
[string] $CASPath = "$ImageRoot\cas",
164+
161165
# SBoM Support
162166
[switch] $IncludeSBoM = $false,
163167
[string] $SyftVersion = "1.29.1",
@@ -560,6 +564,10 @@ if (-not $PinnedBuild) {
560564

561565
$PinnedToolchain = [IO.Path]::GetFileNameWithoutExtension($PinnedBuild)
562566

567+
if ($EnableCAS -and ($UseHostToolchain -or ($PinnedVersion -ne "0.0.0"))) {
568+
throw "CAS currently requires using a main-branch pinned toolchain."
569+
}
570+
563571
$HostPlatform = switch ($HostArchName) {
564572
"AMD64" { $KnownPlatforms[$HostOS.ToString() + "X64"] }
565573
"ARM64" { $KnownPlatforms[$HostOS.ToString() + "ARM64"] }
@@ -1616,6 +1624,14 @@ function Build-CMakeProject {
16161624
@("/GS-", "/Gw", "/Gy", "/Oy", "/Oi", "/Zc:inline")
16171625
}
16181626

1627+
if ($EnableCAS -and $UsePinnedCompilers.Contains("C")) {
1628+
$CFLAGS += if ($UseGNUDriver) {
1629+
@("-fdepscan=inline", "-fdepscan-include-tree", "-Xclang", "-fcas-path", "-Xclang", $CASPath)
1630+
} else {
1631+
@("/clang:-fdepscan=inline", "/clang:-fdepscan-include-tree", "-Xclang", "-fcas-path", "-Xclang", $CASPath)
1632+
}
1633+
}
1634+
16191635
if ($DebugInfo) {
16201636
if ($UsePinnedCompilers.Contains("C") -or $UseBuiltCompilers.Contains("C")) {
16211637
if ($CDebugFormat -eq "dwarf") {
@@ -1656,6 +1672,14 @@ function Build-CMakeProject {
16561672
@("/GS-", "/Gw", "/Gy", "/Oy", "/Oi", "/Zc:inline", "/Zc:__cplusplus")
16571673
}
16581674

1675+
if ($EnableCAS -and $UsePinnedCompilers.Contains("CXX")) {
1676+
$CXXFLAGS += if ($UseGNUDriver) {
1677+
@("-fdepscan=inline", "-fdepscan-include-tree", "-Xclang", "-fcas-path", "-Xclang", $CASPath)
1678+
} else {
1679+
@("/clang:-fdepscan=inline", "/clang:-fdepscan-include-tree", "-Xclang", "-fcas-path", "-Xclang", $CASPath)
1680+
}
1681+
}
1682+
16591683
if ($DebugInfo) {
16601684
if ($UsePinnedCompilers.Contains("CXX") -or $UseBuiltCompilers.Contains("CXX")) {
16611685
if ($CDebugFormat -eq "dwarf") {
@@ -2203,6 +2227,12 @@ function Get-CompilersDefines([Hashtable] $Platform, [string] $Variant, [switch]
22032227
$SwiftFlags += @("-use-ld=lld");
22042228
}
22052229

2230+
$CMakeStaticLibPrefixSwiftDefine = if ((Get-PinnedToolchainVersion) -eq "0.0.0") {
2231+
@{ CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib"; }
2232+
} else {
2233+
@{}
2234+
}
2235+
22062236
return $TestDefines + $DebugDefines + @{
22072237
CLANG_TABLEGEN = (Join-Path -Path $BuildTools -ChildPath "clang-tblgen.exe");
22082238
CLANG_TIDY_CONFUSABLE_CHARS_GEN = (Join-Path -Path $BuildTools -ChildPath "clang-tidy-confusable-chars-gen.exe");
@@ -2254,7 +2284,7 @@ function Get-CompilersDefines([Hashtable] $Platform, [string] $Variant, [switch]
22542284
SWIFT_STDLIB_ASSERTIONS = "NO";
22552285
SWIFTSYNTAX_ENABLE_ASSERTIONS = "NO";
22562286
"cmark-gfm_DIR" = "$($Platform.ToolchainInstallRoot)\usr\lib\cmake";
2257-
}
2287+
} + $CMakeStaticLibPrefixSwiftDefine
22582288
}
22592289

22602290
function Build-Compilers([Hashtable] $Platform, [string] $Variant) {

0 commit comments

Comments
 (0)