@@ -444,6 +444,8 @@ def hack_props(
444
444
suffix = b"-x64"
445
445
elif arch == "win32" :
446
446
suffix = b""
447
+ elif arch == "arm64" :
448
+ suffix = b""
447
449
else :
448
450
raise Exception ("unhandled architecture: %s" % arch )
449
451
@@ -708,9 +710,11 @@ def build_openssl_for_arch(
708
710
elif arch == "amd64" :
709
711
configure = "VC-WIN64A"
710
712
prefix = "64"
713
+ elif arch == "arm64" :
714
+ configure = "VC-WIN64-ARM"
715
+ prefix = "arm64"
711
716
else :
712
- print ("invalid architecture: %s" % arch )
713
- sys .exit (1 )
717
+ raise Exception ("unhandled architecture: %s" % arch )
714
718
715
719
# The official CPython OpenSSL builds hack ms/uplink.c to change the
716
720
# ``GetModuleHandle(NULL)`` invocation to load things from _ssl.pyd
@@ -758,6 +762,12 @@ def build_openssl_for_arch(
758
762
log ("copying %s to %s" % (source , dest ))
759
763
shutil .copyfile (source , dest )
760
764
765
+ # Copy `applink.c` to the include directory.
766
+ source_applink = source_root / "ms" / "applink.c"
767
+ dest_applink = install_root / "include" / "openssl" / "applink.c"
768
+ log ("copying %s to %s" % (source_applink , dest_applink ))
769
+ shutil .copyfile (source_applink , dest_applink )
770
+
761
771
762
772
def build_openssl (
763
773
entry : str ,
@@ -779,6 +789,7 @@ def build_openssl(
779
789
780
790
root_32 = td / "x86"
781
791
root_64 = td / "x64"
792
+ root_arm64 = td / "arm64"
782
793
783
794
if arch == "x86" :
784
795
root_32 .mkdir ()
@@ -802,13 +813,28 @@ def build_openssl(
802
813
root_64 ,
803
814
jom_archive = jom_archive ,
804
815
)
816
+ elif arch == "arm64" :
817
+ root_arm64 .mkdir ()
818
+ build_openssl_for_arch (
819
+ perl_path ,
820
+ "arm64" ,
821
+ openssl_archive ,
822
+ openssl_version ,
823
+ nasm_archive ,
824
+ root_arm64 ,
825
+ jom_archive = jom_archive ,
826
+ )
805
827
else :
806
- raise ValueError ("unhandled arch : %s" % arch )
828
+ raise Exception ("unhandled architecture : %s" % arch )
807
829
808
830
install = td / "out"
809
831
810
832
if arch == "x86" :
811
833
shutil .copytree (root_32 / "install" / "32" , install / "openssl" / "win32" )
834
+ elif arch == "arm64" :
835
+ shutil .copytree (
836
+ root_arm64 / "install" / "arm64" , install / "openssl" / "arm64"
837
+ )
812
838
else :
813
839
shutil .copytree (root_64 / "install" / "64" , install / "openssl" / "amd64" )
814
840
@@ -879,9 +905,14 @@ def build_libffi(
879
905
if arch == "x86" :
880
906
args .append ("-x86" )
881
907
artifacts_path = ffi_source_path / "i686-pc-cygwin"
882
- else :
908
+ elif arch == "arm64" :
909
+ args .append ("-arm64" )
910
+ artifacts_path = ffi_source_path / "aarch64-w64-cygwin"
911
+ elif arch == "amd64" :
883
912
args .append ("-x64" )
884
913
artifacts_path = ffi_source_path / "x86_64-w64-cygwin"
914
+ else :
915
+ raise Exception ("unhandled architecture: %s" % arch )
885
916
886
917
subprocess .run (args , env = env , check = True )
887
918
@@ -1259,8 +1290,11 @@ def build_cpython(
1259
1290
elif arch == "x86" :
1260
1291
build_platform = "win32"
1261
1292
build_directory = "win32"
1293
+ elif arch == "arm64" :
1294
+ build_platform = "arm64"
1295
+ build_directory = "arm64"
1262
1296
else :
1263
- raise ValueError ("unhandled arch : %s" % arch )
1297
+ raise Exception ("unhandled architecture : %s" % arch )
1264
1298
1265
1299
tempdir_opts = (
1266
1300
{"ignore_cleanup_errors" : True } if sys .version_info >= (3 , 12 ) else {}
@@ -1293,7 +1327,7 @@ def build_cpython(
1293
1327
1294
1328
# We need all the OpenSSL library files in the same directory to appease
1295
1329
# install rules.
1296
- openssl_arch = {"amd64" : "amd64" , "x86" : "win32" }[arch ]
1330
+ openssl_arch = {"amd64" : "amd64" , "x86" : "win32" , "arm64" : "arm64" }[arch ]
1297
1331
openssl_root = td / "openssl" / openssl_arch
1298
1332
openssl_bin_path = openssl_root / "bin"
1299
1333
openssl_lib_path = openssl_root / "lib"
@@ -1749,9 +1783,14 @@ def main() -> None:
1749
1783
if os .environ .get ("Platform" ) == "x86" :
1750
1784
target_triple = "i686-pc-windows-msvc"
1751
1785
arch = "x86"
1752
- else :
1786
+ elif os .environ .get ("Platform" ) == "arm64" :
1787
+ target_triple = "aarch64-pc-windows-msvc"
1788
+ arch = "arm64"
1789
+ elif os .environ .get ("Platform" ) == "x64" :
1753
1790
target_triple = "x86_64-pc-windows-msvc"
1754
1791
arch = "amd64"
1792
+ else :
1793
+ raise Exception ("unhandled architecture: %s" % os .environ .get ("Platform" ))
1755
1794
1756
1795
# TODO need better dependency checking.
1757
1796
0 commit comments