Skip to content

Commit 3dc40b4

Browse files
committed
Add SwiftCrypto back to cmake build
1 parent c2aa7bc commit 3dc40b4

File tree

9 files changed

+41
-12
lines changed

9 files changed

+41
-12
lines changed

CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This source file is part of the Swift open source project
22
#
3-
# Copyright (c) 2014 - 2021 Apple Inc. and the Swift project authors
3+
# Copyright (c) 2014 - 2023 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
@@ -54,6 +54,12 @@ if(FIND_PM_DEPS)
5454
find_package(ArgumentParser CONFIG REQUIRED)
5555
find_package(SwiftDriver CONFIG REQUIRED)
5656
find_package(SwiftCollections CONFIG REQUIRED)
57+
find_package(SwiftCrypto CONFIG)
58+
if (SwiftCrypto_FOUND)
59+
add_compile_options($<$<COMPILE_LANGUAGE:Swift>:-DCRYPTO_v2>)
60+
else()
61+
message(WARNING "SwiftCrypto not found, package collections and package signing will be unavailable")
62+
endif()
5763
endif()
5864

5965
find_package(dispatch QUIET)

Package.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,7 @@ let package = Package(
294294
.target(
295295
name: "PackageSigning",
296296
dependencies: [
297-
// TODO: uncomment once we resolve build problems
298-
// .product(name: "Crypto", package: "swift-crypto"),
297+
.product(name: "Crypto", package: "swift-crypto"),
299298
"Basics",
300299
"PackageModel",
301300
],

Sources/PackageCollectionsSigning/Key/Key+EC.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift open source project
44
//
5-
// Copyright (c) 2021 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2021-2023 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See http://swift.org/LICENSE.txt for license information
@@ -12,7 +12,12 @@
1212

1313
import Foundation
1414

15+
// FIXME: @_implementationOnly fails on Linux
16+
#if !os(Linux)
17+
@_implementationOnly import Crypto
18+
#else
1519
import Crypto
20+
#endif
1621

1722
typealias CryptoECPrivateKey = P256.Signing.PrivateKey
1823
typealias CryptoECPublicKey = P256.Signing.PublicKey

Sources/PackageCollectionsSigning/Signing/Signing+ECKey.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift open source project
44
//
5-
// Copyright (c) 2021 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2021-2023 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See http://swift.org/LICENSE.txt for license information
@@ -12,7 +12,12 @@
1212

1313
import struct Foundation.Data
1414

15+
// FIXME: @_implementationOnly fails on Linux
16+
#if !os(Linux)
17+
@_implementationOnly import Crypto
18+
#else
1519
import Crypto
20+
#endif
1621

1722
// MARK: - MessageSigner and MessageValidator conformance
1823

Sources/PackageSigning/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ add_library(PackageSigning STATIC
1515
target_link_libraries(PackageSigning PUBLIC
1616
$<$<NOT:$<PLATFORM_ID:Darwin>>:Foundation>
1717
Basics
18-
# Crypto ## TODO: uncomment once we resolve build problems
18+
Crypto
1919
PackageModel
2020
TSCBasic
2121
TSCUtility)

Sources/PackageSigning/SignatureProvider.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,15 @@ import struct Foundation.Data
1414

1515
#if os(macOS)
1616
import Security
17-
import CryptoKit // TODO: remove when we can import Crypto
1817
#endif
1918

2019
import Basics
21-
//import Crypto
20+
// FIXME: @_implementationOnly fails on Linux
21+
#if !os(Linux)
22+
@_implementationOnly import Crypto
23+
#else
24+
import Crypto
25+
#endif
2226

2327
public enum SignatureProvider {
2428
public static func sign(

Sources/PackageSigning/SigningIdentity.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,15 @@ import struct Foundation.Data
1414

1515
#if os(macOS)
1616
import Security
17-
import CryptoKit // TODO: remove when we can import Crypto
1817
#endif
1918

2019
import Basics
21-
//import Crypto
20+
// FIXME: @_implementationOnly fails on Linux
21+
#if !os(Linux)
22+
@_implementationOnly import Crypto
23+
#else
24+
import Crypto
25+
#endif
2226

2327
public protocol SigningIdentity {
2428
// TODO: change type to Certificate

Utilities/Docker/docker-compose.yaml

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 open source project
22
#
3-
# Copyright (c) 2021 Apple Inc. and the Swift project authors
3+
# Copyright (c) 2021-2023 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
@@ -36,6 +36,7 @@ services:
3636
- ../../../swift-tools-support-core:/code/swift-tools-support-core:z
3737
- ../../../yams:/code/yams:z
3838
- ../../../swift-argument-parser:/code/swift-argument-parser:z
39+
- ../../../swift-crypto:/code/swift-crypto:z
3940
- ../../../swift-driver:/code/swift-driver:z
4041
- ../../../swift-llbuild:/code/llbuild:z
4142
- ../../../swift-system:/code/swift-system:z

Utilities/bootstrap

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"""
55
This source file is part of the Swift open source project
66
//
7-
// Copyright (c) 2014-2021 Apple Inc. and the Swift project authors
7+
// Copyright (c) 2014-2023 Apple Inc. and the Swift project authors
88
Licensed under Apache License v2.0 with Runtime Library Exception
99
1010
See http://swift.org/LICENSE.txt for license information
@@ -184,6 +184,7 @@ def parse_global_args(args):
184184
args.source_dirs["tsc"] = os.path.join(args.project_root, "..", "swift-tools-support-core")
185185
args.source_dirs["yams"] = os.path.join(args.project_root, "..", "yams")
186186
args.source_dirs["swift-argument-parser"] = os.path.join(args.project_root, "..", "swift-argument-parser")
187+
args.source_dirs["swift-crypto"] = os.path.join(args.project_root, "..", "swift-crypto")
187188
args.source_dirs["swift-driver"] = os.path.join(args.project_root, "..", "swift-driver")
188189
args.source_dirs["swift-system"] = os.path.join(args.project_root, "..", "swift-system")
189190
args.source_dirs["swift-collections"] = os.path.join(args.project_root, "..", "swift-collections")
@@ -351,6 +352,7 @@ def build(args):
351352
]
352353
build_dependency(args, "swift-driver", swift_driver_cmake_flags)
353354
build_dependency(args, "swift-collections")
355+
build_dependency(args, "swift-crypto")
354356
build_swiftpm_with_cmake(args)
355357

356358
build_swiftpm_with_swiftpm(args,integrated_swift_driver=False)
@@ -594,6 +596,7 @@ def build_swiftpm_with_cmake(args):
594596
get_llbuild_cmake_arg(args),
595597
"-DTSC_DIR=" + os.path.join(args.build_dirs["tsc"], "cmake/modules"),
596598
"-DArgumentParser_DIR=" + os.path.join(args.build_dirs["swift-argument-parser"], "cmake/modules"),
599+
"-DSwiftCrypto_DIR=" + os.path.join(args.build_dirs["swift-crypto"], "cmake/modules"),
597600
"-DSwiftDriver_DIR=" + os.path.join(args.build_dirs["swift-driver"], "cmake/modules"),
598601
"-DSwiftSystem_DIR=" + os.path.join(args.build_dirs["swift-system"], "cmake/modules"),
599602
"-DSwiftCollections_DIR=" + os.path.join(args.build_dirs["swift-collections"], "cmake/modules"),
@@ -611,6 +614,7 @@ def build_swiftpm_with_cmake(args):
611614
if platform.system() == "Darwin":
612615
add_rpath_for_cmake_build(args, os.path.join(args.build_dirs["yams"], "lib"))
613616
add_rpath_for_cmake_build(args, os.path.join(args.build_dirs["swift-argument-parser"], "lib"))
617+
add_rpath_for_cmake_build(args, os.path.join(args.build_dirs["swift-crypto"], "lib"))
614618
add_rpath_for_cmake_build(args, os.path.join(args.build_dirs["swift-driver"], "lib"))
615619
add_rpath_for_cmake_build(args, os.path.join(args.build_dirs["swift-system"], "lib"))
616620
add_rpath_for_cmake_build(args, os.path.join(args.build_dirs["swift-collections"], "lib"))
@@ -724,6 +728,7 @@ def get_swiftpm_env_cmd(args):
724728
os.path.join(args.build_dirs["llbuild"], "lib"),
725729
os.path.join(args.build_dirs["yams"], "lib"),
726730
os.path.join(args.build_dirs["swift-argument-parser"], "lib"),
731+
os.path.join(args.build_dirs["swift-crypto"], "lib"),
727732
os.path.join(args.build_dirs["swift-driver"], "lib"),
728733
os.path.join(args.build_dirs["swift-system"], "lib"),
729734
os.path.join(args.build_dirs["swift-collections"], "lib"),

0 commit comments

Comments
 (0)