diff --git a/CMakeLists.txt b/CMakeLists.txt index 3d0db5ce519..677e8dc01bb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ # This source file is part of the Swift open source project # -# Copyright (c) 2014 - 2021 Apple Inc. and the Swift project authors +# Copyright (c) 2014 - 2023 Apple Inc. and the Swift project authors # Licensed under Apache License v2.0 with Runtime Library Exception # # See http://swift.org/LICENSE.txt for license information @@ -54,6 +54,12 @@ if(FIND_PM_DEPS) find_package(ArgumentParser CONFIG REQUIRED) find_package(SwiftDriver CONFIG REQUIRED) find_package(SwiftCollections CONFIG REQUIRED) + find_package(SwiftCrypto CONFIG) + if (SwiftCrypto_FOUND) + add_compile_options($<$:-DCRYPTO_v2>) + else() + message(WARNING "SwiftCrypto not found, package collections and package signing will be unavailable") + endif() endif() find_package(dispatch QUIET) diff --git a/Package.swift b/Package.swift index 4e82c00b44c..804e45247b6 100644 --- a/Package.swift +++ b/Package.swift @@ -294,8 +294,7 @@ let package = Package( .target( name: "PackageSigning", dependencies: [ - // TODO: uncomment once we resolve build problems -// .product(name: "Crypto", package: "swift-crypto"), + .product(name: "Crypto", package: "swift-crypto"), "Basics", "PackageModel", ], diff --git a/Sources/PackageCollectionsSigning/Key/Key+EC.swift b/Sources/PackageCollectionsSigning/Key/Key+EC.swift index 1f031799d21..25d49869d9b 100644 --- a/Sources/PackageCollectionsSigning/Key/Key+EC.swift +++ b/Sources/PackageCollectionsSigning/Key/Key+EC.swift @@ -2,7 +2,7 @@ // // This source file is part of the Swift open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021-2023 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See http://swift.org/LICENSE.txt for license information @@ -12,7 +12,12 @@ import Foundation +// FIXME: @_implementationOnly fails on Linux +#if !os(Linux) +@_implementationOnly import Crypto +#else import Crypto +#endif typealias CryptoECPrivateKey = P256.Signing.PrivateKey typealias CryptoECPublicKey = P256.Signing.PublicKey diff --git a/Sources/PackageCollectionsSigning/Signing/Signing+ECKey.swift b/Sources/PackageCollectionsSigning/Signing/Signing+ECKey.swift index dbca56000db..ce005dde8c7 100644 --- a/Sources/PackageCollectionsSigning/Signing/Signing+ECKey.swift +++ b/Sources/PackageCollectionsSigning/Signing/Signing+ECKey.swift @@ -2,7 +2,7 @@ // // This source file is part of the Swift open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021-2023 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See http://swift.org/LICENSE.txt for license information @@ -12,7 +12,12 @@ import struct Foundation.Data +// FIXME: @_implementationOnly fails on Linux +#if !os(Linux) +@_implementationOnly import Crypto +#else import Crypto +#endif // MARK: - MessageSigner and MessageValidator conformance diff --git a/Sources/PackageSigning/CMakeLists.txt b/Sources/PackageSigning/CMakeLists.txt index 8344cb8b41c..92ec05d1dea 100644 --- a/Sources/PackageSigning/CMakeLists.txt +++ b/Sources/PackageSigning/CMakeLists.txt @@ -15,7 +15,7 @@ add_library(PackageSigning STATIC target_link_libraries(PackageSigning PUBLIC $<$>:Foundation> Basics - # Crypto ## TODO: uncomment once we resolve build problems + Crypto PackageModel TSCBasic TSCUtility) diff --git a/Sources/PackageSigning/SignatureProvider.swift b/Sources/PackageSigning/SignatureProvider.swift index a5860d151aa..a9ad6b6fdea 100644 --- a/Sources/PackageSigning/SignatureProvider.swift +++ b/Sources/PackageSigning/SignatureProvider.swift @@ -14,11 +14,15 @@ import struct Foundation.Data #if os(macOS) import Security -import CryptoKit // TODO: remove when we can import Crypto #endif import Basics -//import Crypto +// FIXME: @_implementationOnly fails on Linux +#if !os(Linux) +@_implementationOnly import Crypto +#else +import Crypto +#endif public enum SignatureProvider { public static func sign( diff --git a/Sources/PackageSigning/SigningIdentity.swift b/Sources/PackageSigning/SigningIdentity.swift index bbd3bb9c915..c855b41dda3 100644 --- a/Sources/PackageSigning/SigningIdentity.swift +++ b/Sources/PackageSigning/SigningIdentity.swift @@ -14,11 +14,15 @@ import struct Foundation.Data #if os(macOS) import Security -import CryptoKit // TODO: remove when we can import Crypto #endif import Basics -//import Crypto +// FIXME: @_implementationOnly fails on Linux +#if !os(Linux) +@_implementationOnly import Crypto +#else +import Crypto +#endif public protocol SigningIdentity { // TODO: change type to Certificate diff --git a/Utilities/Docker/docker-compose.yaml b/Utilities/Docker/docker-compose.yaml index c2ef5f721a3..6d1d0de820d 100644 --- a/Utilities/Docker/docker-compose.yaml +++ b/Utilities/Docker/docker-compose.yaml @@ -1,6 +1,6 @@ # This source file is part of the Swift open source project # -# Copyright (c) 2021 Apple Inc. and the Swift project authors +# Copyright (c) 2021-2023 Apple Inc. and the Swift project authors # Licensed under Apache License v2.0 with Runtime Library Exception # # See http://swift.org/LICENSE.txt for license information @@ -36,6 +36,7 @@ services: - ../../../swift-tools-support-core:/code/swift-tools-support-core:z - ../../../yams:/code/yams:z - ../../../swift-argument-parser:/code/swift-argument-parser:z + - ../../../swift-crypto:/code/swift-crypto:z - ../../../swift-driver:/code/swift-driver:z - ../../../swift-llbuild:/code/llbuild:z - ../../../swift-system:/code/swift-system:z diff --git a/Utilities/bootstrap b/Utilities/bootstrap index 746c05ab1a0..e2ddfab1bae 100755 --- a/Utilities/bootstrap +++ b/Utilities/bootstrap @@ -4,7 +4,7 @@ """ This source file is part of the Swift open source project // -// Copyright (c) 2014-2021 Apple Inc. and the Swift project authors +// Copyright (c) 2014-2023 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See http://swift.org/LICENSE.txt for license information @@ -184,6 +184,7 @@ def parse_global_args(args): args.source_dirs["tsc"] = os.path.join(args.project_root, "..", "swift-tools-support-core") args.source_dirs["yams"] = os.path.join(args.project_root, "..", "yams") args.source_dirs["swift-argument-parser"] = os.path.join(args.project_root, "..", "swift-argument-parser") + args.source_dirs["swift-crypto"] = os.path.join(args.project_root, "..", "swift-crypto") args.source_dirs["swift-driver"] = os.path.join(args.project_root, "..", "swift-driver") args.source_dirs["swift-system"] = os.path.join(args.project_root, "..", "swift-system") args.source_dirs["swift-collections"] = os.path.join(args.project_root, "..", "swift-collections") @@ -351,6 +352,7 @@ def build(args): ] build_dependency(args, "swift-driver", swift_driver_cmake_flags) build_dependency(args, "swift-collections") + build_dependency(args, "swift-crypto") build_swiftpm_with_cmake(args) build_swiftpm_with_swiftpm(args,integrated_swift_driver=False) @@ -594,6 +596,7 @@ def build_swiftpm_with_cmake(args): get_llbuild_cmake_arg(args), "-DTSC_DIR=" + os.path.join(args.build_dirs["tsc"], "cmake/modules"), "-DArgumentParser_DIR=" + os.path.join(args.build_dirs["swift-argument-parser"], "cmake/modules"), + "-DSwiftCrypto_DIR=" + os.path.join(args.build_dirs["swift-crypto"], "cmake/modules"), "-DSwiftDriver_DIR=" + os.path.join(args.build_dirs["swift-driver"], "cmake/modules"), "-DSwiftSystem_DIR=" + os.path.join(args.build_dirs["swift-system"], "cmake/modules"), "-DSwiftCollections_DIR=" + os.path.join(args.build_dirs["swift-collections"], "cmake/modules"), @@ -611,6 +614,7 @@ def build_swiftpm_with_cmake(args): if platform.system() == "Darwin": add_rpath_for_cmake_build(args, os.path.join(args.build_dirs["yams"], "lib")) 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-crypto"], "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-system"], "lib")) 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): os.path.join(args.build_dirs["llbuild"], "lib"), os.path.join(args.build_dirs["yams"], "lib"), os.path.join(args.build_dirs["swift-argument-parser"], "lib"), + os.path.join(args.build_dirs["swift-crypto"], "lib"), os.path.join(args.build_dirs["swift-driver"], "lib"), os.path.join(args.build_dirs["swift-system"], "lib"), os.path.join(args.build_dirs["swift-collections"], "lib"),