Skip to content

Commit ad05fcb

Browse files
committed
Merge branch 'main' of github.com:apple/swift-package-manager into maxd/test-toolchain-argument
# Conflicts: # Tests/BuildTests/BuildPlanTests.swift
2 parents a7f8121 + 7bd34cc commit ad05fcb

File tree

65 files changed

+1673
-1084
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1673
-1084
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ Package.resolved
1818
.docc-build
1919
.vscode
2020
Utilities/InstalledSwiftPMConfiguration/config.json
21+
.devcontainer

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ Note: This is in reverse chronological order, so newer entries are added to the
22

33
* [#7530]
44

5-
Makes it possible for packages to depend on each other if such dependency doesn't form any target-level cycles. For example,
6-
package `A` can depend on `B` and `B` on `A` unless targets in `B` depend on products of `A` that depend on some of the same
5+
Starting from tools-version 6.0 makes it possible for packages to depend on each other if such dependency doesn't form any target-level cycles.
6+
For example, package `A` can depend on `B` and `B` on `A` unless targets in `B` depend on products of `A` that depend on some of the same
77
targets from `B` and vice versa.
88

99
Swift 6.0

CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@
2626

2727
Sources/XCBuildSupport/* @jakepetroules
2828

29-
* @bnbarham @MaxDesiatov @jakepetroules @francescomikulis
29+
* @bnbarham @MaxDesiatov @jakepetroules @francescomikulis @xedin
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// swift-tools-version: 5.10
2+
3+
import PackageDescription
4+
5+
let package = Package(
6+
name: "CheckTestLibraryEnvironmentVariable",
7+
targets: [
8+
.testTarget(name: "CheckTestLibraryEnvironmentVariableTests"),
9+
]
10+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import XCTest
2+
3+
final class CheckTestLibraryEnvironmentVariableTests: XCTestCase {
4+
func testEnviromentVariable() throws {
5+
let envvar = ProcessInfo.processInfo.environment["SWIFT_PM_TEST_LIBRARY"]
6+
XCTAssertEqual(envvar, "XCTest")
7+
}
8+
}

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
827827
.package(url: "https://github.com/apple/swift-crypto.git", .upToNextMinor(from: "3.0.0")),
828828
.package(url: "https://github.com/apple/swift-syntax.git", branch: relatedDependenciesBranch),
829829
.package(url: "https://github.com/apple/swift-system.git", .upToNextMinor(from: "1.1.1")),
830-
.package(url: "https://github.com/apple/swift-collections.git", .upToNextMinor(from: "1.0.1")),
830+
.package(url: "https://github.com/apple/swift-collections.git", "1.0.1" ..< "1.2.0"),
831831
.package(url: "https://github.com/apple/swift-certificates.git", .upToNextMinor(from: "1.0.1")),
832832
]
833833
} else {

Sources/Build/BuildDescription/PluginDescription.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ public final class PluginDescription: Codable {
2929
/// the plugin).
3030
public let targetName: String
3131

32+
/// The language-level target name.
33+
public let targetC99Name: String
34+
3235
/// The names of any plugin products in that package that vend the plugin
3336
/// to other packages.
3437
public let productNames: [String]
@@ -56,6 +59,7 @@ public final class PluginDescription: Codable {
5659

5760
self.package = package.identity
5861
self.targetName = target.name
62+
self.targetC99Name = target.c99name
5963
self.productNames = products.map(\.name)
6064
self.toolsVersion = toolsVersion
6165
self.sources = target.sources

Sources/Build/BuildDescription/ResolvedModule+BuildDescription.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import SPMBuildCore
1717

1818
extension ResolvedModule {
1919
func tempsPath(_ buildParameters: BuildParameters) -> AbsolutePath {
20-
let suffix = buildParameters.suffix(triple: self.buildTriple)
20+
let suffix = buildParameters.suffix
2121
return buildParameters.buildPath.appending(component: "\(self.c99name)\(suffix).build")
2222
}
2323
}

Sources/Build/BuildDescription/SwiftTargetBuildDescription.swift

Lines changed: 86 additions & 91 deletions
Large diffs are not rendered by default.

Sources/Build/BuildDescription/TargetBuildDescription.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public enum TargetBuildDescription {
101101
var buildParameters: BuildParameters {
102102
switch self {
103103
case .swift(let swiftTargetBuildDescription):
104-
return swiftTargetBuildDescription.defaultBuildParameters
104+
return swiftTargetBuildDescription.buildParameters
105105
case .clang(let clangTargetBuildDescription):
106106
return clangTargetBuildDescription.buildParameters
107107
}

Sources/Build/BuildManifest/LLBuildManifestBuilder+Clang.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ extension LLBuildManifestBuilder {
9393
let additionalInputs = try addBuildToolPlugins(.clang(target))
9494

9595
// Create a phony node to represent the entire target.
96-
let targetName = target.target.getLLBuildTargetName(buildParameters: target.buildParameters)
96+
let targetName = target.llbuildTargetName
9797
let output: Node = .virtual(targetName)
9898

9999
self.manifest.addNode(output, toTarget: targetName)

Sources/Build/BuildManifest/LLBuildManifestBuilder+Product.swift

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
import struct Basics.AbsolutePath
14+
import struct Basics.InternalError
1415
import struct LLBuildManifest.Node
16+
import struct SPMBuildCore.BuildParameters
17+
import struct PackageGraph.ResolvedProduct
1518

1619
extension LLBuildManifestBuilder {
1720
func createProductCommand(_ buildProduct: ProductBuildDescription) throws {
18-
let cmdName = try buildProduct.product.getCommandName(buildParameters: buildProduct.buildParameters)
21+
let cmdName = try buildProduct.commandName
1922

2023
// Add dependency on Info.plist generation on Darwin platforms.
2124
let testInputs: [AbsolutePath]
@@ -34,7 +37,7 @@ extension LLBuildManifestBuilder {
3437
}
3538

3639
// Create a phony node to represent the entire target.
37-
let targetName = try buildProduct.product.getLLBuildTargetName(buildParameters: buildProduct.buildParameters)
40+
let targetName = try buildProduct.llbuildTargetName
3841
let output: Node = .virtual(targetName)
3942

4043
let finalProductNode: Node
@@ -85,7 +88,7 @@ extension LLBuildManifestBuilder {
8588
outputPath: plistPath
8689
)
8790

88-
let cmdName = try buildProduct.product.getCommandName(buildParameters: buildProduct.buildParameters)
91+
let cmdName = try buildProduct.commandName
8992
let codeSigningOutput = Node.virtual(targetName + "-CodeSigning")
9093
try self.manifest.addShellCmd(
9194
name: "\(cmdName)-entitlements",
@@ -120,3 +123,48 @@ extension LLBuildManifestBuilder {
120123
)
121124
}
122125
}
126+
127+
extension ProductBuildDescription {
128+
package var llbuildTargetName: String {
129+
get throws {
130+
try self.product.getLLBuildTargetName(buildParameters: self.buildParameters)
131+
}
132+
}
133+
134+
package var commandName: String {
135+
get throws {
136+
try "C.\(self.llbuildTargetName)\(self.buildParameters.suffix)"
137+
}
138+
}
139+
}
140+
141+
extension ResolvedProduct {
142+
public func getLLBuildTargetName(buildParameters: BuildParameters) throws -> String {
143+
let triple = buildParameters.triple.tripleString
144+
let config = buildParameters.buildConfig
145+
let suffix = buildParameters.suffix
146+
let potentialExecutableTargetName = "\(name)-\(triple)-\(config)\(suffix).exe"
147+
let potentialLibraryTargetName = "\(name)-\(triple)-\(config)\(suffix).dylib"
148+
149+
switch type {
150+
case .library(.dynamic):
151+
return potentialLibraryTargetName
152+
case .test:
153+
return "\(name)-\(triple)-\(config)\(suffix).test"
154+
case .library(.static):
155+
return "\(name)-\(triple)-\(config)\(suffix).a"
156+
case .library(.automatic):
157+
throw InternalError("automatic library not supported")
158+
case .executable, .snippet:
159+
return potentialExecutableTargetName
160+
case .macro:
161+
#if BUILD_MACROS_AS_DYLIBS
162+
return potentialLibraryTargetName
163+
#else
164+
return potentialExecutableTargetName
165+
#endif
166+
case .plugin:
167+
throw InternalError("unexpectedly asked for the llbuild target name of a plugin product")
168+
}
169+
}
170+
}

Sources/Build/BuildManifest/LLBuildManifestBuilder+Resources.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ extension LLBuildManifestBuilder {
4545
outputs.append(output)
4646
}
4747

48-
let cmdName = target.target.getLLBuildResourcesCmdName(buildParameters: target.buildParameters)
48+
let cmdName = target.llbuildResourcesCmdName
4949
self.manifest.addPhonyCmd(name: cmdName, inputs: outputs, outputs: [.virtual(cmdName)])
5050

5151
return .virtual(cmdName)

0 commit comments

Comments
 (0)