2022-09-29 00:25:21 +08:00
|
|
|
// swift-tools-version:5.5
|
2019-12-07 00:55:35 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This source file is part of the SwiftCrypto open source project
|
|
|
|
//
|
2023-01-26 18:51:20 +08:00
|
|
|
// Copyright (c) 2019-2023 Apple Inc. and the SwiftCrypto project authors
|
2019-12-07 00:55:35 +08:00
|
|
|
// Licensed under Apache License v2.0
|
|
|
|
//
|
|
|
|
// See LICENSE.txt for license information
|
2020-02-06 19:28:29 +08:00
|
|
|
// See CONTRIBUTORS.md for the list of SwiftCrypto project authors
|
2019-12-07 00:55:35 +08:00
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
// This package contains a vendored copy of BoringSSL. For ease of tracking
|
|
|
|
// down problems with the copy of BoringSSL in use, we include a copy of the
|
|
|
|
// commit hash of the revision of BoringSSL included in the given release.
|
|
|
|
// This is also reproduced in a file called hash.txt in the
|
|
|
|
// Sources/CCryptoBoringSSL directory. The source repository is at
|
|
|
|
// https://boringssl.googlesource.com/boringssl.
|
|
|
|
//
|
2023-01-20 01:30:15 +08:00
|
|
|
// BoringSSL Commit: 45b8d7bbd771cbf7e116db2ba1f1cc7af959497e
|
2019-12-07 00:55:35 +08:00
|
|
|
|
|
|
|
import PackageDescription
|
|
|
|
|
2022-04-20 18:47:19 +08:00
|
|
|
// To develop this on Apple platforms, set this to true
|
|
|
|
let development = false
|
|
|
|
|
|
|
|
let swiftSettings: [SwiftSetting]
|
|
|
|
let dependencies: [Target.Dependency]
|
|
|
|
if development {
|
|
|
|
swiftSettings = [
|
|
|
|
.define("CRYPTO_IN_SWIFTPM"),
|
|
|
|
.define("CRYPTO_IN_SWIFTPM_FORCE_BUILD_API"),
|
|
|
|
]
|
|
|
|
dependencies = [
|
|
|
|
"CCryptoBoringSSL",
|
2022-10-14 16:50:36 +08:00
|
|
|
"CCryptoBoringSSLShims",
|
|
|
|
"CryptoBoringWrapper"
|
2022-04-20 18:47:19 +08:00
|
|
|
]
|
|
|
|
} else {
|
|
|
|
swiftSettings = [
|
|
|
|
.define("CRYPTO_IN_SWIFTPM"),
|
|
|
|
]
|
|
|
|
let platforms: [Platform] = [
|
|
|
|
Platform.linux,
|
|
|
|
Platform.android,
|
|
|
|
Platform.windows,
|
2023-02-09 22:04:16 +08:00
|
|
|
Platform.wasi,
|
2022-04-20 18:47:19 +08:00
|
|
|
]
|
|
|
|
dependencies = [
|
|
|
|
.target(name: "CCryptoBoringSSL", condition: .when(platforms: platforms)),
|
2022-10-14 16:50:36 +08:00
|
|
|
.target(name: "CCryptoBoringSSLShims", condition: .when(platforms: platforms)),
|
|
|
|
.target(name: "CryptoBoringWrapper", condition: .when(platforms: platforms))
|
2022-04-20 18:47:19 +08:00
|
|
|
]
|
|
|
|
}
|
2019-12-07 00:55:35 +08:00
|
|
|
|
|
|
|
let package = Package(
|
|
|
|
name: "swift-crypto",
|
|
|
|
platforms: [
|
|
|
|
.macOS(.v10_15),
|
|
|
|
.iOS(.v13),
|
|
|
|
.watchOS(.v6),
|
|
|
|
.tvOS(.v13),
|
|
|
|
],
|
|
|
|
products: [
|
|
|
|
.library(name: "Crypto", targets: ["Crypto"]),
|
2021-04-23 22:01:56 +08:00
|
|
|
.library(name: "_CryptoExtras", targets: ["_CryptoExtras"]),
|
2019-12-07 00:55:35 +08:00
|
|
|
/* This target is used only for symbol mangling. It's added and removed automatically because it emits build warnings. MANGLE_START
|
2019-12-20 04:53:36 +08:00
|
|
|
.library(name: "CCryptoBoringSSL", type: .static, targets: ["CCryptoBoringSSL"]),
|
|
|
|
MANGLE_END */
|
2019-12-07 00:55:35 +08:00
|
|
|
],
|
|
|
|
dependencies: [],
|
|
|
|
targets: [
|
2020-12-02 19:09:40 +08:00
|
|
|
.target(
|
2022-04-20 18:47:19 +08:00
|
|
|
name: "CCryptoBoringSSL",
|
|
|
|
exclude: [
|
|
|
|
"hash.txt",
|
|
|
|
"include/boringssl_prefix_symbols_nasm.inc",
|
|
|
|
"CMakeLists.txt",
|
2023-02-09 22:04:16 +08:00
|
|
|
/*
|
|
|
|
* These files are excluded to support WASI libc which doesn't provide <netdb.h>.
|
|
|
|
* This is safe for all platforms as we do not rely on networking features.
|
|
|
|
*/
|
|
|
|
"crypto/bio/connect.c",
|
|
|
|
"crypto/bio/socket_helper.c",
|
|
|
|
"crypto/bio/socket.c"
|
2022-04-20 18:47:19 +08:00
|
|
|
],
|
|
|
|
cSettings: [
|
|
|
|
/*
|
|
|
|
* This define is required on Windows, but because we need older
|
|
|
|
* versions of SPM, we cannot conditionally define this on Windows
|
|
|
|
* only. Unconditionally define it instead.
|
|
|
|
*/
|
|
|
|
.define("WIN32_LEAN_AND_MEAN"),
|
2023-02-09 22:04:16 +08:00
|
|
|
/*
|
|
|
|
* These defines are required on Wasm/WASI, to disable use of pthread.
|
|
|
|
*/
|
|
|
|
.define("OPENSSL_NO_THREADS_CORRUPT_MEMORY_AND_LEAK_SECRETS_IF_THREADED", .when(platforms: [Platform.wasi])),
|
|
|
|
.define("OPENSSL_NO_ASM", .when(platforms: [Platform.wasi])),
|
2022-04-20 18:47:19 +08:00
|
|
|
]
|
|
|
|
),
|
|
|
|
.target(
|
|
|
|
name: "CCryptoBoringSSLShims",
|
|
|
|
dependencies: ["CCryptoBoringSSL"],
|
|
|
|
exclude: [
|
|
|
|
"CMakeLists.txt"
|
|
|
|
]
|
|
|
|
),
|
|
|
|
.target(
|
|
|
|
name: "Crypto",
|
|
|
|
dependencies: dependencies,
|
|
|
|
exclude: [
|
|
|
|
"CMakeLists.txt",
|
|
|
|
"AEADs/Nonces.swift.gyb",
|
|
|
|
"Digests/Digests.swift.gyb",
|
|
|
|
"Key Agreement/ECDH.swift.gyb",
|
|
|
|
"Signatures/ECDSA.swift.gyb",
|
|
|
|
],
|
|
|
|
swiftSettings: swiftSettings
|
2020-12-02 19:09:40 +08:00
|
|
|
),
|
2023-01-26 18:51:20 +08:00
|
|
|
.target(
|
|
|
|
name: "_CryptoExtras",
|
|
|
|
dependencies: [
|
|
|
|
"CCryptoBoringSSL",
|
|
|
|
"CCryptoBoringSSLShims",
|
|
|
|
"CryptoBoringWrapper",
|
|
|
|
"Crypto"
|
|
|
|
],
|
|
|
|
exclude: [
|
|
|
|
"CMakeLists.txt",
|
|
|
|
]
|
|
|
|
),
|
2022-10-14 16:50:36 +08:00
|
|
|
.target(
|
|
|
|
name: "CryptoBoringWrapper",
|
|
|
|
dependencies: [
|
|
|
|
"CCryptoBoringSSL",
|
|
|
|
"CCryptoBoringSSLShims"
|
|
|
|
],
|
|
|
|
exclude: [
|
|
|
|
"CMakeLists.txt",
|
|
|
|
]
|
|
|
|
),
|
2022-04-20 18:47:19 +08:00
|
|
|
.executableTarget(name: "crypto-shasum", dependencies: ["Crypto"]),
|
2019-12-07 00:55:35 +08:00
|
|
|
.testTarget(name: "CryptoTests", dependencies: ["Crypto"], swiftSettings: swiftSettings),
|
2021-04-23 22:01:56 +08:00
|
|
|
.testTarget(name: "_CryptoExtrasTests", dependencies: ["_CryptoExtras"]),
|
2019-12-07 00:55:35 +08:00
|
|
|
],
|
|
|
|
cxxLanguageStandard: .cxx11
|
|
|
|
)
|