Skip to content

Commit cba79ca

Browse files
authored
Merge pull request #811 from artemcm/NoResponseFilesForScanDeps
[Dependency Scanning] Do not support generating command-line response-files for dependency scanning jobs.
2 parents fbe2485 + fdd4891 commit cba79ca

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

Sources/SwiftDriver/ExplicitModuleBuilds/ModuleDependencyScanning.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public extension Driver {
2323
/// Precompute the dependencies for a given Swift compilation, producing a
2424
/// dependency graph including all Swift and C module files and
2525
/// source files.
26-
mutating private func dependencyScanningJob() throws -> Job {
26+
mutating func dependencyScanningJob() throws -> Job {
2727
let (inputs, commandLine) = try dependencyScannerInvocationCommand()
2828

2929
// Construct the scanning job.
@@ -35,7 +35,7 @@ public extension Driver {
3535
inputs: inputs,
3636
primaryInputs: [],
3737
outputs: [TypedVirtualPath(file: .standardOutput, type: .jsonDependencies)],
38-
supportsResponseFiles: true)
38+
supportsResponseFiles: false)
3939
}
4040

4141
/// Generate a full command-line invocation to be used for the dependency scanning action
@@ -239,7 +239,7 @@ public extension Driver {
239239
inputs: inputs,
240240
primaryInputs: [],
241241
outputs: [TypedVirtualPath(file: .standardOutput, type: .jsonDependencies)],
242-
supportsResponseFiles: true)
242+
supportsResponseFiles: false)
243243
}
244244

245245
/// Precompute the dependencies for a given collection of modules using swift frontend's batch scanning mode
@@ -288,7 +288,7 @@ public extension Driver {
288288
inputs: inputs,
289289
primaryInputs: [],
290290
outputs: outputs,
291-
supportsResponseFiles: true)
291+
supportsResponseFiles: false)
292292
}
293293

294294
/// Serialize a collection of modules into an input format expected by the batch module dependency scanner.

Tests/SwiftDriverTests/ExplicitModuleBuildTests.swift

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,31 @@ final class ExplicitModuleBuildTests: XCTestCase {
700700
}
701701
}
702702

703+
704+
/// Test that the scanner invocation does not rely in response files
705+
func testDependencyScanningNoResponse() throws {
706+
try withTemporaryDirectory { path in
707+
let main = path.appending(component: "testDependencyScanning.swift")
708+
// With a number of inputs this large, a response file should be generated
709+
// unless explicitly not supported, as should be the case for scan-deps.
710+
let lotsOfInputs = (0...700).map{"test\($0).swift"}
711+
let sdkArgumentsForTesting = (try? Driver.sdkArgumentsForTesting()) ?? []
712+
var driver = try Driver(args: ["swiftc",
713+
"-experimental-explicit-module-build",
714+
"-working-directory", path.pathString,
715+
main.pathString] + lotsOfInputs + sdkArgumentsForTesting,
716+
env: ProcessEnv.vars)
717+
let scannerJob = try driver.dependencyScanningJob()
718+
719+
let resolver = try ArgsResolver(fileSystem: localFileSystem)
720+
let (args, _) = try resolver.resolveArgumentList(for: scannerJob,
721+
forceResponseFiles: false,
722+
quotePaths: true)
723+
XCTAssertTrue(args.count > 1)
724+
XCTAssertFalse(args[0].hasSuffix(".resp"))
725+
}
726+
}
727+
703728
/// Test the libSwiftScan dependency scanning.
704729
func testDependencyScanning() throws {
705730
#if os(macOS) && arch(arm64)

0 commit comments

Comments
 (0)