Skip to content

begin to integrate SwiftSystem #3881

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@ string(COMPARE EQUAL ${CMAKE_SYSTEM_NAME} Windows CMAKE_INSTALL_DEFAULT)
option(USE_CMAKE_INSTALL
"Install build products using cmake's install() instead of the bootstrap script's install()"
${CMAKE_INSTALL_DEFAULT})

if(BUILD_SHARED_LIBS)
set(CMAKE_POSITION_INDEPENDENT_CODE YES)
endif()

if(FIND_PM_DEPS)
find_package(SwiftSystem CONFIG REQUIRED)
find_package(TSC CONFIG REQUIRED)

find_package(LLBuild CONFIG)
Expand Down
9 changes: 9 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,22 @@ Clone the following repositories beside the SwiftPM directory:
$> git clone https://github.com/apple/swift-crypto --branch 1.1.6
```

76. [swift-system] and check out tag with the [latest version](https://github.com/apple/swift-system/tags).

For example, if the latest tag is 1.0.0:
```sh
$> git clone https://github.com/apple/swift-system --branch 1.0.0
```

[swift-argument-parser]: https://github.com/apple/swift-argument-parser
[swift-crypto]: https://github.com/apple/swift-crypto
[swift-driver]: https://github.com/apple/swift-driver
[swift-llbuild]: https://github.com/apple/swift-llbuild
[swift-system]: https://github.com/apple/swift-system
[swift-tools-support-core]: https://github.com/apple/swift-tools-support-core
[Yams]: https://github.com/jpsim/yams


#### Building

```bash
Expand Down
3 changes: 3 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ let package = Package(
name: "Basics",
dependencies: [
.product(name: "SwiftToolsSupport-auto", package: "swift-tools-support-core"),
.product(name: "SystemPackage", package: "swift-system"),
],
exclude: ["CMakeLists.txt"]
),
Expand Down Expand Up @@ -549,12 +550,14 @@ if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
.package(url: "https://github.com/apple/swift-argument-parser.git", .upToNextMinor(from: "1.0.1")),
.package(url: "https://github.com/apple/swift-driver.git", .branch(relatedDependenciesBranch)),
.package(url: "https://github.com/apple/swift-crypto.git", .upToNextMinor(from: minimumCryptoVersion)),
.package(url: "https://github.com/apple/swift-system.git", .upToNextMinor(from: "1.0.0")),
]
} else {
package.dependencies += [
.package(path: "../swift-tools-support-core"),
.package(path: "../swift-argument-parser"),
.package(path: "../swift-driver"),
.package(path: "../swift-crypto"),
.package(path: "../swift-system"),
]
}
1 change: 1 addition & 0 deletions Sources/Basics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ add_library(Basics
SQLiteBackedCache.swift
Version+Extensions.swift)
target_link_libraries(Basics PUBLIC
SwiftSystem::SystemPackage
TSCBasic
TSCUtility)
target_link_libraries(Basics PRIVATE
Expand Down
1 change: 1 addition & 0 deletions Sources/Basics/FileSystem+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import class Foundation.FileManager
import struct Foundation.Data
import struct Foundation.UUID
import SystemPackage
import TSCBasic

// MARK: - user level
Expand Down
14 changes: 12 additions & 2 deletions Utilities/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ def parse_global_args(args):
args.source_dirs["swift-argument-parser"] = os.path.join(args.project_root, "..", "swift-argument-parser")
args.source_dirs["swift-driver"] = os.path.join(args.project_root, "..", "swift-driver")
args.source_dirs["swift-crypto"] = os.path.join(args.project_root, "..", "swift-crypto")
args.source_dirs["swift-system"] = os.path.join(args.project_root, "..", "swift-system")
args.source_root = os.path.join(args.project_root, "Sources")

if platform.system() == 'Darwin':
Expand Down Expand Up @@ -330,13 +331,19 @@ def build(args):
build_llbuild(args)

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

swift_driver_cmake_flags = [
get_llbuild_cmake_arg(args),
"-DSwiftSystem_DIR=" + os.path.join(args.build_dirs["swift-system"], "cmake/modules"),
"-DTSC_DIR=" + os.path.join(args.build_dirs["tsc"], "cmake/modules"),
"-DYams_DIR=" + os.path.join(args.build_dirs["yams"], "cmake/modules"),
"-DArgumentParser_DIR=" + os.path.join(args.build_dirs["swift-argument-parser"], "cmake/modules"),
Expand Down Expand Up @@ -560,6 +567,7 @@ def build_swiftpm_with_cmake(args):
"-DArgumentParser_DIR=" + os.path.join(args.build_dirs["swift-argument-parser"], "cmake/modules"),
"-DSwiftDriver_DIR=" + os.path.join(args.build_dirs["swift-driver"], "cmake/modules"),
"-DSwiftCrypto_DIR=" + os.path.join(args.build_dirs["swift-crypto"], "cmake/modules"),
"-DSwiftSystem_DIR=" + os.path.join(args.build_dirs["swift-system"], "cmake/modules"),
]

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

def build_swiftpm_with_swiftpm(args, integrated_swift_driver):
"""Builds SwiftPM using the version of SwiftPM built with CMake."""
Expand Down Expand Up @@ -680,6 +689,7 @@ def get_swiftpm_env_cmd(args):
os.path.join(args.build_dirs["swift-argument-parser"], "lib"),
os.path.join(args.build_dirs["swift-driver"], "lib"),
os.path.join(args.build_dirs["swift-crypto"], "lib"),
os.path.join(args.build_dirs["swift-system"], "lib"),
] + args.target_info["paths"]["runtimeLibraryPaths"])

if platform.system() == 'Darwin':
Expand Down