Skip to content

Commit 5185c03

Browse files
authored
Hide more llbuild-specific APIs (#7387)
These APIs should not be marked `public` to prevent SwiftPM clients from adopting them by accident.
1 parent 99a65c0 commit 5185c03

19 files changed

+305
-305
lines changed

Sources/Build/BuildDescription/ClangTargetBuildDescription.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ import struct SPMBuildCore.PrebuildCommandResult
2222
import enum TSCBasic.ProcessEnv
2323

2424
/// Target description for a Clang target i.e. C language family target.
25-
public final class ClangTargetBuildDescription {
25+
package final class ClangTargetBuildDescription {
2626
/// The target described by this target.
27-
public let target: ResolvedTarget
27+
package let target: ResolvedTarget
2828

2929
/// The underlying clang target.
30-
public let clangTarget: ClangTarget
30+
package let clangTarget: ClangTarget
3131

3232
/// The tools version of the package that declared the target. This can
3333
/// can be used to conditionalize semantically significant changes in how
3434
/// a target is built.
35-
public let toolsVersion: ToolsVersion
35+
package let toolsVersion: ToolsVersion
3636

3737
/// The build parameters.
3838
let buildParameters: BuildParameters
@@ -43,7 +43,7 @@ public final class ClangTargetBuildDescription {
4343
}
4444

4545
/// The list of all resource files in the target, including the derived ones.
46-
public var resources: [Resource] {
46+
package var resources: [Resource] {
4747
self.target.underlying.resources + self.pluginDerivedResources
4848
}
4949

@@ -61,7 +61,7 @@ public final class ClangTargetBuildDescription {
6161
}
6262

6363
/// The modulemap file for this target, if any.
64-
public private(set) var moduleMap: AbsolutePath?
64+
package private(set) var moduleMap: AbsolutePath?
6565

6666
/// Path to the temporary directory for this target.
6767
var tempsPath: AbsolutePath
@@ -78,13 +78,13 @@ public final class ClangTargetBuildDescription {
7878
private var pluginDerivedResources: [Resource]
7979

8080
/// Path to the resource accessor header file, if generated.
81-
public private(set) var resourceAccessorHeaderFile: AbsolutePath?
81+
package private(set) var resourceAccessorHeaderFile: AbsolutePath?
8282

8383
/// Path to the resource Info.plist file, if generated.
84-
public private(set) var resourceBundleInfoPlistPath: AbsolutePath?
84+
package private(set) var resourceBundleInfoPlistPath: AbsolutePath?
8585

8686
/// The objects in this target.
87-
public var objects: [AbsolutePath] {
87+
package var objects: [AbsolutePath] {
8888
get throws {
8989
try compilePaths().map(\.object)
9090
}
@@ -100,12 +100,12 @@ public final class ClangTargetBuildDescription {
100100
private let fileSystem: FileSystem
101101

102102
/// If this target is a test target.
103-
public var isTestTarget: Bool {
103+
package var isTestTarget: Bool {
104104
target.type == .test
105105
}
106106

107107
/// The results of applying any build tool plugins to this target.
108-
public let buildToolPluginInvocationResults: [BuildToolPluginInvocationResult]
108+
package let buildToolPluginInvocationResults: [BuildToolPluginInvocationResult]
109109

110110
/// Create a new target description with target and build parameters.
111111
init(
@@ -182,7 +182,7 @@ public final class ClangTargetBuildDescription {
182182
}
183183

184184
/// An array of tuples containing filename, source, object and dependency path for each of the source in this target.
185-
public func compilePaths()
185+
package func compilePaths()
186186
throws -> [(filename: RelativePath, source: AbsolutePath, object: AbsolutePath, deps: AbsolutePath)]
187187
{
188188
let sources = [
@@ -206,7 +206,7 @@ public final class ClangTargetBuildDescription {
206206
/// NOTE: The parameter to specify whether to get C++ semantics is currently optional, but this is only for revlock
207207
/// avoidance with clients. Callers should always specify what they want based either the user's indication or on a
208208
/// default value (possibly based on the filename suffix).
209-
public func basicArguments(
209+
package func basicArguments(
210210
isCXX isCXXOverride: Bool? = .none,
211211
isC: Bool = false
212212
) throws -> [String] {
@@ -308,7 +308,7 @@ public final class ClangTargetBuildDescription {
308308
return args
309309
}
310310

311-
public func emitCommandLine(for filePath: AbsolutePath) throws -> [String] {
311+
package func emitCommandLine(for filePath: AbsolutePath) throws -> [String] {
312312
let standards = [
313313
(clangTarget.cxxLanguageStandard, SupportedLanguageExtension.cppExtensions),
314314
(clangTarget.cLanguageStandard, SupportedLanguageExtension.cExtensions),

Sources/Build/BuildDescription/PluginDescription.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,24 @@ import protocol Basics.FileSystem
2121
/// But because the package graph and build plan are not loaded for incremental
2222
/// builds, this information is included in the BuildDescription, and the plugin
2323
/// targets are compiled directly.
24-
public final class PluginDescription: Codable {
24+
package final class PluginDescription: Codable {
2525
/// The identity of the package in which the plugin is defined.
26-
public let package: PackageIdentity
26+
package let package: PackageIdentity
2727

2828
/// The name of the plugin target in that package (this is also the name of
2929
/// the plugin).
30-
public let targetName: String
30+
package let targetName: String
3131

3232
/// The names of any plugin products in that package that vend the plugin
3333
/// to other packages.
34-
public let productNames: [String]
34+
package let productNames: [String]
3535

3636
/// The tools version of the package that declared the target. This affects
3737
/// the API that is available in the PackagePlugin module.
38-
public let toolsVersion: ToolsVersion
38+
package let toolsVersion: ToolsVersion
3939

4040
/// Swift source files that comprise the plugin.
41-
public let sources: Sources
41+
package let sources: Sources
4242

4343
/// Initialize a new plugin target description. The target is expected to be
4444
/// a `PluginTarget`.

Sources/Build/BuildDescription/ProductBuildDescription.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,25 @@ import SPMBuildCore
2121
import struct TSCBasic.SortedArray
2222

2323
/// The build description for a product.
24-
public final class ProductBuildDescription: SPMBuildCore.ProductBuildDescription {
24+
package final class ProductBuildDescription: SPMBuildCore.ProductBuildDescription {
2525
/// The reference to the product.
26-
public let package: ResolvedPackage
26+
package let package: ResolvedPackage
2727

2828
/// The reference to the product.
29-
public let product: ResolvedProduct
29+
package let product: ResolvedProduct
3030

3131
/// The tools version of the package that declared the product. This can
3232
/// can be used to conditionalize semantically significant changes in how
3333
/// a target is built.
34-
public let toolsVersion: ToolsVersion
34+
package let toolsVersion: ToolsVersion
3535

3636
/// The build parameters.
37-
public let buildParameters: BuildParameters
37+
package let buildParameters: BuildParameters
3838

3939
/// All object files to link into this product.
4040
///
4141
// Computed during build planning.
42-
public internal(set) var objects = SortedArray<AbsolutePath>()
42+
package internal(set) var objects = SortedArray<AbsolutePath>()
4343

4444
/// The dynamic libraries this product needs to link with.
4545
// Computed during build planning.
@@ -128,7 +128,7 @@ public final class ProductBuildDescription: SPMBuildCore.ProductBuildDescription
128128
}
129129

130130
/// The arguments to the librarian to create a static library.
131-
public func archiveArguments() throws -> [String] {
131+
package func archiveArguments() throws -> [String] {
132132
let librarian = self.buildParameters.toolchain.librarianPath.pathString
133133
let triple = self.buildParameters.triple
134134
if triple.isWindows(), librarian.hasSuffix("link") || librarian.hasSuffix("link.exe") {
@@ -141,7 +141,7 @@ public final class ProductBuildDescription: SPMBuildCore.ProductBuildDescription
141141
}
142142

143143
/// The arguments to link and create this product.
144-
public func linkArguments() throws -> [String] {
144+
package func linkArguments() throws -> [String] {
145145
var args = [buildParameters.toolchain.swiftCompilerPath.pathString]
146146
args += self.buildParameters.sanitizers.linkSwiftFlags()
147147
args += self.additionalFlags
@@ -390,7 +390,7 @@ public final class ProductBuildDescription: SPMBuildCore.ProductBuildDescription
390390
}
391391

392392
extension SortedArray where Element == AbsolutePath {
393-
public static func +=<S: Sequence>(lhs: inout SortedArray, rhs: S) where S.Iterator.Element == AbsolutePath {
393+
package static func +=<S: Sequence>(lhs: inout SortedArray, rhs: S) where S.Iterator.Element == AbsolutePath {
394394
lhs.insert(contentsOf: rhs)
395395
}
396396
}

Sources/Build/BuildDescription/SwiftTargetBuildDescription.swift

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,19 @@ import DriverSupport
2828
import struct TSCBasic.ByteString
2929

3030
/// Target description for a Swift target.
31-
public final class SwiftTargetBuildDescription {
31+
package final class SwiftTargetBuildDescription {
3232
/// The package this target belongs to.
33-
public let package: ResolvedPackage
33+
package let package: ResolvedPackage
3434

3535
/// The target described by this target.
36-
public let target: ResolvedTarget
36+
package let target: ResolvedTarget
3737

3838
private let swiftTarget: SwiftTarget
3939

4040
/// The tools version of the package that declared the target. This can
4141
/// can be used to conditionalize semantically significant changes in how
4242
/// a target is built.
43-
public let toolsVersion: ToolsVersion
43+
package let toolsVersion: ToolsVersion
4444

4545
/// The build parameters.
4646
let buildParameters: BuildParameters
@@ -77,22 +77,22 @@ public final class SwiftTargetBuildDescription {
7777
}
7878

7979
/// The list of all source files in the target, including the derived ones.
80-
public var sources: [AbsolutePath] {
80+
package var sources: [AbsolutePath] {
8181
self.target.sources.paths + self.derivedSources.paths + self.pluginDerivedSources.paths
8282
}
8383

84-
public var sourcesFileListPath: AbsolutePath {
84+
package var sourcesFileListPath: AbsolutePath {
8585
self.tempsPath.appending(component: "sources")
8686
}
8787

8888
/// The list of all resource files in the target, including the derived ones.
89-
public var resources: [Resource] {
89+
package var resources: [Resource] {
9090
self.target.underlying.resources + self.pluginDerivedResources
9191
}
9292

9393
/// The objects in this target, containing either machine code or bitcode
9494
/// depending on the build parameters used.
95-
public var objects: [AbsolutePath] {
95+
package var objects: [AbsolutePath] {
9696
get throws {
9797
let relativeSources = self.target.sources.relativePaths
9898
+ self.derivedSources.relativePaths
@@ -112,7 +112,7 @@ public final class SwiftTargetBuildDescription {
112112
}
113113

114114
/// The path to the swiftmodule file after compilation.
115-
public var moduleOutputPath: AbsolutePath { // note: needs to be public because of sourcekit-lsp
115+
public var moduleOutputPath: AbsolutePath { // note: needs to be `public` because of sourcekit-lsp
116116
// If we're an executable and we're not allowing test targets to link against us, we hide the module.
117117
let triple = buildParameters.triple
118118
let allowLinkingAgainstExecutables = (triple.isDarwin() || triple.isLinux() || triple.isWindows()) && self.toolsVersion >= .v5_5
@@ -133,7 +133,7 @@ public final class SwiftTargetBuildDescription {
133133
}
134134

135135
/// Path to the resource Info.plist file, if generated.
136-
public private(set) var resourceBundleInfoPlistPath: AbsolutePath?
136+
package private(set) var resourceBundleInfoPlistPath: AbsolutePath?
137137

138138
/// Paths to the binary libraries the target depends on.
139139
var libraryBinaryPaths: Set<AbsolutePath> = []
@@ -148,7 +148,7 @@ public final class SwiftTargetBuildDescription {
148148

149149
/// Describes the purpose of a test target, including any special roles such as containing a list of discovered
150150
/// tests or serving as the manifest target which contains the main entry point.
151-
public enum TestTargetRole {
151+
package enum TestTargetRole {
152152
/// An ordinary test target, defined explicitly in a package, containing test code.
153153
case `default`
154154

@@ -163,10 +163,10 @@ public final class SwiftTargetBuildDescription {
163163
case entryPoint(isSynthesized: Bool)
164164
}
165165

166-
public let testTargetRole: TestTargetRole?
166+
package let testTargetRole: TestTargetRole?
167167

168168
/// If this target is a test target.
169-
public var isTestTarget: Bool {
169+
package var isTestTarget: Bool {
170170
self.testTargetRole != nil
171171
}
172172

@@ -228,13 +228,13 @@ public final class SwiftTargetBuildDescription {
228228
private(set) var moduleMap: AbsolutePath?
229229

230230
/// The results of applying any build tool plugins to this target.
231-
public let buildToolPluginInvocationResults: [BuildToolPluginInvocationResult]
231+
package let buildToolPluginInvocationResults: [BuildToolPluginInvocationResult]
232232

233233
/// The results of running any prebuild commands for this target.
234-
public let prebuildCommandResults: [PrebuildCommandResult]
234+
package let prebuildCommandResults: [PrebuildCommandResult]
235235

236236
/// Any macro products that this target requires to build.
237-
public let requiredMacroProducts: [ResolvedProduct]
237+
package let requiredMacroProducts: [ResolvedProduct]
238238

239239
/// ObservabilityScope with which to emit diagnostics
240240
private let observabilityScope: ObservabilityScope
@@ -474,7 +474,7 @@ public final class SwiftTargetBuildDescription {
474474
}
475475

476476
/// The arguments needed to compile this target.
477-
public func compileArguments() throws -> [String] {
477+
package func compileArguments() throws -> [String] {
478478
var args = [String]()
479479
args += try self.buildParameters.targetTripleArgs(for: self.target)
480480
args += ["-swift-version", self.swiftVersion.rawValue]
@@ -650,7 +650,7 @@ public final class SwiftTargetBuildDescription {
650650

651651
/// When `scanInvocation` argument is set to `true`, omit the side-effect producing arguments
652652
/// such as emitting a module or supplementary outputs.
653-
public func emitCommandLine(scanInvocation: Bool = false) throws -> [String] {
653+
package func emitCommandLine(scanInvocation: Bool = false) throws -> [String] {
654654
var result: [String] = []
655655
result.append(self.buildParameters.toolchain.swiftCompilerPath.pathString)
656656

Sources/Build/BuildDescription/TargetBuildDescription.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ import struct PackageModel.ToolsVersion
1717
import struct SPMBuildCore.BuildToolPluginInvocationResult
1818
import struct SPMBuildCore.BuildParameters
1919

20-
public enum BuildDescriptionError: Swift.Error {
20+
package enum BuildDescriptionError: Swift.Error {
2121
case requestedFileNotPartOfTarget(targetName: String, requestedFilePath: AbsolutePath)
2222
}
2323

2424
/// A target description which can either be for a Swift or Clang target.
25-
public enum TargetBuildDescription {
25+
package enum TargetBuildDescription {
2626
/// Swift target description.
2727
case swift(SwiftTargetBuildDescription)
2828

Sources/Build/BuildManifest/LLBuildManifestBuilder+Swift.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ extension LLBuildManifestBuilder {
188188
// dependency graph of B. The driver is then responsible for the necessary post-processing
189189
// to merge the dependency graphs and plan the build for A, using artifacts of B as explicit
190190
// inputs.
191-
public func addTargetsToExplicitBuildManifest() throws {
191+
package func addTargetsToExplicitBuildManifest() throws {
192192
// Sort the product targets in topological order in order to collect and "bubble up"
193193
// their respective dependency graphs to the depending targets.
194194
let nodes: [ResolvedTarget.Dependency] = try self.plan.targetMap.keys.compactMap {

0 commit comments

Comments
 (0)