Skip to content

Commit 6e881c1

Browse files
committed
Stop passing -resource-dir to the swift-frontend if the flag wasn't passed in on the command-line
The original C++ Driver works this way and this flag is being repurposed in the future. Make an exception for `-scan-dependencies` jobs because of a remaining issue with in-process scanning that needs to be tracked down.
1 parent fef4d97 commit 6e881c1

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift

+9-5
Original file line numberDiff line numberDiff line change
@@ -392,11 +392,15 @@ extension Driver {
392392
try addPathArgument(.absolute(workingDirectory), to: &commandLine, remap: jobNeedPathRemap)
393393
}
394394

395-
// Resource directory.
396-
try addPathOption(option: .resourceDir,
397-
path: VirtualPath.lookup(frontendTargetInfo.runtimeResourcePath.path),
398-
to: &commandLine,
399-
remap: jobNeedPathRemap)
395+
// Only pass in a resource directory to the frontend if one was passed to
396+
// swift-driver. Make an exception for scan-dependencies jobs for now till
397+
// we figure out a remaining problem with in-process scanning.
398+
if parsedOptions.hasArgument(.resourceDir) || kind == .scanDependencies {
399+
try addPathOption(option: .resourceDir,
400+
path: VirtualPath.lookup(frontendTargetInfo.runtimeResourcePath.path),
401+
to: &commandLine,
402+
remap: jobNeedPathRemap)
403+
}
400404

401405
if self.useStaticResourceDir {
402406
commandLine.appendFlag("-use-static-resource-dir")

Tests/SwiftDriverTests/SwiftDriverTests.swift

+2
Original file line numberDiff line numberDiff line change
@@ -860,8 +860,10 @@ final class SwiftDriverTests: XCTestCase {
860860
let plannedJobs = try driver1.planBuild().removingAutolinkExtractJobs()
861861
XCTAssertEqual(plannedJobs.count, 3)
862862
XCTAssertEqual(plannedJobs[0].outputs.count, 1)
863+
XCTAssert(!plannedJobs[0].commandLine.contains(.flag("-resource-dir")))
863864
XCTAssertTrue(matchTemporary(plannedJobs[0].outputs.first!.file, "foo.o"))
864865
XCTAssertEqual(plannedJobs[1].outputs.count, 1)
866+
XCTAssert(!plannedJobs[1].commandLine.contains(.flag("-resource-dir")))
865867
XCTAssertTrue(matchTemporary(plannedJobs[1].outputs.first!.file, "bar.o"))
866868
XCTAssertTrue(plannedJobs[2].tool.name.contains(executableName("clang")))
867869
XCTAssertEqual(plannedJobs[2].outputs.count, 1)

0 commit comments

Comments
 (0)