1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
|
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift open source project
//
// Copyright (c) 2015-2023 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
import Basics
import struct PackageGraph.ResolvedModule
import struct PackageModel.Resource
import struct PackageModel.ToolsVersion
import struct SPMBuildCore.BuildToolPluginInvocationResult
import struct SPMBuildCore.BuildParameters
public enum BuildDescriptionError: Swift.Error {
case requestedFileNotPartOfTarget(targetName: String, requestedFilePath: AbsolutePath)
}
@available(*, deprecated, renamed: "ModuleBuildDescription")
public typealias TargetBuildDescription = ModuleBuildDescription
/// A module build description which can either be for a Swift or Clang module.
public enum ModuleBuildDescription {
/// Swift target description.
case swift(SwiftModuleBuildDescription)
/// Clang target description.
case clang(ClangModuleBuildDescription)
/// The objects in this target.
var objects: [AbsolutePath] {
get throws {
switch self {
case .swift(let module):
return try module.objects
case .clang(let module):
return try module.objects
}
}
}
/// The resources in this target.
var resources: [Resource] {
switch self {
case .swift(let buildDescription):
return buildDescription.resources
case .clang(let buildDescription):
return buildDescription.resources
}
}
/// Path to the bundle generated for this module (if any).
var bundlePath: AbsolutePath? {
switch self {
case .swift(let buildDescription):
return buildDescription.bundlePath
case .clang(let buildDescription):
return buildDescription.bundlePath
}
}
var target: ResolvedModule {
switch self {
case .swift(let buildDescription):
return buildDescription.target
case .clang(let buildDescription):
return buildDescription.target
}
}
/// Paths to the binary libraries the target depends on.
var libraryBinaryPaths: Set<AbsolutePath> {
switch self {
case .swift(let target):
return target.libraryBinaryPaths
case .clang(let target):
return target.libraryBinaryPaths
}
}
var resourceBundleInfoPlistPath: AbsolutePath? {
switch self {
case .swift(let buildDescription):
return buildDescription.resourceBundleInfoPlistPath
case .clang(let buildDescription):
return buildDescription.resourceBundleInfoPlistPath
}
}
var buildToolPluginInvocationResults: [BuildToolPluginInvocationResult] {
switch self {
case .swift(let buildDescription):
return buildDescription.buildToolPluginInvocationResults
case .clang(let buildDescription):
return buildDescription.buildToolPluginInvocationResults
}
}
var buildParameters: BuildParameters {
switch self {
case .swift(let buildDescription):
return buildDescription.buildParameters
case .clang(let buildDescription):
return buildDescription.buildParameters
}
}
var toolsVersion: ToolsVersion {
switch self {
case .swift(let buildDescription):
return buildDescription.toolsVersion
case .clang(let buildDescription):
return buildDescription.toolsVersion
}
}
/// Determines the arguments needed to run `swift-symbolgraph-extract` for
/// this module.
package func symbolGraphExtractArguments() throws -> [String] {
switch self {
case .swift(let buildDescription): try buildDescription.symbolGraphExtractArguments()
case .clang(let buildDescription): try buildDescription.symbolGraphExtractArguments()
}
}
}
|