Skip to content

Commit f2b080c

Browse files
authored
Merge pull request #1499 from owenv/owenv/prefix-map
Include WORKSPACE_DIR when configuring prefix mapping
2 parents e08bae6 + 45493aa commit f2b080c

5 files changed

Lines changed: 10 additions & 0 deletions

File tree

Sources/SWBTaskConstruction/TaskProducers/OtherTaskProducers/ModuleVerifierTaskProducer.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ final class ModuleVerifierTaskProducer: PhasedTaskProducer, TaskProducer {
320320
passthrough(BuiltinMacros.PROJECT_DIR)
321321
passthrough(BuiltinMacros.PROJECT_TEMP_DIR)
322322
passthrough(BuiltinMacros.BUILT_PRODUCTS_DIR)
323+
passthrough(BuiltinMacros.WORKSPACE_DIR)
323324

324325
// Module cache: with explicit modules we have a strict context hash that ensures correctness. For implicit modules create a separate cache for each target to prevent cache-correctness issues from leaking into validation. This matches the external modules-verifier tool, which always creates a separate cache.
325326
if scope.evaluate(BuiltinMacros.CLANG_ENABLE_EXPLICIT_MODULES) || scope.evaluate(BuiltinMacros._EXPERIMENTAL_CLANG_EXPLICIT_MODULES) {

Sources/SWBTaskConstruction/TaskProducers/WorkspaceTaskProducers/CompilationCachingConfigFileTaskProducer.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ final class CompilationCachingConfigFileTaskProducer: StandardTaskProducer, Task
118118
prefixMaps["/^src"] = scope.evaluate(BuiltinMacros.PROJECT_DIR).str
119119
prefixMaps["/^derived"] = scope.evaluate(BuiltinMacros.PROJECT_TEMP_DIR).str
120120
prefixMaps["/^built"] = scope.evaluate(BuiltinMacros.BUILT_PRODUCTS_DIR).str
121+
prefixMaps["/^workspace"] = scope.evaluate(BuiltinMacros.WORKSPACE_DIR)
121122
}
122123
prefixMaps.merge(extraMaps, uniquingKeysWith: { _, new in new })
123124

Sources/SWBUniversalPlatform/Specs/Clang.xcspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3362,6 +3362,7 @@
33623362
"-fdepscan-prefix-map=$(PROJECT_DIR)=/^src",
33633363
"-fdepscan-prefix-map=$(PROJECT_TEMP_DIR)=/^derived",
33643364
"-fdepscan-prefix-map=$(BUILT_PRODUCTS_DIR)=/^built",
3365+
"-fdepscan-prefix-map=$(WORKSPACE_DIR)=/^workspace",
33653366
);
33663367
NO = ();
33673368
};

Sources/SWBUniversalPlatform/Specs/Swift.xcspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,6 +1504,7 @@
15041504
"-scanner-prefix-map", "$(PROJECT_DIR)=/^src",
15051505
"-scanner-prefix-map", "$(PROJECT_TEMP_DIR)=/^derived",
15061506
"-scanner-prefix-map", "$(BUILT_PRODUCTS_DIR)=/^built",
1507+
"-scanner-prefix-map", "$(WORKSPACE_DIR)=/^workspace",
15071508
);
15081509
NO = ();
15091510
};

Tests/SWBCoreTests/CommandLineSpecTests.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1976,6 +1976,7 @@ import SWBMacro
19761976
let srcDir = try #require(core.specRegistry.internalMacroNamespace.lookupMacroDeclaration("PROJECT_DIR") as? PathMacroDeclaration)
19771977
let projectTmpDir = try #require(core.specRegistry.internalMacroNamespace.lookupMacroDeclaration("PROJECT_TEMP_DIR") as? PathMacroDeclaration)
19781978
let builtDir = try #require(core.specRegistry.internalMacroNamespace.lookupMacroDeclaration("BUILT_PRODUCTS_DIR") as? PathMacroDeclaration)
1979+
let workspaceDir = try #require(core.specRegistry.internalMacroNamespace.lookupMacroDeclaration("WORKSPACE_DIR") as? StringMacroDeclaration)
19791980

19801981
func test(caching: Bool, prefixMapping: Bool, completeMapping: Bool, extraMaps: [String], completion: ([String]) throws -> Void) async throws {
19811982
var table = MacroValueAssignmentTable(namespace: core.specRegistry.internalMacroNamespace)
@@ -1987,6 +1988,7 @@ import SWBMacro
19871988
table.push(srcDir, literal: "/source")
19881989
table.push(projectTmpDir, literal: "/build")
19891990
table.push(builtDir, literal: "/products")
1991+
table.push(workspaceDir, literal: "/workspace")
19901992
let mockScope = MacroEvaluationScope(table: table)
19911993
let producer = try MockCommandProducer(core: core, productTypeIdentifier: "com.apple.product-type.framework", platform: "macosx")
19921994
let delegate = try CapturingTaskGenerationDelegate(producer: producer, userPreferences: .defaultForTesting)
@@ -2021,6 +2023,7 @@ import SWBMacro
20212023
"-fdepscan-prefix-map=/source=/^src",
20222024
"-fdepscan-prefix-map=/build=/^derived",
20232025
"-fdepscan-prefix-map=/products=/^built",
2026+
"-fdepscan-prefix-map=/workspace=/^workspace",
20242027
])
20252028
})
20262029
try await test(caching: true, prefixMapping: true, completeMapping: false, extraMaps: ["/a=/b", "/c=/d"], completion: { args in
@@ -2048,6 +2051,7 @@ import SWBMacro
20482051
let srcDir = try #require(core.specRegistry.internalMacroNamespace.lookupMacroDeclaration("PROJECT_DIR") as? PathMacroDeclaration)
20492052
let projectTmpDir = try #require(core.specRegistry.internalMacroNamespace.lookupMacroDeclaration("PROJECT_TEMP_DIR") as? PathMacroDeclaration)
20502053
let builtDir = try #require(core.specRegistry.internalMacroNamespace.lookupMacroDeclaration("BUILT_PRODUCTS_DIR") as? PathMacroDeclaration)
2054+
let workspaceDir = try #require(core.specRegistry.internalMacroNamespace.lookupMacroDeclaration("WORKSPACE_DIR") as? StringMacroDeclaration)
20512055

20522056
func test(caching: Bool, prefixMapping: Bool, completeMapping: Bool, extraMaps: [String], completion: ([String]) throws -> Void) async throws {
20532057
// Create the mock table.
@@ -2072,6 +2076,7 @@ import SWBMacro
20722076
table.push(srcDir, literal: "/source")
20732077
table.push(projectTmpDir, literal: "/build")
20742078
table.push(builtDir, literal: "/products")
2079+
table.push(workspaceDir, literal: "/workspace")
20752080
let mockScope = MacroEvaluationScope(table: table)
20762081
let producer = try MockCommandProducer(core: core, productTypeIdentifier: "com.apple.product-type.framework", platform: "macosx")
20772082
let delegate = try CapturingTaskGenerationDelegate(producer: producer, userPreferences: .defaultForTesting)
@@ -2114,6 +2119,7 @@ import SWBMacro
21142119
"-scanner-prefix-map", "/source=/^src",
21152120
"-scanner-prefix-map", "/build=/^derived",
21162121
"-scanner-prefix-map", "/products=/^built",
2122+
"-scanner-prefix-map", "/workspace=/^workspace",
21172123
])
21182124
})
21192125
try await test(caching: true, prefixMapping: true, completeMapping: false, extraMaps: ["/a=/b", "/c=/d"], completion: { args in

0 commit comments

Comments
 (0)