mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Add new dependency kind (swiftExternal) to model external dependencies.
This commit is contained in:
@@ -221,10 +221,17 @@ namespace {
|
||||
const ModuleDependencyID &module,
|
||||
unsigned indentLevel) {
|
||||
out << "{\n";
|
||||
std::string moduleKind;
|
||||
if (module.second == ModuleDependenciesKind::Swift)
|
||||
moduleKind = "swift";
|
||||
else if (module.second == ModuleDependenciesKind::SwiftExternal)
|
||||
moduleKind = "swiftExternal";
|
||||
else
|
||||
moduleKind = "clang";
|
||||
|
||||
writeJSONSingleField(
|
||||
out,
|
||||
module.second == ModuleDependenciesKind::Swift ? "swift" : "clang",
|
||||
moduleKind,
|
||||
module.first,
|
||||
indentLevel + 1,
|
||||
/*trailingComma=*/false);
|
||||
@@ -317,27 +324,33 @@ static void writeJSON(llvm::raw_ostream &out,
|
||||
out.indent(2 * 2);
|
||||
out << "{\n";
|
||||
|
||||
auto externalSwiftDep = moduleDeps.getAsExternalDependencyModuleStub();
|
||||
auto swiftDeps = moduleDeps.getAsSwiftModule();
|
||||
auto clangDeps = moduleDeps.getAsClangModule();
|
||||
|
||||
// Module path.
|
||||
const char *modulePathSuffix =
|
||||
moduleDeps.isSwiftModule() ? ".swiftmodule" : ".pcm";
|
||||
std::string modulePath = module.first + modulePathSuffix;
|
||||
|
||||
std::string modulePath = externalSwiftDep
|
||||
? externalSwiftDep->compiledModulePath
|
||||
: module.first + modulePathSuffix;
|
||||
writeJSONSingleField(out, "modulePath", modulePath, /*indentLevel=*/3,
|
||||
/*trailingComma=*/true);
|
||||
|
||||
// Source files.
|
||||
auto swiftDeps = moduleDeps.getAsSwiftModule();
|
||||
auto clangDeps = moduleDeps.getAsClangModule();
|
||||
if (swiftDeps) {
|
||||
writeJSONSingleField(out, "sourceFiles", swiftDeps->sourceFiles, 3,
|
||||
/*trailingComma=*/true);
|
||||
} else {
|
||||
/*trailingComma=*/true);
|
||||
} else if (clangDeps) {
|
||||
writeJSONSingleField(out, "sourceFiles", clangDeps->fileDependencies, 3,
|
||||
/*trailingComma=*/true);
|
||||
}
|
||||
|
||||
// Direct dependencies.
|
||||
writeJSONSingleField(out, "directDependencies", directDependencies,
|
||||
3, /*trailingComma=*/true);
|
||||
if (swiftDeps || clangDeps)
|
||||
writeJSONSingleField(out, "directDependencies", directDependencies, 3,
|
||||
/*trailingComma=*/true);
|
||||
|
||||
// Swift and Clang-specific details.
|
||||
out.indent(3 * 2);
|
||||
@@ -358,6 +371,7 @@ static void writeJSON(llvm::raw_ostream &out,
|
||||
out.indent(5 * 2);
|
||||
out << "\"commandLine\": [\n";
|
||||
for (auto &arg :swiftDeps->buildCommandLine) {
|
||||
|
||||
out.indent(6 * 2);
|
||||
out << "\"" << arg << "\"";
|
||||
if (&arg != &swiftDeps->buildCommandLine.back())
|
||||
@@ -386,7 +400,7 @@ static void writeJSON(llvm::raw_ostream &out,
|
||||
if (!swiftDeps->extraPCMArgs.empty()) {
|
||||
out.indent(5 * 2);
|
||||
out << "\"extraPcmArgs\": [\n";
|
||||
for (auto &arg :swiftDeps->extraPCMArgs) {
|
||||
for (auto &arg : swiftDeps->extraPCMArgs) {
|
||||
out.indent(6 * 2);
|
||||
out << "\"" << arg << "\"";
|
||||
if (&arg != &swiftDeps->extraPCMArgs.back())
|
||||
@@ -400,11 +414,10 @@ static void writeJSON(llvm::raw_ostream &out,
|
||||
if (swiftDeps->bridgingHeaderFile) {
|
||||
out.indent(5 * 2);
|
||||
out << "\"bridgingHeader\": {\n";
|
||||
writeJSONSingleField(out, "path",
|
||||
*swiftDeps->bridgingHeaderFile, 6,
|
||||
writeJSONSingleField(out, "path", *swiftDeps->bridgingHeaderFile, 6,
|
||||
/*trailingComma=*/true);
|
||||
writeJSONSingleField(out, "sourceFiles",
|
||||
swiftDeps->bridgingSourceFiles, 6,
|
||||
writeJSONSingleField(out, "sourceFiles", swiftDeps->bridgingSourceFiles,
|
||||
6,
|
||||
/*trailingComma=*/true);
|
||||
writeJSONSingleField(out, "moduleDependencies",
|
||||
swiftDeps->bridgingModuleDependencies, 6,
|
||||
@@ -412,22 +425,35 @@ static void writeJSON(llvm::raw_ostream &out,
|
||||
out.indent(5 * 2);
|
||||
out << "}\n";
|
||||
}
|
||||
} else if (externalSwiftDep) {
|
||||
out << "\"swiftExternal\": {\n";
|
||||
|
||||
// Module doc file
|
||||
if (externalSwiftDep->moduleDocPath != "")
|
||||
writeJSONSingleField(out, "moduleDocPath",
|
||||
externalSwiftDep->moduleDocPath,
|
||||
/*indentLevel=*/5,
|
||||
/*trailingComma=*/true);
|
||||
|
||||
// Module Source Info file
|
||||
if (externalSwiftDep->moduleDocPath != "")
|
||||
writeJSONSingleField(out, "moduleSourceInfoPath",
|
||||
externalSwiftDep->sourceInfoPath,
|
||||
/*indentLevel=*/5,
|
||||
/*trailingComma=*/true);
|
||||
} else {
|
||||
out << "\"clang\": {\n";
|
||||
|
||||
// Module map file.
|
||||
writeJSONSingleField(out, "moduleMapPath",
|
||||
clangDeps->moduleMapFile, 5,
|
||||
writeJSONSingleField(out, "moduleMapPath", clangDeps->moduleMapFile, 5,
|
||||
/*trailingComma=*/true);
|
||||
|
||||
// Context hash.
|
||||
writeJSONSingleField(out, "contextHash",
|
||||
clangDeps->contextHash, 5,
|
||||
writeJSONSingleField(out, "contextHash", clangDeps->contextHash, 5,
|
||||
/*trailingComma=*/true);
|
||||
|
||||
// Command line.
|
||||
writeJSONSingleField(out, "commandLine",
|
||||
clangDeps->nonPathCommandLine, 5,
|
||||
writeJSONSingleField(out, "commandLine", clangDeps->nonPathCommandLine, 5,
|
||||
/*trailingComma=*/false);
|
||||
}
|
||||
|
||||
@@ -435,7 +461,6 @@ static void writeJSON(llvm::raw_ostream &out,
|
||||
out << "}\n";
|
||||
out.indent(3 * 2);
|
||||
out << "}\n";
|
||||
|
||||
out.indent(2 * 2);
|
||||
out << "}";
|
||||
|
||||
@@ -584,8 +609,7 @@ bool swift::scanDependencies(CompilerInstance &instance) {
|
||||
depTracker->addDependency(sourceFile, /*IsSystem=*/false);
|
||||
for (const auto &bridgingSourceFile : swiftDeps->bridgingSourceFiles)
|
||||
depTracker->addDependency(bridgingSourceFile, /*IsSystem=*/false);
|
||||
} else {
|
||||
auto clangDeps = deps->getAsClangModule();
|
||||
} else if (auto clangDeps = deps->getAsClangModule()) {
|
||||
if (!clangDeps->moduleMapFile.empty())
|
||||
depTracker->addDependency(clangDeps->moduleMapFile, /*IsSystem=*/false);
|
||||
for (const auto &sourceFile : clangDeps->fileDependencies)
|
||||
|
||||
Reference in New Issue
Block a user