diff --git a/Sources/SWBCore/SpecImplementations/Tools/SwiftCompiler.swift b/Sources/SWBCore/SpecImplementations/Tools/SwiftCompiler.swift index 09d8f08b..14d1030c 100644 --- a/Sources/SWBCore/SpecImplementations/Tools/SwiftCompiler.swift +++ b/Sources/SWBCore/SpecImplementations/Tools/SwiftCompiler.swift @@ -1495,8 +1495,11 @@ public final class SwiftCompilerSpec : CompilerSpec, SpecIdentifierType, SwiftDi let matchingBuildSetting = feature.buildSettings?.first(where: { if let macro = try? cbc.scope.namespace.declareBooleanMacro($0) { return cbc.scope.evaluate(macro) + } else if let macro = try? cbc.scope.namespace.declareStringMacro($0) { + return cbc.scope.evaluate(macro) == "YES" + } else { + return false } - return false }) if matchingBuildSetting != nil { continue diff --git a/Tests/SWBBuildSystemTests/SwiftDriverTests.swift b/Tests/SWBBuildSystemTests/SwiftDriverTests.swift index 7cc31253..cf368ea8 100644 --- a/Tests/SWBBuildSystemTests/SwiftDriverTests.swift +++ b/Tests/SWBBuildSystemTests/SwiftDriverTests.swift @@ -4944,6 +4944,45 @@ fileprivate struct SwiftDriverTests: CoreBasedTests { } } + //Reinit the core to invalidate all caching + tester = try await BuildOperationTester(getCore(), testWorkspace, simulated: false) + // Test with a setting which has a MIGRATE mode + do { + try await tester.fs.writeFileContents(blockListFilePath) { file in + file <<< + """ + { + "features": { + "MemberImportVisibility": { + "level": "warn", + "buildSettings": ["SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY"], + "learnMoreURL": "https://www.swift.org/swift-evolution/", + "moduleExceptions": [] + } + } + } + """ + } + + do { + let params = BuildParameters(configuration: "Debug") + try await tester.checkBuild(runDestination: .macOS, buildRequest: parameterizedBuildRequest(params)) { results in + results.checkWarning(.contains("Enabling the Swift language feature 'MemberImportVisibility' will become a requirement in the future; set 'SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES'")) + results.checkNoDiagnostics() + } + try await tester.checkBuild(runDestination: .macOS, buildRequest: cleanRequest) { results in results.checkNoErrors() } + } + + do { + let params = BuildParameters(configuration: "Debug", + commandLineOverrides: ["SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY": "YES"]) + try await tester.checkBuild(runDestination: .macOS, buildRequest: parameterizedBuildRequest(params)) { results in + results.checkNoDiagnostics() + } + try await tester.checkBuild(runDestination: .macOS, buildRequest: cleanRequest) { results in results.checkNoErrors() } + } + } + // Test with module exceptions specified in the block list. //Reinit the core to invalidate all caching tester = try await BuildOperationTester(getCore(), testWorkspace, simulated: false)