Skip to content

Commit ff2552a

Browse files
authored
begin to integrate SwiftSystem (#3881)
motivation: SwiftSystem provides infra that can replace some bespoke implmentations in TSC and SwiftPM, improving the cross-platform support changes: add SwiftPM and CMake setup for including SwiftSystem as a dependency
1 parent 0a66149 commit ff2552a

File tree

6 files changed

+28
-3
lines changed

6 files changed

+28
-3
lines changed

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,13 @@ string(COMPARE EQUAL ${CMAKE_SYSTEM_NAME} Windows CMAKE_INSTALL_DEFAULT)
3737
option(USE_CMAKE_INSTALL
3838
"Install build products using cmake's install() instead of the bootstrap script's install()"
3939
${CMAKE_INSTALL_DEFAULT})
40-
40+
4141
if(BUILD_SHARED_LIBS)
4242
set(CMAKE_POSITION_INDEPENDENT_CODE YES)
4343
endif()
4444

4545
if(FIND_PM_DEPS)
46+
find_package(SwiftSystem CONFIG REQUIRED)
4647
find_package(TSC CONFIG REQUIRED)
4748

4849
find_package(LLBuild CONFIG)

CONTRIBUTING.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,13 +186,22 @@ Clone the following repositories beside the SwiftPM directory:
186186
$> git clone https://github.com/apple/swift-crypto --branch 1.1.6
187187
```
188188

189+
76. [swift-system] and check out tag with the [latest version](https://github.com/apple/swift-system/tags).
190+
191+
For example, if the latest tag is 1.0.0:
192+
```sh
193+
$> git clone https://github.com/apple/swift-system --branch 1.0.0
194+
```
195+
189196
[swift-argument-parser]: https://github.com/apple/swift-argument-parser
190197
[swift-crypto]: https://github.com/apple/swift-crypto
191198
[swift-driver]: https://github.com/apple/swift-driver
192199
[swift-llbuild]: https://github.com/apple/swift-llbuild
200+
[swift-system]: https://github.com/apple/swift-system
193201
[swift-tools-support-core]: https://github.com/apple/swift-tools-support-core
194202
[Yams]: https://github.com/jpsim/yams
195203

204+
196205
#### Building
197206

198207
```bash

Package.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ let package = Package(
139139
name: "Basics",
140140
dependencies: [
141141
.product(name: "SwiftToolsSupport-auto", package: "swift-tools-support-core"),
142+
.product(name: "SystemPackage", package: "swift-system"),
142143
],
143144
exclude: ["CMakeLists.txt"]
144145
),
@@ -571,12 +572,14 @@ if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
571572
.package(url: "https://github.com/apple/swift-argument-parser.git", .upToNextMinor(from: "1.0.1")),
572573
.package(url: "https://github.com/apple/swift-driver.git", .branch(relatedDependenciesBranch)),
573574
.package(url: "https://github.com/apple/swift-crypto.git", .upToNextMinor(from: minimumCryptoVersion)),
575+
.package(url: "https://github.com/apple/swift-system.git", .upToNextMinor(from: "1.0.0")),
574576
]
575577
} else {
576578
package.dependencies += [
577579
.package(path: "../swift-tools-support-core"),
578580
.package(path: "../swift-argument-parser"),
579581
.package(path: "../swift-driver"),
580582
.package(path: "../swift-crypto"),
583+
.package(path: "../swift-system"),
581584
]
582585
}

Sources/Basics/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ add_library(Basics
2626
SQLiteBackedCache.swift
2727
Version+Extensions.swift)
2828
target_link_libraries(Basics PUBLIC
29+
SwiftSystem::SystemPackage
2930
TSCBasic
3031
TSCUtility)
3132
target_link_libraries(Basics PRIVATE

Sources/Basics/FileSystem+Extensions.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import class Foundation.FileManager
1212
import struct Foundation.Data
1313
import struct Foundation.UUID
14+
import SystemPackage
1415
import TSCBasic
1516

1617
// MARK: - user level

Utilities/bootstrap

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ def parse_global_args(args):
185185
args.source_dirs["swift-argument-parser"] = os.path.join(args.project_root, "..", "swift-argument-parser")
186186
args.source_dirs["swift-driver"] = os.path.join(args.project_root, "..", "swift-driver")
187187
args.source_dirs["swift-crypto"] = os.path.join(args.project_root, "..", "swift-crypto")
188+
args.source_dirs["swift-system"] = os.path.join(args.project_root, "..", "swift-system")
188189
args.source_root = os.path.join(args.project_root, "Sources")
189190

190191
if platform.system() == 'Darwin':
@@ -330,13 +331,19 @@ def build(args):
330331
build_llbuild(args)
331332

332333
if args.bootstrap:
333-
# tsc, swift-argument-parser, and yams are depended on by swift-driver, so they must be built first.
334-
build_dependency(args, "tsc")
334+
# tsc depends on swift-system so they must be built first.
335+
build_dependency(args, "swift-system")
336+
# swift-driver depends on tsc, swift-argument-parser, and yams so they must be built first.
337+
tsc_cmake_flags = [
338+
"-DSwiftSystem_DIR=" + os.path.join(args.build_dirs["swift-system"], "cmake/modules"),
339+
]
340+
build_dependency(args, "tsc", tsc_cmake_flags)
335341
build_dependency(args, "swift-argument-parser", ["-DBUILD_TESTING=NO", "-DBUILD_EXAMPLES=NO"])
336342
build_dependency(args, "yams", [], [get_foundation_cmake_arg(args)] if args.foundation_build_dir else [])
337343

338344
swift_driver_cmake_flags = [
339345
get_llbuild_cmake_arg(args),
346+
"-DSwiftSystem_DIR=" + os.path.join(args.build_dirs["swift-system"], "cmake/modules"),
340347
"-DTSC_DIR=" + os.path.join(args.build_dirs["tsc"], "cmake/modules"),
341348
"-DYams_DIR=" + os.path.join(args.build_dirs["yams"], "cmake/modules"),
342349
"-DArgumentParser_DIR=" + os.path.join(args.build_dirs["swift-argument-parser"], "cmake/modules"),
@@ -560,6 +567,7 @@ def build_swiftpm_with_cmake(args):
560567
"-DArgumentParser_DIR=" + os.path.join(args.build_dirs["swift-argument-parser"], "cmake/modules"),
561568
"-DSwiftDriver_DIR=" + os.path.join(args.build_dirs["swift-driver"], "cmake/modules"),
562569
"-DSwiftCrypto_DIR=" + os.path.join(args.build_dirs["swift-crypto"], "cmake/modules"),
570+
"-DSwiftSystem_DIR=" + os.path.join(args.build_dirs["swift-system"], "cmake/modules"),
563571
]
564572

565573
if platform.system() == 'Darwin':
@@ -576,6 +584,7 @@ def build_swiftpm_with_cmake(args):
576584
add_rpath_for_cmake_build(args, os.path.join(args.build_dirs["swift-argument-parser"], "lib"))
577585
add_rpath_for_cmake_build(args, os.path.join(args.build_dirs["swift-driver"], "lib"))
578586
add_rpath_for_cmake_build(args, os.path.join(args.build_dirs["swift-crypto"], "lib"))
587+
add_rpath_for_cmake_build(args, os.path.join(args.build_dirs["swift-system"], "lib"))
579588

580589
def build_swiftpm_with_swiftpm(args, integrated_swift_driver):
581590
"""Builds SwiftPM using the version of SwiftPM built with CMake."""
@@ -680,6 +689,7 @@ def get_swiftpm_env_cmd(args):
680689
os.path.join(args.build_dirs["swift-argument-parser"], "lib"),
681690
os.path.join(args.build_dirs["swift-driver"], "lib"),
682691
os.path.join(args.build_dirs["swift-crypto"], "lib"),
692+
os.path.join(args.build_dirs["swift-system"], "lib"),
683693
] + args.target_info["paths"]["runtimeLibraryPaths"])
684694

685695
if platform.system() == 'Darwin':

0 commit comments

Comments
 (0)