forked from apple/swift-crypto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPackage.swift
159 lines (154 loc) · 5.56 KB
/
Package.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
// swift-tools-version:5.7
//===----------------------------------------------------------------------===//
//
// This source file is part of the SwiftCrypto open source project
//
// Copyright (c) 2019-2023 Apple Inc. and the SwiftCrypto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.md for the list of SwiftCrypto project authors
//
// 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.
//
// BoringSSL Commit: 7a813621dac6878ab53b6ed7392939a8982226e8
import PackageDescription
// 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",
"CCryptoBoringSSLShims",
"CryptoBoringWrapper"
]
} else {
let platforms: [Platform] = [
Platform.linux,
Platform.android,
Platform.windows,
Platform.wasi,
]
swiftSettings = [
.define("CRYPTO_IN_SWIFTPM"),
.define("CRYPTO_IN_SWIFTPM_FORCE_BUILD_API", .when(platforms: platforms)),
]
dependencies = [
.target(name: "CCryptoBoringSSL", condition: .when(platforms: platforms)),
.target(name: "CCryptoBoringSSLShims", condition: .when(platforms: platforms)),
.target(name: "CryptoBoringWrapper", condition: .when(platforms: platforms))
]
}
let package = Package(
name: "swift-crypto",
platforms: [
.macOS(.v10_15),
.iOS(.v13),
.watchOS(.v6),
.tvOS(.v13),
],
products: [
.library(name: "Crypto", targets: ["Crypto"]),
.library(name: "CCryptoBoringSSL", targets: ["CCryptoBoringSSL"]),
.library(name: "_CryptoExtras", targets: ["_CryptoExtras"]),
/* This target is used only for symbol mangling. It's added and removed automatically because it emits build warnings. MANGLE_START
.library(name: "CCryptoBoringSSL", type: .static, targets: ["CCryptoBoringSSL"]),
MANGLE_END */
],
dependencies: [],
targets: [
.target(
name: "CCryptoBoringSSL",
exclude: [
"hash.txt",
"include/boringssl_prefix_symbols_nasm.inc",
"CMakeLists.txt",
/*
* 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"
],
cSettings: [
// These defines come from BoringSSL's build system
.define("_HAS_EXCEPTIONS", to: "0", .when(platforms: [Platform.windows])),
.define("WIN32_LEAN_AND_MEAN", .when(platforms: [Platform.windows])),
.define("NOMINMAX", .when(platforms: [Platform.windows])),
.define("_CRT_SECURE_NO_WARNINGS", .when(platforms: [Platform.windows])),
/*
* 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])),
]
),
.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
),
.target(
name: "_CryptoExtras",
dependencies: [
"CCryptoBoringSSL",
"CCryptoBoringSSLShims",
"CryptoBoringWrapper",
"Crypto"
],
exclude: [
"CMakeLists.txt",
],
swiftSettings: swiftSettings
),
.target(
name: "CryptoBoringWrapper",
dependencies: [
"CCryptoBoringSSL",
"CCryptoBoringSSLShims"
],
exclude: [
"CMakeLists.txt",
]
),
.executableTarget(name: "crypto-shasum", dependencies: ["Crypto"]),
.testTarget(
name: "CryptoTests",
dependencies: ["Crypto"],
resources: [
.copy("HPKE/hpke-test-vectors.json"),
],
swiftSettings: swiftSettings
),
.testTarget(name: "_CryptoExtrasTests", dependencies: ["_CryptoExtras"]),
],
cxxLanguageStandard: .cxx11
)