Add re-export umbrella module generation with transitive import analysis
This commit is contained in:
parent
b32bc595ac
commit
2956b23b58
1 changed files with 26 additions and 0 deletions
|
|
@ -288,6 +288,32 @@ public struct CodeGenerator {
|
|||
return allOutputs
|
||||
}
|
||||
|
||||
/// Generates re-export umbrella Swift files for each module in the monorepo.
|
||||
///
|
||||
/// Each umbrella file (e.g., `"Sources/Gtk/Gtk.swift"`) contains
|
||||
/// `@_exported import` statements for all transitive dependencies,
|
||||
/// so that importing a higher-level module (e.g. `import Gtk`)
|
||||
/// exposes the full type lattice.
|
||||
///
|
||||
/// - Parameter analysis: The resolved multi-package analysis.
|
||||
/// - Returns: A dictionary mapping relative file paths (e.g.
|
||||
/// `"Sources/Gtk/Gtk.swift"`) to file content.
|
||||
public static func generateReexportUmbrellas(analysis: MultiPackageAnalysis) -> [String: String] {
|
||||
var umbrellas: [String: String] = [:]
|
||||
|
||||
for (moduleName, _) in analysis.repositories {
|
||||
let transitive = analysis.transitiveDependencies[moduleName] ?? []
|
||||
var content = "// Generated by SwiftGtkGen. DO NOT EDIT.\n\n"
|
||||
for dep in transitive.sorted() {
|
||||
content += "@_exported import \(dep)\n"
|
||||
}
|
||||
content += "\n"
|
||||
umbrellas["Sources/\(moduleName)/\(moduleName).swift"] = content
|
||||
}
|
||||
|
||||
return umbrellas
|
||||
}
|
||||
|
||||
/// Generates the standard file header for monorepo source files.
|
||||
private func fileHeader(moduleName: String, directImports: Set<String>) -> String {
|
||||
var imports = "import C\(moduleName)\nimport Foundation\n"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue