Skip to content

Commit 60d6da6

Browse files
authored
Add swift-crypto dependency (#3202)
Motivation: Package collections feature will require swift-crypto dependency. Modifications: - Add swift-crypto dependency - Bump minimum macOS version to 10.15, for it's required by swift-crypto Requires apple/swift-crypto#65
1 parent fb7e96c commit 60d6da6

File tree

6 files changed

+51
-5
lines changed

6 files changed

+51
-5
lines changed

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This source file is part of the Swift.org open source project
22
#
3-
# Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors
3+
# Copyright (c) 2014 - 2021 Apple Inc. and the Swift project authors
44
# Licensed under Apache License v2.0 with Runtime Library Exception
55
#
66
# See http://swift.org/LICENSE.txt for license information
@@ -47,6 +47,7 @@ if(FIND_PM_DEPS)
4747
endif()
4848

4949
find_package(ArgumentParser CONFIG REQUIRED)
50+
find_package(SwiftCrypto CONFIG REQUIRED)
5051
find_package(SwiftDriver CONFIG REQUIRED)
5152
endif()
5253

Documentation/Contributing.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,13 @@ For example, if the latest tag is 0.3.1:
152152
$> git clone https://github.com/apple/swift-argument-parser --branch 0.3.1
153153
```
154154

155+
5. Clone [swift-crypto](https://github.com/apple/swift-crypto) beside the SwiftPM directory and check out tag with the [latest version](https://github.com/apple/swift-crypto/tags).
156+
157+
For example, if the latest tag is 1.1.3:
158+
```bash
159+
$> git clone https://github.com/apple/swift-crypto --branch 1.1.3
160+
```
161+
155162
#### Building
156163

157164
```bash

Package.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/*
44
This source file is part of the Swift.org open source project
55

6-
Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
6+
Copyright (c) 2014 - 2021 Apple Inc. and the Swift project authors
77
Licensed under Apache License v2.0 with Runtime Library Exception
88

99
See http://swift.org/LICENSE.txt for license information
@@ -20,7 +20,7 @@ let macOSPlatform: SupportedPlatform
2020
if let deploymentTarget = ProcessInfo.processInfo.environment["SWIFTPM_MACOS_DEPLOYMENT_TARGET"] {
2121
macOSPlatform = .macOS(deploymentTarget)
2222
} else {
23-
macOSPlatform = .macOS(.v10_10)
23+
macOSPlatform = .macOS(.v10_15)
2424
}
2525

2626
let package = Package(
@@ -156,7 +156,7 @@ let package = Package(
156156
.target(
157157
/** Data structures and support for package collections */
158158
name: "PackageCollections",
159-
dependencies: ["SwiftToolsSupport-auto", "Basics", "PackageModel", "SourceControl", "PackageCollectionsModel"]),
159+
dependencies: ["SwiftToolsSupport-auto", "Basics", "PackageModel", "SourceControl", "PackageCollectionsModel", "Crypto"]),
160160

161161
// MARK: Package Manager Functionality
162162

@@ -323,11 +323,13 @@ if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
323323
// dependency version changes here with those projects.
324324
.package(url: "https://github.com/apple/swift-argument-parser.git", .upToNextMinor(from: "0.3.1")),
325325
.package(url: "https://github.com/apple/swift-driver.git", .branch(relatedDependenciesBranch)),
326+
.package(url: "https://github.com/apple/swift-crypto.git", .branch(relatedDependenciesBranch)),
326327
]
327328
} else {
328329
package.dependencies += [
329330
.package(path: "../swift-tools-support-core"),
330331
.package(path: "../swift-argument-parser"),
331332
.package(path: "../swift-driver"),
333+
.package(path: "../swift-crypto"),
332334
]
333335
}

Sources/PackageCollections/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,15 @@ target_link_libraries(PackageCollections PUBLIC
3232
TSCBasic
3333
TSCUtility
3434
Basics
35+
Crypto
36+
CCryptoBoringSSL
3537
PackageModel
3638
SourceControl)
3739
# NOTE(compnerd) workaround for CMake not setting up include flags yet
3840
set_target_properties(PackageCollections PROPERTIES
3941
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
42+
target_link_options(PackageCollections PRIVATE
43+
"$<$<PLATFORM_ID:Darwin>:SHELL:-Xlinker -framework -Xlinker Security>")
4044

4145
if(USE_CMAKE_INSTALL)
4246
install(TARGETS PackageCollections
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
This source file is part of the Swift.org open source project
3+
4+
Copyright (c) 2021 Apple Inc. and the Swift project authors
5+
Licensed under Apache License v2.0 with Runtime Library Exception
6+
7+
See http://swift.org/LICENSE.txt for license information
8+
See http://swift.org/CONTRIBUTORS.txt for Swift project authors
9+
*/
10+
11+
import Crypto
12+
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
13+
import Security
14+
#else
15+
import CCryptoBoringSSL
16+
#endif

Utilities/bootstrap

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44
This source file is part of the Swift.org open source project
55
6-
Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
6+
Copyright (c) 2014 - 2021 Apple Inc. and the Swift project authors
77
Licensed under Apache License v2.0 with Runtime Library Exception
88
99
See http://swift.org/LICENSE.txt for license information
@@ -171,6 +171,7 @@ def parse_global_args(args):
171171
args.yams_source_dir = os.path.join(args.project_root, "..", "yams")
172172
args.swift_argument_parser_source_dir = os.path.join(args.project_root, "..", "swift-argument-parser")
173173
args.swift_driver_source_dir = os.path.join(args.project_root, "..", "swift-driver")
174+
args.swift_crypto_source_dir = os.path.join(args.project_root, "..", "swift-crypto")
174175
args.source_root = os.path.join(args.project_root, "Sources")
175176

176177
if platform.system() == 'Darwin':
@@ -307,6 +308,7 @@ def build(args):
307308
build_yams(args)
308309
build_swift_argument_parser(args)
309310
build_swift_driver(args)
311+
build_swift_crypto(args)
310312

311313
build_swiftpm_with_cmake(args)
312314
build_swiftpm_with_swiftpm(args,integrated_swift_driver=False)
@@ -559,6 +561,17 @@ def build_swift_driver(args):
559561
cmake_flags.append("-DCMAKE_OSX_DEPLOYMENT_TARGET=%s" % g_macos_deployment_target)
560562

561563
build_with_cmake(args, cmake_flags, args.swift_driver_source_dir, args.swift_driver_build_dir)
564+
565+
def build_swift_crypto(args):
566+
note("Building SwiftCrypto")
567+
args.swift_crypto_build_dir = os.path.join(args.target_dir, "swift-crypto")
568+
569+
cmake_flags = []
570+
if platform.system() == 'Darwin':
571+
cmake_flags.append("-DCMAKE_C_FLAGS=-target %s%s" % (get_build_target(args), g_macos_deployment_target))
572+
cmake_flags.append("-DCMAKE_OSX_DEPLOYMENT_TARGET=%s" % g_macos_deployment_target)
573+
574+
build_with_cmake(args, cmake_flags, args.swift_crypto_source_dir, args.swift_crypto_build_dir)
562575

563576
def add_rpath_for_cmake_build(args, rpath):
564577
"Adds the given rpath to the CMake-built swift-build"
@@ -578,6 +591,7 @@ def build_swiftpm_with_cmake(args):
578591
"-DYams_DIR=" + os.path.join(args.yams_build_dir, "cmake/modules"),
579592
"-DArgumentParser_DIR=" + os.path.join(args.swift_argument_parser_build_dir, "cmake/modules"),
580593
"-DSwiftDriver_DIR=" + os.path.join(args.swift_driver_build_dir, "cmake/modules"),
594+
"-DSwiftCrypto_DIR=" + os.path.join(args.swift_crypto_build_dir, "cmake/modules"),
581595
"-DFIND_PM_DEPS:BOOL=YES",
582596
]
583597
else:
@@ -598,6 +612,7 @@ def build_swiftpm_with_cmake(args):
598612
add_rpath_for_cmake_build(args, os.path.join(args.yams_build_dir, "lib"))
599613
add_rpath_for_cmake_build(args, os.path.join(args.swift_argument_parser_build_dir, "lib"))
600614
add_rpath_for_cmake_build(args, os.path.join(args.swift_driver_build_dir, "lib"))
615+
add_rpath_for_cmake_build(args, os.path.join(args.swift_crypto_build_dir, "lib"))
601616

602617
def build_swiftpm_with_swiftpm(args, integrated_swift_driver):
603618
"""Builds SwiftPM using the version of SwiftPM built with CMake."""
@@ -694,6 +709,7 @@ def get_swiftpm_env_cmd(args):
694709
os.path.join(args.yams_build_dir, "lib"),
695710
os.path.join(args.swift_argument_parser_build_dir, "lib"),
696711
os.path.join(args.swift_driver_build_dir, "lib"),
712+
os.path.join(args.swift_crypto_build_dir, "lib"),
697713
] + args.target_info["paths"]["runtimeLibraryPaths"])
698714

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

0 commit comments

Comments
 (0)