ModulesGraph
A collection of packages.
ModulesGraph.swift:76struct ModulesGraph
Citizens in PackageGraph
Type members
init(rootPackages: [ResolvedPackage], rootDependencies: [ResolvedPackage], packages: IdentifiableSet<ResolvedPackage>, dependencies: [PackageReference], binaryArtifacts: [PackageIdentity : [String : BinaryArtifact]]
) throws Construct a package graph directly.
static func load(root: PackageGraphRoot, identityResolver: IdentityResolver, additionalFileRules: [FileRuleDescription], externalManifests: OrderedCollections.OrderedDictionary<PackageIdentity, (manifest: Manifest, fs: FileSystem)>, requiredDependencies: [PackageReference], unsafeAllowedPackages: Set<PackageReference>, binaryArtifacts: [PackageIdentity : [String : BinaryArtifact]], shouldCreateMultipleTestProducts: Bool, createREPLProduct: Bool, customPlatformsRegistry: PlatformRegistry?, customXCTestMinimumDeploymentTargets: [PackageModel.Platform : PlatformVersion]?, testEntryPointPath: AbsolutePath?, fileSystem: FileSystem, observabilityScope: ObservabilityScope, productsFilter: ((Product) -> Bool)?, modulesFilter: ((Module) -> Bool)?
) throws -> ModulesGraph Load the package graph for the given package path.
Instance members
var allModules: IdentifiableSet<ResolvedModule>
Returns all the modules in the graph, regardless if they are reachable from the root modules or not.
var allModulesInTopologicalOrder: [ResolvedModule]
Returns all modules within the graph in topological order, starting with low-level modules (that have no dependencies).
var allProducts: IdentifiableSet<ResolvedProduct>
Returns all the products in the graph, regardless if they are reachable from the root modules or not.
let binaryArtifacts: [PackageIdentity : [String : BinaryArtifact]]
Any binary artifacts referenced by the graph.
let inputPackages: [ResolvedPackage]
All root and root dependency packages provided as input to the graph.
let packages: IdentifiableSet<ResolvedPackage>
The complete set of contained packages.
var reachableModules: IdentifiableSet<ResolvedModule>
The list of all modules reachable from root modules.
var reachableProducts: IdentifiableSet<ResolvedProduct>
The list of all products reachable from root modules.
let requiredDependencies: [PackageReference]
Package dependencies required for a fully resolved graph.
let rootPackages: IdentifiableSet<ResolvedPackage>
The root packages.
func directDependencies(for: ResolvedPackage
) -> [ResolvedPackage] Returns all of the packages that the given package depends on directly.
func isInRootPackages(ResolvedModule, satisfying: BuildEnvironment
) -> Bool Returns true if a given module is present in root packages and is not excluded for the given build environment.
func isRootPackage(ResolvedPackage
) -> Bool func module(for: String, destination: BuildTriple?
) -> ResolvedModule? Find a module given a name and an optional destination. If a destination is not specified this method uses
.destination
and falls back to.tools
for macros, plugins, and tests.func package(for: PackageIdentity
) -> ResolvedPackage? Returns the package based on the given identity, or nil if the package isn’t in the graph.
func package(for: ResolvedModule
) -> ResolvedPackage? Returns the package that contains the module, or nil if the module isn’t in the graph.
func package(for: ResolvedProduct
) -> ResolvedPackage? Returns the package that contains the product, or nil if the product isn’t in the graph.
func product(for: String, destination: BuildTriple?
) -> ResolvedProduct? Find a product given a name and an optional destination. If a destination is not specified this method uses
.destination
and falls back to.tools
for macros, plugins, and tests.
Show obsolete interfaces (3)
Hide obsolete interfaces
Show system interfaces (2)
Hide system interfaces
func computeTestModulesForExecutableModules(
) throws -> [ResolvedModule.ID : [ResolvedModule]] Computes a map from each executable module in any of the root packages to the corresponding test modules.
func computeTestTargetsForExecutableTargets(
) throws -> [ResolvedModule.ID : [ResolvedModule]]
Available in SPMBuildCore
Type members
static func computePluginGeneratedFiles(target: ResolvedModule, toolsVersion: ToolsVersion, additionalFileRules: [FileRuleDescription], buildParameters: BuildParameters, buildToolPluginInvocationResults: [BuildToolPluginInvocationResult], prebuildCommandResults: [PrebuildCommandResult], observabilityScope: ObservabilityScope
) -> (pluginDerivedSources: Sources, pluginDerivedResources: [Resource])
Instance members
func invokeBuildToolPlugins(outputDir: AbsolutePath, buildParameters: BuildParameters, additionalFileRules: [FileRuleDescription], toolSearchDirectories: [AbsolutePath], pkgConfigDirectories: [AbsolutePath], pluginScriptRunner: PluginScriptRunner, observabilityScope: ObservabilityScope, fileSystem: FileSystem, builtToolHandler: (_ name: String, _ path: RelativePath) throws -> AbsolutePath?
) throws -> [ResolvedModule.ID : (target: ResolvedModule, results: [BuildToolPluginInvocationResult])] Traverses the graph of reachable targets in a package graph, and applies plugins to targets as needed. Each plugin is passed an input context that provides information about the target to which it is being applied (along with some information about that target’s dependency closure). The plugin is expected to generate an output in the form of commands that will later be run before or during the build, and can also emit debug output and diagnostics.