[Dependency Scanning] Add a field of source-imported dependencies

For the main source module, provide info on which dependencies are directly imported into the user program, explicitly ('import' statement) or implicitly (e.g. stdlib). Thist list does not include Swift overlay dependencies, cross-import dependencies, bridging header dependencies.
This commit is contained in:
Artem Chikin
2025-04-18 11:22:35 -07:00
parent 454e5ea98f
commit 7c5d8b24d3
12 changed files with 82 additions and 0 deletions

View File

@@ -424,6 +424,9 @@ void writeJSON(llvm::raw_ostream &out,
bool hasOverlayDependencies =
swiftTextualDeps->swift_overlay_module_dependencies &&
swiftTextualDeps->swift_overlay_module_dependencies->count > 0;
bool hasSourceImportedDependencies =
swiftTextualDeps->source_import_module_dependencies &&
swiftTextualDeps->source_import_module_dependencies->count > 0;
bool commaAfterBridgingHeaderPath = hasOverlayDependencies;
bool commaAfterFramework =
hasBridgingHeader || commaAfterBridgingHeaderPath;
@@ -448,6 +451,11 @@ void writeJSON(llvm::raw_ostream &out,
/*trailingComma=*/true);
writeMacroDependencies(out, swiftTextualDeps->macro_dependencies, 5,
/*trailingComma=*/true);
if (hasSourceImportedDependencies) {
writeDependencies(out, swiftTextualDeps->source_import_module_dependencies,
"sourceImportedDependencies", 5,
/*trailingComma=*/true);
}
writeJSONSingleField(out, "isFramework", swiftTextualDeps->is_framework,
5, commaAfterFramework);
/// Bridging header and its source file dependencies, if any.