Skip to content

Commit bfcd792

Browse files
compnerdyim-lee
authored andcommitted
build: build macOS against BoringSSL
Make the BoringSSL based build for macOS complete enough. We can now build a shared library version of SwiftCrypto on macOS without CryptoKit.
1 parent 8c58c4c commit bfcd792

File tree

3 files changed

+29
-17
lines changed

3 files changed

+29
-17
lines changed

CMakeLists.txt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
cmake_minimum_required(VERSION 3.15.1)
1212

1313
project(SwiftCrypto
14-
LANGUAGES C Swift)
14+
LANGUAGES ASM C Swift)
1515

1616
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
1717

@@ -35,12 +35,5 @@ if(BUILD_SHARED_LIBS)
3535
set(CMAKE_POSITION_INDEPENDENT_CODE YES)
3636
endif()
3737

38-
if(APPLE)
39-
find_library(CRYPTO_KIT CryptoKit)
40-
if(NOT CRYPTO_KIT)
41-
message(FATAL_ERROR "CryptoKit not found")
42-
endif()
43-
endif()
44-
4538
add_subdirectory(Sources)
4639
add_subdirectory(cmake/modules)

Sources/CCryptoBoringSSL/CMakeLists.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,29 @@ add_library(CCryptoBoringSSL STATIC
310310
crypto/x509v3/v3_purp.c
311311
crypto/x509v3/v3_skey.c
312312
crypto/x509v3/v3_utl.c)
313+
if(APPLE)
314+
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64")
315+
target_sources(CCryptoBoringSSL PRIVATE
316+
crypto/chacha/chacha-x86_64.mac.x86_64.S
317+
crypto/cipher_extra/aes128gcmsiv-x86_64.mac.x86_64.S
318+
crypto/cipher_extra/chacha20_poly1305_x86_64.mac.x86_64.S
319+
crypto/fipsmodule/aesni-gcm-x86_64.mac.x86_64.S
320+
crypto/fipsmodule/aesni-x86_64.mac.x86_64.S
321+
crypto/fipsmodule/ghash-ssse3-x86_64.mac.x86_64.S
322+
crypto/fipsmodule/ghash-x86_64.mac.x86_64.S
323+
crypto/fipsmodule/md5-x86_64.mac.x86_64.S
324+
crypto/fipsmodule/p256-x86_64-asm.mac.x86_64.S
325+
crypto/fipsmodule/p256_beeu-x86_64-asm.mac.x86_64.S
326+
crypto/fipsmodule/rdrand-x86_64.mac.x86_64.S
327+
crypto/fipsmodule/rsaz-avx2.mac.x86_64.S
328+
crypto/fipsmodule/sha1-x86_64.mac.x86_64.S
329+
crypto/fipsmodule/sha256-x86_64.mac.x86_64.S
330+
crypto/fipsmodule/sha512-x86_64.mac.x86_64.S
331+
crypto/fipsmodule/vpaes-x86_64.mac.x86_64.S
332+
crypto/fipsmodule/x86_64-mont.mac.x86_64.S
333+
crypto/fipsmodule/x86_64-mont5.mac.x86_64.S)
334+
endif()
335+
endif()
313336

314337
target_include_directories(CCryptoBoringSSL PUBLIC
315338
include)

Sources/Crypto/CMakeLists.txt

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,14 @@ add_library(Crypto
7070
Util/SecureBytes.swift
7171
Util/Zeroization.swift)
7272

73-
target_link_libraries(Crypto PUBLIC
74-
CCryptoBoringSSL
75-
CCryptoBoringSSLShims)
76-
77-
if(APPLE AND CRYPTO_KIT)
78-
target_link_libraries(Crypto PRIVATE
79-
${CRYPTO_KIT})
80-
endif()
81-
73+
target_compile_definitions(Crypto PRIVATE
74+
CRYPTO_IN_SWIFTPM_FORCE_BUILD_API)
8275
target_include_directories(Crypto PRIVATE
8376
$<TARGET_PROPERTY:CCryptoBoringSSL,INCLUDE_DIRECTORIES>
8477
$<TARGET_PROPERTY:CCryptoBoringSSLShims,INCLUDE_DIRECTORIES>)
78+
target_link_libraries(Crypto PUBLIC
79+
CCryptoBoringSSL
80+
CCryptoBoringSSLShims)
8581
set_target_properties(Crypto PROPERTIES
8682
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
8783

0 commit comments

Comments
 (0)