Skip to content

[DNM] Test adding swift-crypto back to cmake #6218

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

Closed
wants to merge 1 commit into from
Closed
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
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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($<$<COMPILE_LANGUAGE:Swift>:-DCRYPTO_v2>)
else()
message(WARNING "SwiftCrypto not found, package collections and package signing will be unavailable")
endif()
endif()

find_package(dispatch QUIET)
Expand Down
3 changes: 1 addition & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
Expand Down
7 changes: 6 additions & 1 deletion Sources/PackageCollectionsSigning/Key/Key+EC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion Sources/PackageSigning/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ add_library(PackageSigning STATIC
target_link_libraries(PackageSigning PUBLIC
$<$<NOT:$<PLATFORM_ID:Darwin>>:Foundation>
Basics
# Crypto ## TODO: uncomment once we resolve build problems
Crypto
PackageModel
TSCBasic
TSCUtility)
Expand Down
8 changes: 6 additions & 2 deletions Sources/PackageSigning/SignatureProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
8 changes: 6 additions & 2 deletions Sources/PackageSigning/SigningIdentity.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion Utilities/Docker/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion Utilities/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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"),
Expand All @@ -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"))
Expand Down Expand Up @@ -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"),
Expand Down