Compare commits

..
3 Commits
Author SHA1 Message Date
Saleem Abdulrasool 80a6e3edc1 build: add ARM64 spelling for Windows (#148)
Windows uses `ARM64` for the `CMAKE_SYSTEM_PROCESSOR` which does not
match the existing spellings.  Add the special case for Darwin while in
the area.
2023-03-02 12:13:00 -08:00
Andrew BarbaandMax Desiatov a1b800581e Support SwiftWasm (#145)
Co-authored-by: Max Desiatov <m_desiatov@apple.com>
2023-02-09 06:04:16 -08:00
Yim Lee 935c74be2f Set up CMake build for _CryptoExtras (#144)
* Set up CMake build for _CryptoExtras

* Add CMakeLists.txt to exclude list
2023-01-26 10:51:20 +00:00
6 changed files with 85 additions and 10 deletions

No files matched your search

+26 -2
View File
@@ -3,7 +3,7 @@
//
// This source file is part of the SwiftCrypto open source project
//
// Copyright (c) 2019 Apple Inc. and the SwiftCrypto project authors
// Copyright (c) 2019-2023 Apple Inc. and the SwiftCrypto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
@@ -47,6 +47,7 @@ if development {
Platform.linux,
Platform.android,
Platform.windows,
Platform.wasi,
]
dependencies = [
.target(name: "CCryptoBoringSSL", condition: .when(platforms: platforms)),
@@ -78,6 +79,13 @@ let package = Package(
"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: [
/*
@@ -86,6 +94,11 @@ let package = Package(
* only. Unconditionally define it instead.
*/
.define("WIN32_LEAN_AND_MEAN"),
/*
* 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(
@@ -107,7 +120,18 @@ let package = Package(
],
swiftSettings: swiftSettings
),
.target(name: "_CryptoExtras", dependencies: ["CCryptoBoringSSL", "CCryptoBoringSSLShims", "CryptoBoringWrapper", "Crypto"]),
.target(
name: "_CryptoExtras",
dependencies: [
"CCryptoBoringSSL",
"CCryptoBoringSSLShims",
"CryptoBoringWrapper",
"Crypto"
],
exclude: [
"CMakeLists.txt",
]
),
.target(
name: "CryptoBoringWrapper",
dependencies: [
+2 -1
View File
@@ -2,7 +2,7 @@
##
## This source file is part of the SwiftCrypto open source project
##
## Copyright (c) 2021 Apple Inc. and the SwiftCrypto project authors
## Copyright (c) 2021-2023 Apple Inc. and the SwiftCrypto project authors
## Licensed under Apache License v2.0
##
## See LICENSE.txt for license information
@@ -16,3 +16,4 @@ add_subdirectory(CCryptoBoringSSL)
add_subdirectory(CCryptoBoringSSLShims)
add_subdirectory(CryptoBoringWrapper)
add_subdirectory(Crypto)
add_subdirectory(_CryptoExtras)
+46
View File
@@ -0,0 +1,46 @@
##===----------------------------------------------------------------------===##
##
## This source file is part of the SwiftCrypto open source project
##
## Copyright (c) 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
##
##===----------------------------------------------------------------------===##
add_library(_CryptoExtras
"AES/AES_GCM_SIV.swift"
"AES/Block Function.swift"
"AES/BoringSSL/AES_GCM_SIV_boring.swift"
"RSA/RSA.swift"
"RSA/RSA_boring.swift"
"RSA/RSA_security.swift"
"Util/BoringSSLHelpers.swift"
"Util/CryptoKitErrors_boring.swift"
"Util/DigestType.swift"
"Util/Error.swift"
"Util/PEMDocument.swift"
"Util/RandomBytes.swift")
target_include_directories(_CryptoExtras PRIVATE
$<TARGET_PROPERTY:CCryptoBoringSSL,INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:CCryptoBoringSSLShims,INCLUDE_DIRECTORIES>)
target_link_libraries(_CryptoExtras PUBLIC
$<$<NOT:$<PLATFORM_ID:Darwin>>:Foundation>
Crypto
CryptoBoringWrapper
CCryptoBoringSSL
CCryptoBoringSSLShims)
target_link_options(_CryptoExtras PRIVATE
"$<$<PLATFORM_ID:Darwin>:SHELL:-Xlinker -framework -Xlinker Security>")
set_target_properties(_CryptoExtras PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
set_property(GLOBAL APPEND PROPERTY SWIFT_CRYPTO_EXPORTS _CryptoExtras)
+6 -4
View File
@@ -22,10 +22,12 @@
function(get_swift_host_arch result_var_name)
if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64")
set("${result_var_name}" "x86_64" PARENT_SCOPE)
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64")
set("${result_var_name}" "aarch64" PARENT_SCOPE)
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "arm64")
set("${result_var_name}" "aarch64" PARENT_SCOPE)
elseif("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "AArch64|aarch64|arm64|ARM64")
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
set("${result_var_name}" "arm64" PARENT_SCOPE)
else()
set("${result_var_name}" "aarch64" PARENT_SCOPE)
endif()
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "ppc64")
set("${result_var_name}" "powerpc64" PARENT_SCOPE)
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "ppc64le")
+2 -2
View File
@@ -3,7 +3,7 @@
##
## This source file is part of the SwiftCrypto open source project
##
## Copyright (c) 2019-2021 Apple Inc. and the SwiftCrypto project authors
## Copyright (c) 2019-2023 Apple Inc. and the SwiftCrypto project authors
## Licensed under Apache License v2.0
##
## See LICENSE.txt for license information
@@ -17,7 +17,7 @@ set -eu
here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
function replace_acceptable_years() {
# this needs to replace all acceptable forms with 'YEARS'
sed -e 's/20[12][890]-20[12][1290]/YEARS/' -e 's/20[12][90123]/YEARS/'
sed -e 's/20[12][8901]-20[12][90123]/YEARS/' -e 's/20[12][90123]/YEARS/'
}
printf "=> Checking for unacceptable language... "
+3 -1
View File
@@ -3,7 +3,7 @@
##
## This source file is part of the SwiftCrypto open source project
##
## Copyright (c) 2021 Apple Inc. and the SwiftCrypto project authors
## Copyright (c) 2021-2023 Apple Inc. and the SwiftCrypto project authors
## Licensed under Apache License v2.0
##
## See LICENSE.txt for license information
@@ -80,6 +80,8 @@ function update_cmakelists_assembly() {
update_cmakelists_source "CCryptoBoringSSL" "*.c"
update_cmakelists_source "CCryptoBoringSSLShims" "*.c"
update_cmakelists_source "CryptoBoringWrapper" "*.swift"
update_cmakelists_source "Crypto" "*.swift"
update_cmakelists_source "_CryptoExtras" "*.swift"
update_cmakelists_assembly "CCryptoBoringSSL"