@@ -55,11 +55,7 @@ def run_cmd(args):
55
55
56
56
57
57
def copy_tree (src , dst ):
58
- if sys .version_info >= (3 , 8 ):
59
- shutil .copytree (src , dst , dirs_exist_ok = True )
60
- else :
61
- shutil .rmtree (dst , ignore_errors = True )
62
- shutil .copytree (src , dst )
58
+ shutil .copytree (src , dst , dirs_exist_ok = True )
63
59
64
60
65
61
def is_macos_universal2 ():
@@ -144,6 +140,16 @@ def using_system_libs():
144
140
or not os .path .exists (os .path .join (PROJECT_DIR , 'crt' , 'aws-c-common' , 'CMakeLists.txt' )))
145
141
146
142
143
+ def using_libcrypto ():
144
+ """If true, libcrypto is used, even on win/mac."""
145
+ if sys .platform == 'darwin' or sys .platform == 'win32' :
146
+ # use libcrypto on mac/win to support ed25519, unless its disabled via env-var
147
+ return not os .getenv ('AWS_CRT_BUILD_DISABLE_LIBCRYPTO_USE_FOR_ED25519_EVERYWHERE' ) == '1'
148
+ else :
149
+ # on Unix we always use libcrypto
150
+ return True
151
+
152
+
147
153
def using_system_libcrypto ():
148
154
"""If true, don't build AWS-LC. Use the libcrypto that's already on the system."""
149
155
return using_system_libs () or os .getenv ('AWS_CRT_BUILD_USE_SYSTEM_LIBCRYPTO' ) == '1'
@@ -154,11 +160,6 @@ def forcing_static_libs():
154
160
return os .getenv ('AWS_CRT_BUILD_FORCE_STATIC_LIBS' ) == '1'
155
161
156
162
157
- def disable_libcrypto_use_for_ed25519_everywhere ():
158
- """If true, libcrypto is not used on mac/win to support ed25519 and apis instead return not supported."""
159
- return os .getenv ('AWS_CRT_BUILD_DISABLE_LIBCRYPTO_USE_FOR_ED25519_EVERYWHERE' ) == '1'
160
-
161
-
162
163
class AwsLib :
163
164
def __init__ (self , name , extra_cmake_args = [], libname = None ):
164
165
self .name = name
@@ -170,7 +171,7 @@ def __init__(self, name, extra_cmake_args=[], libname=None):
170
171
# They're built along with the extension (unless using_system_libs() is True)
171
172
AWS_LIBS = []
172
173
173
- if not disable_libcrypto_use_for_ed25519_everywhere () or ( sys . platform != 'darwin' and sys . platform != 'win32' ):
174
+ if using_libcrypto ( ):
174
175
# aws-lc produces libcrypto.a
175
176
AWS_LIBS .append (AwsLib ('aws-lc' , libname = 'crypto' ))
176
177
@@ -223,10 +224,10 @@ def _build_dependencies_impl(self, build_dir, install_path, osx_arch=None):
223
224
f'-DCMAKE_BUILD_TYPE={ build_type } ' ,
224
225
])
225
226
226
- if using_system_libcrypto ():
227
- cmake_args .append ('-DUSE_OPENSSL=ON' )
227
+ if using_libcrypto ():
228
+ if using_system_libcrypto ():
229
+ cmake_args .append ('-DUSE_OPENSSL=ON' )
228
230
229
- if not disable_libcrypto_use_for_ed25519_everywhere ():
230
231
cmake_args .append ('-DAWS_USE_LIBCRYPTO_TO_SUPPORT_ED25519_EVERYWHERE=ON' )
231
232
232
233
if sys .platform == 'darwin' :
@@ -360,6 +361,19 @@ def awscrt_ext():
360
361
extra_link_args += ['-framework' , 'Security' ]
361
362
362
363
else : # unix
364
+ if forcing_static_libs ():
365
+ # linker will prefer shared libraries over static if it can find both.
366
+ # force linker to choose static variant by using
367
+ # "-l:libaws-c-common.a" syntax instead of just "-laws-c-common".
368
+ #
369
+ # This helps AWS developers creating Lambda applications from Brazil.
370
+ # In Brazil, both shared and static libs are available.
371
+ # But Lambda requires all shared libs to be explicitly packaged up.
372
+ # So it's simpler to link them in statically and have less runtime dependencies.
373
+ #
374
+ # Don't apply this trick to dependencies that are always on the OS (e.g. librt)
375
+ libraries = [':lib{}.a' .format (x ) for x in libraries ]
376
+
363
377
# OpenBSD doesn't have librt; functions are found in libc instead.
364
378
if not sys .platform .startswith ('openbsd' ):
365
379
libraries += ['rt' ]
@@ -386,20 +400,6 @@ def awscrt_ext():
386
400
# Do this even if using system libcrypto, since it could still be a static lib.
387
401
extra_link_args += ['-Wl,--exclude-libs,libcrypto.a' ]
388
402
389
- if not disable_libcrypto_use_for_ed25519_everywhere () or (sys .platform != 'darwin' and sys .platform != 'win32' ):
390
- if forcing_static_libs ():
391
- # linker will prefer shared libraries over static if it can find both.
392
- # force linker to choose static variant by using
393
- # "-l:libaws-c-common.a" syntax instead of just "-laws-c-common".
394
- #
395
- # This helps AWS developers creating Lambda applications from Brazil.
396
- # In Brazil, both shared and static libs are available.
397
- # But Lambda requires all shared libs to be explicitly packaged up.
398
- # So it's simpler to link them in statically and have less runtime dependencies.
399
- #
400
- # Don't apply this trick to dependencies that are always on the OS (e.g. librt)
401
- libraries = [':lib{}.a' .format (x ) for x in libraries ]
402
-
403
403
if sys .platform != 'win32' or distutils .ccompiler .get_default_compiler () != 'msvc' :
404
404
extra_compile_args += ['-Wno-strict-aliasing' , '-std=gnu99' ]
405
405
0 commit comments