Skip to content

Commit bdf106c

Browse files
authored
Merge pull request #735 from bob-wilson/bwilson/downgrade-dependency-errors
Add VALIDATE_DEPENDENCIES_DOWNGRADE_ERRORS build setting
2 parents e3d484f + cb904ed commit bdf106c

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

Sources/SWBCore/Dependencies.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,9 @@ public struct ModuleDependenciesContext: Sendable, SerializableCodable {
8888
public init?(settings: Settings) {
8989
let validate = settings.globalScope.evaluate(BuiltinMacros.VALIDATE_MODULE_DEPENDENCIES)
9090
guard validate != .no else { return nil }
91+
let downgrade = settings.globalScope.evaluate(BuiltinMacros.VALIDATE_DEPENDENCIES_DOWNGRADE_ERRORS)
9192
let fixItContext = ModuleDependenciesContext.FixItContext(settings: settings)
92-
self.init(validate: validate, moduleDependencies: settings.moduleDependencies, fixItContext: fixItContext)
93+
self.init(validate: downgrade ? .yes : validate, moduleDependencies: settings.moduleDependencies, fixItContext: fixItContext)
9394
}
9495

9596
/// Compute missing module dependencies.
@@ -269,8 +270,9 @@ public struct HeaderDependenciesContext: Sendable, SerializableCodable {
269270
public init?(settings: Settings) {
270271
let validate = settings.globalScope.evaluate(BuiltinMacros.VALIDATE_HEADER_DEPENDENCIES)
271272
guard validate != .no else { return nil }
273+
let downgrade = settings.globalScope.evaluate(BuiltinMacros.VALIDATE_DEPENDENCIES_DOWNGRADE_ERRORS)
272274
let fixItContext = HeaderDependenciesContext.FixItContext(settings: settings)
273-
self.init(validate: validate, headerDependencies: settings.headerDependencies, fixItContext: fixItContext)
275+
self.init(validate: downgrade ? .yes : validate, headerDependencies: settings.headerDependencies, fixItContext: fixItContext)
274276
}
275277

276278
/// Make diagnostics for missing header dependencies.

Sources/SWBCore/Settings/BuiltinMacros.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,6 +1145,7 @@ public final class BuiltinMacros {
11451145
public static let VALIDATE_PLIST_FILES_WHILE_COPYING = BuiltinMacros.declareBooleanMacro("VALIDATE_PLIST_FILES_WHILE_COPYING")
11461146
public static let VALIDATE_PRODUCT = BuiltinMacros.declareBooleanMacro("VALIDATE_PRODUCT")
11471147
public static let VALIDATE_DEPENDENCIES = BuiltinMacros.declareEnumMacro("VALIDATE_DEPENDENCIES") as EnumMacroDeclaration<BooleanWarningLevel>
1148+
public static let VALIDATE_DEPENDENCIES_DOWNGRADE_ERRORS = BuiltinMacros.declareBooleanMacro("VALIDATE_DEPENDENCIES_DOWNGRADE_ERRORS")
11481149
public static let VALIDATE_DEVELOPMENT_ASSET_PATHS = BuiltinMacros.declareEnumMacro("VALIDATE_DEVELOPMENT_ASSET_PATHS") as EnumMacroDeclaration<BooleanWarningLevel>
11491150
public static let VALIDATE_HEADER_DEPENDENCIES = BuiltinMacros.declareEnumMacro("VALIDATE_HEADER_DEPENDENCIES") as EnumMacroDeclaration<BooleanWarningLevel>
11501151
public static let VALIDATE_MODULE_DEPENDENCIES = BuiltinMacros.declareEnumMacro("VALIDATE_MODULE_DEPENDENCIES") as EnumMacroDeclaration<BooleanWarningLevel>
@@ -2375,6 +2376,7 @@ public final class BuiltinMacros {
23752376
VALIDATE_CAS_EXEC,
23762377
VALIDATE_PRODUCT,
23772378
VALIDATE_DEPENDENCIES,
2379+
VALIDATE_DEPENDENCIES_DOWNGRADE_ERRORS,
23782380
VALIDATE_DEVELOPMENT_ASSET_PATHS,
23792381
VALIDATE_HEADER_DEPENDENCIES,
23802382
VALIDATE_MODULE_DEPENDENCIES,

Tests/SWBBuildSystemTests/DependencyValidationTests.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -546,8 +546,8 @@ fileprivate struct DependencyValidationTests: CoreBasedTests {
546546
}
547547
}
548548

549-
@Test(.requireSDKs(.host), .requireClangFeatures(.printHeadersDirectPerFile), .skipHostOS(.windows, "toolchain too old"), .skipHostOS(.linux, "toolchain too old"))
550-
func validateModuleDependenciesMixedSource() async throws {
549+
@Test(.requireSDKs(.host), .requireClangFeatures(.printHeadersDirectPerFile), .skipHostOS(.windows, "toolchain too old"), .skipHostOS(.linux, "toolchain too old"), arguments: [false, true])
550+
func validateModuleDependenciesMixedSource(downgradeErrors: Bool) async throws {
551551
try await withTemporaryDirectory { tmpDir async throws -> Void in
552552
let testWorkspace = try await TestWorkspace(
553553
"Test",
@@ -573,6 +573,7 @@ fileprivate struct DependencyValidationTests: CoreBasedTests {
573573
"SWIFT_VERSION": swiftVersion,
574574
"GENERATE_INFOPLIST_FILE": "YES",
575575
"VALIDATE_MODULE_DEPENDENCIES": "YES_ERROR",
576+
"VALIDATE_DEPENDENCIES_DOWNGRADE_ERRORS": downgradeErrors ? "YES" : "NO",
576577
"SDKROOT": "$(HOST_PLATFORM)",
577578
"SUPPORTED_PLATFORMS": "$(HOST_PLATFORM)",
578579
"DSTROOT": tmpDir.join("dstroot").str,
@@ -615,7 +616,11 @@ fileprivate struct DependencyValidationTests: CoreBasedTests {
615616
}
616617

617618
try await tester.checkBuild(parameters: BuildParameters(configuration: "Debug"), runDestination: .host, persistent: true) { results in
618-
results.checkError(.contains("Missing entries in MODULE_DEPENDENCIES: Accelerate AppKit Foundation"))
619+
if downgradeErrors {
620+
results.checkWarning(.contains("Missing entries in MODULE_DEPENDENCIES: Accelerate AppKit Foundation"))
621+
} else {
622+
results.checkError(.contains("Missing entries in MODULE_DEPENDENCIES: Accelerate AppKit Foundation"))
623+
}
619624
}
620625
}
621626
}

0 commit comments

Comments
 (0)