Skip to content

Commit 903a1ab

Browse files
committed
Allow linking an existing llbuild.framework
This introduces a new environment variable `SWIFT_DRIVER_LLBUILD_FWK` which can be set to opt out of having a dependency on llbuild in the manifest. This allows linking with an existing llbuild.framework instead of building it, similar to SwiftPM's `SWIFTPM_LLBUILD_FWK` option.
1 parent 28563cb commit 903a1ab

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

Package.swift

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ let package = Package(
2525
/// The driver library.
2626
.target(
2727
name: "SwiftDriver",
28-
dependencies: ["SwiftOptions", "SwiftToolsSupport-auto", "llbuildSwift", "Yams"]),
28+
dependencies: ["SwiftOptions", "SwiftToolsSupport-auto", "Yams"]),
2929
.testTarget(
3030
name: "SwiftDriverTests",
3131
dependencies: ["SwiftDriver", "swift-driver"]),
@@ -56,16 +56,29 @@ let package = Package(
5656
cxxLanguageStandard: .cxx14
5757
)
5858

59+
if ProcessInfo.processInfo.environment["SWIFT_DRIVER_LLBUILD_FWK"] == nil {
60+
if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
61+
package.dependencies += [
62+
.package(url: "https://github.com/apple/swift-llbuild.git", .branch("master")),
63+
]
64+
} else {
65+
// In Swift CI, use a local path to llbuild to interoperate with tools
66+
// like `update-checkout`, which control the sources externally.
67+
package.dependencies += [
68+
.package(path: "../llbuild"),
69+
]
70+
}
71+
package.targets.first(where: { $0.name == "SwiftDriver" })!.dependencies += ["llbuildSwift"]
72+
}
73+
5974
if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
6075
package.dependencies += [
6176
.package(url: "https://github.com/apple/swift-tools-support-core.git", .branch("master")),
62-
.package(url: "https://github.com/apple/swift-llbuild.git", .branch("master")),
6377
.package(url: "https://github.com/jpsim/Yams.git", .branch("master")),
6478
]
6579
} else {
6680
package.dependencies += [
6781
.package(path: "../swiftpm/swift-tools-support-core"),
6882
.package(path: "../yams"),
69-
.package(path: "../llbuild"),
7083
]
7184
}

Sources/SwiftDriver/Execution/llbuild.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@
1212

1313
// FIXME: This is directly copied from SwiftPM, consider moving this to llbuild.
1414

15+
// We either export the llbuildSwift shared library or the llbuild framework.
16+
#if canImport(llbuildSwift)
1517
@_exported import llbuildSwift
18+
@_exported import llbuild
19+
#else
20+
@_exported import llbuild
21+
#endif
1622

1723
import Foundation
1824

0 commit comments

Comments
 (0)