Skip to content

Commit 004d4ea

Browse files
committed
Added support for flutter pub run webcrypto:setup on mac
1 parent 4a3a8bc commit 004d4ea

File tree

1 file changed

+33
-20
lines changed

1 file changed

+33
-20
lines changed

src/CMakeLists.txt

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ set(BORINGSSL_ROOT ../third_party/boringssl/)
3737
# - crypto_sources_linux_ppc64le
3838
# - crypto_sources_linux_x86
3939
# - crypto_sources_linux_x86_64
40+
# - crypto_sources_mac_x86
41+
# - crypto_sources_mac_x86_64
42+
# - crypto_sources_win_x86
43+
# - crypto_sources_win_x86_64
4044
include(
4145
../third_party/boringssl/sources.cmake
4246
)
@@ -47,40 +51,49 @@ add_definitions(-DOPENSSL_SMALL)
4751

4852
# Logic from CMakeLists.txt in BoringSSL
4953
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
50-
set(crypto_sources_ARCH ${crypto_sources_linux_x86_64})
54+
set(ARCH "x86_64")
5155
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "amd64")
52-
set(crypto_sources_ARCH ${crypto_sources_linux_x86_64})
56+
set(ARCH "x86_64")
5357
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "AMD64")
54-
# cmake reports AMD64 on Windows, but we might be building for 32-bit.
5558
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
56-
set(crypto_sources_ARCH ${crypto_sources_linux_x86_64})
59+
set(ARCH "x86_64")
5760
else()
58-
set(crypto_sources_ARCH ${crypto_sources_linux_x86})
61+
set(ARCH "x86")
5962
endif()
6063
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86")
61-
set(crypto_sources_ARCH ${crypto_sources_linux_x86})
64+
set(ARCH "x86")
6265
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i386")
63-
set(crypto_sources_ARCH ${crypto_sources_linux_x86})
66+
set(ARCH "x86")
6467
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i686")
65-
set(crypto_sources_ARCH ${crypto_sources_linux_x86})
68+
set(ARCH "x86")
6669
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")
67-
set(crypto_sources_ARCH ${crypto_sources_linux_aarch64})
70+
set(ARCH "aarch64")
6871
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm64")
69-
set(crypto_sources_ARCH ${crypto_sources_linux_aarch64})
70-
# Apple A12 Bionic chipset which is added in iPhone XS/XS Max/XR uses arm64e architecture.
72+
set(ARCH "aarch64")
7173
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm64e")
72-
set(crypto_sources_ARCH ${crypto_sources_linux_aarch64})
74+
set(ARCH "aarch64")
7375
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^arm*")
74-
set(crypto_sources_ARCH ${crypto_sources_linux_arm})
75-
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "mips")
76-
# Just to avoid the “unknown processor” error.
77-
set(crypto_sources_ARCH ${crypto_sources_linux_generic})
76+
set(ARCH "arm")
7877
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "ppc64le")
79-
set(crypto_sources_ARCH ${crypto_sources_linux_ppc64le})
78+
set(ARCH "ppc64le")
8079
else()
81-
# If we can't match an architecture, we just disable assembler optimizations
82-
set(crypto_sources_ARCH)
80+
set(ARCH "generic")
81+
endif()
82+
83+
# https://cmake.org/cmake/help/latest/variable/CMAKE_SYSTEM_NAME.html
84+
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
85+
set(PLATFORM "win")
86+
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
87+
set(PLATFORM "mac")
88+
else()
89+
# Assume we're on linux or similar platform
90+
set(PLATFORM "linux")
91+
endif()
92+
93+
# If there is no assembly files disable ASM and set empty sources list
94+
if(NOT DEFINED crypto_sources_${PLATFORM}_${ARCH})
8395
add_definitions(-DOPENSSL_NO_ASM)
96+
set(crypto_sources_${PLATFORM}_${ARCH})
8497
endif()
8598

8699
add_library(
@@ -93,7 +106,7 @@ add_library(
93106
../src/webcrypto.c
94107
../src/symbols.generated.c
95108
${crypto_sources}
96-
${crypto_sources_ARCH}
109+
${crypto_sources_${PLATFORM}_${ARCH}}
97110
)
98111

99112
target_include_directories(

0 commit comments

Comments
 (0)