Skip to content

Commit 57f6af6

Browse files
authored
util: Validate validatable params in build.ps1. (#79276)
* util: Validate validatable params in build.ps1. * PR Feedback. * Remove ValidateSet() for string[] values; it breaks when routed through build.cmd.
1 parent aa0833b commit 57f6af6

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

utils/build.ps1

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,26 +113,41 @@ param(
113113
[string] $SourceCache = "S:\SourceCache",
114114
[string] $BinaryCache = "S:\b",
115115
[string] $ImageRoot = "S:",
116+
[ValidateSet("codeview", "dwarf")]
116117
[string] $CDebugFormat = "dwarf",
118+
[ValidateSet("codeview", "dwarf")]
117119
[string] $SwiftDebugFormat = "dwarf",
118-
[string] $AndroidAPILevel = 28,
120+
[ValidateRange(1, 36)]
121+
[int] $AndroidAPILevel = 28,
119122
[string[]] $AndroidSDKs = @(),
120123
[string[]] $WindowsSDKs = @("X64","X86","Arm64"),
121124
[string] $ProductVersion = "0.0.0",
122125
[string] $ToolchainIdentifier = $(if (${env:TOOLCHAIN_VERSION}) { "${env:TOOLCHAIN_VERSION}" } else { "${env:USERNAME}.development" }),
123126
[string] $PinnedBuild = "",
127+
[ValidatePattern("^[A-Fa-f0-9]{64}$")]
124128
[string] $PinnedSHA256 = "",
125129
[string] $PinnedVersion = "",
126130
[string] $PythonVersion = "3.9.10",
131+
[ValidatePattern("^r(?:[1-9]|[1-9][0-9])(?:[a-z])?$")]
127132
[string] $AndroidNDKVersion = "r26b",
133+
[ValidatePattern("^\d+\.\d+\.\d+(?:-\w+)?")]
128134
[string] $WinSDKVersion = "",
129135
[switch] $Android = $false,
130136
[switch] $SkipBuild = $false,
131137
[switch] $SkipPackaging = $false,
132138
[switch] $IncludeDS2 = $false,
133139
[string[]] $Test = @(),
134140
[string] $Stage = "",
141+
[ValidateSet("ArgumentParser", "ASN1", "BuildTools", "Certificates", "CMark",
142+
"Collections", "Compilers", "Crypto", "CURL", "Dispatch", "DocC", "Driver",
143+
"DS2", "ExperimentalRuntime", "Format", "Foundation", "FoundationMacros",
144+
"IndexStoreDB", "Inspect", "Installer", "LLBuild", "LLVM", "LMDB",
145+
"Markdown", "mimalloc", "PackageManager", "PlatformInfoPlist", "RegsGen2",
146+
"Runtime", "Sanitizers", "SDKSettingsPlist", "SourceKitLSP", "SQLite",
147+
"System", "Testing", "TestingMacros", "ToolsSupportCore", "XCTest", "XML2",
148+
"ZLib")]
135149
[string] $BuildTo = "",
150+
[ValidateSet("AMD64", "ARM64")]
136151
[string] $HostArchName = $(if ($env:PROCESSOR_ARCHITEW6432 -ne $null) { "$env:PROCESSOR_ARCHITEW6432" } else { "$env:PROCESSOR_ARCHITECTURE" }),
137152
[switch] $Clean,
138153
[switch] $DebugInfo,

0 commit comments

Comments
 (0)