|
11 | 11 | //===----------------------------------------------------------------------===// |
12 | 12 | import Foundation |
13 | 13 | import TSCBasic |
14 | | -import SwiftOptions |
15 | 14 |
|
16 | 15 | extension Driver { |
17 | 16 | /// Precompute the dependencies for a given Swift compilation, producing a |
18 | | - /// dependency graph including all Swift and C module files and |
| 17 | + /// complete dependency graph including all Swift and C module files and |
19 | 18 | /// source files. |
20 | 19 | mutating func dependencyScanningJob() throws -> Job { |
21 | 20 | var inputs: [TypedVirtualPath] = [] |
@@ -74,66 +73,4 @@ extension Driver { |
74 | 73 | try fileSystem.writeFileContents(placeholderMapFilePath, bytes: ByteString(contents)) |
75 | 74 | return placeholderMapFilePath |
76 | 75 | } |
77 | | - |
78 | | - /// Compute the dependencies for a given Clang module, by invoking the Clang dependency scanning action |
79 | | - /// with the given module's name and a set of arguments (including the target version) |
80 | | - mutating func clangDependencyScanningJob(moduleId: ModuleDependencyId, |
81 | | - pcmArgs: [String]) throws -> Job { |
82 | | - var inputs: [TypedVirtualPath] = [] |
83 | | - |
84 | | - // Aggregate the fast dependency scanner arguments |
85 | | - var commandLine: [Job.ArgTemplate] = swiftCompilerPrefixArgs.map { Job.ArgTemplate.flag($0) } |
86 | | - commandLine.appendFlag("-frontend") |
87 | | - commandLine.appendFlag("-scan-clang-dependencies") |
88 | | - |
89 | | - try addCommonFrontendOptions(commandLine: &commandLine, inputs: &inputs, |
90 | | - bridgingHeaderHandling: .precompiled, |
91 | | - moduleDependencyGraphUse: .dependencyScan) |
92 | | - |
93 | | - // Ensure the `-target` option is inherited from the dependent Swift module's PCM args |
94 | | - if let targetOptionIndex = pcmArgs.firstIndex(of: Option.target.spelling) { |
95 | | - // PCM args are formulated as Clang command line options specified with: |
96 | | - // -Xcc <option> -Xcc <option_value> |
97 | | - assert(pcmArgs.count > targetOptionIndex + 1 && pcmArgs[targetOptionIndex + 1] == "-Xcc") |
98 | | - let pcmArgTriple = Triple(pcmArgs[targetOptionIndex + 2]) |
99 | | - // Override the invocation's default target argument by appending the one extracted from |
100 | | - // the pcmArgs |
101 | | - commandLine.appendFlag(.target) |
102 | | - commandLine.appendFlag(pcmArgTriple.triple) |
103 | | - } |
104 | | - |
105 | | - // Add the PCM args specific to this scan |
106 | | - pcmArgs.forEach { commandLine.appendFlags($0) } |
107 | | - |
108 | | - // This action does not require any input files, but all frontend actions require |
109 | | - // at least one input so pick any input of the current compilation. |
110 | | - let inputFile = inputFiles.first { $0.type == .swift } |
111 | | - commandLine.appendPath(inputFile!.file) |
112 | | - inputs.append(inputFile!) |
113 | | - |
114 | | - commandLine.appendFlags("-module-name", moduleId.moduleName) |
115 | | - // Construct the scanning job. |
116 | | - return Job(moduleName: moduleOutputInfo.name, |
117 | | - kind: .scanClangDependencies, |
118 | | - tool: VirtualPath.absolute(try toolchain.getToolPath(.swiftCompiler)), |
119 | | - commandLine: commandLine, |
120 | | - displayInputs: inputs, |
121 | | - inputs: inputs, |
122 | | - outputs: [TypedVirtualPath(file: .standardOutput, type: .jsonDependencies)], |
123 | | - supportsResponseFiles: true) |
124 | | - } |
125 | | - |
126 | | - mutating func scanClangModule(moduleId: ModuleDependencyId, pcmArgs: [String]) |
127 | | - throws -> InterModuleDependencyGraph { |
128 | | - let clangDependencyScannerJob = try clangDependencyScanningJob(moduleId: moduleId, |
129 | | - pcmArgs: pcmArgs) |
130 | | - let forceResponseFiles = parsedOptions.hasArgument(.driverForceResponseFiles) |
131 | | - |
132 | | - let dependencyGraph = |
133 | | - try self.executor.execute(job: clangDependencyScannerJob, |
134 | | - capturingJSONOutputAs: InterModuleDependencyGraph.self, |
135 | | - forceResponseFiles: forceResponseFiles, |
136 | | - recordedInputModificationDates: recordedInputModificationDates) |
137 | | - return dependencyGraph |
138 | | - } |
139 | 76 | } |
0 commit comments