@@ -438,6 +438,8 @@ def hack_props(
438
438
suffix = b"-x64"
439
439
elif arch == "win32" :
440
440
suffix = b""
441
+ elif arch == "arm64" :
442
+ suffix = b""
441
443
else :
442
444
raise Exception ("unhandled architecture: %s" % arch )
443
445
@@ -917,9 +919,11 @@ def build_openssl_for_arch(
917
919
elif arch == "amd64" :
918
920
configure = "VC-WIN64A"
919
921
prefix = "64"
922
+ elif arch == "arm64" :
923
+ configure = "VC-WIN64-ARM"
924
+ prefix = "arm64"
920
925
else :
921
- print ("invalid architecture: %s" % arch )
922
- sys .exit (1 )
926
+ raise Exception ("unhandled architecture: %s" % arch )
923
927
924
928
# The official CPython OpenSSL builds hack ms/uplink.c to change the
925
929
# ``GetModuleHandle(NULL)`` invocation to load things from _ssl.pyd
@@ -967,6 +971,12 @@ def build_openssl_for_arch(
967
971
log ("copying %s to %s" % (source , dest ))
968
972
shutil .copyfile (source , dest )
969
973
974
+ # Copy `applink.c` to the include directory.
975
+ source_applink = source_root / "ms" / "applink.c"
976
+ dest_applink = install_root / "include" / "openssl" / "applink.c"
977
+ log ("copying %s to %s" % (source_applink , dest_applink ))
978
+ shutil .copyfile (source_applink , dest_applink )
979
+
970
980
971
981
def build_openssl (
972
982
entry : str ,
@@ -988,6 +998,7 @@ def build_openssl(
988
998
989
999
root_32 = td / "x86"
990
1000
root_64 = td / "x64"
1001
+ root_arm64 = td / "arm64"
991
1002
992
1003
if arch == "x86" :
993
1004
root_32 .mkdir ()
@@ -1011,13 +1022,28 @@ def build_openssl(
1011
1022
root_64 ,
1012
1023
jom_archive = jom_archive ,
1013
1024
)
1025
+ elif arch == "arm64" :
1026
+ root_arm64 .mkdir ()
1027
+ build_openssl_for_arch (
1028
+ perl_path ,
1029
+ "arm64" ,
1030
+ openssl_archive ,
1031
+ openssl_version ,
1032
+ nasm_archive ,
1033
+ root_arm64 ,
1034
+ jom_archive = jom_archive ,
1035
+ )
1014
1036
else :
1015
- raise ValueError ("unhandled arch : %s" % arch )
1037
+ raise Exception ("unhandled architecture : %s" % arch )
1016
1038
1017
1039
install = td / "out"
1018
1040
1019
1041
if arch == "x86" :
1020
1042
shutil .copytree (root_32 / "install" / "32" , install / "openssl" / "win32" )
1043
+ elif arch == "arm64" :
1044
+ shutil .copytree (
1045
+ root_arm64 / "install" / "arm64" , install / "openssl" / "arm64"
1046
+ )
1021
1047
else :
1022
1048
shutil .copytree (root_64 / "install" / "64" , install / "openssl" / "amd64" )
1023
1049
@@ -1088,9 +1114,14 @@ def build_libffi(
1088
1114
if arch == "x86" :
1089
1115
args .append ("-x86" )
1090
1116
artifacts_path = ffi_source_path / "i686-pc-cygwin"
1091
- else :
1117
+ elif arch == "arm64" :
1118
+ args .append ("-arm64" )
1119
+ artifacts_path = ffi_source_path / "aarch64-w64-cygwin"
1120
+ elif arch == "amd64" :
1092
1121
args .append ("-x64" )
1093
1122
artifacts_path = ffi_source_path / "x86_64-w64-cygwin"
1123
+ else :
1124
+ raise Exception ("unhandled architecture: %s" % arch )
1094
1125
1095
1126
subprocess .run (args , env = env , check = True )
1096
1127
@@ -1460,8 +1491,11 @@ def build_cpython(
1460
1491
elif arch == "x86" :
1461
1492
build_platform = "win32"
1462
1493
build_directory = "win32"
1494
+ elif arch == "arm64" :
1495
+ build_platform = "arm64"
1496
+ build_directory = "arm64"
1463
1497
else :
1464
- raise ValueError ("unhandled arch : %s" % arch )
1498
+ raise Exception ("unhandled architecture : %s" % arch )
1465
1499
1466
1500
with tempfile .TemporaryDirectory (prefix = "python-build-" ) as td :
1467
1501
td = pathlib .Path (td )
@@ -1491,7 +1525,7 @@ def build_cpython(
1491
1525
1492
1526
# We need all the OpenSSL library files in the same directory to appease
1493
1527
# install rules.
1494
- openssl_arch = {"amd64" : "amd64" , "x86" : "win32" }[arch ]
1528
+ openssl_arch = {"amd64" : "amd64" , "x86" : "win32" , "arm64" : "arm64" }[arch ]
1495
1529
openssl_root = td / "openssl" / openssl_arch
1496
1530
openssl_bin_path = openssl_root / "bin"
1497
1531
openssl_lib_path = openssl_root / "lib"
@@ -1930,9 +1964,14 @@ def main() -> None:
1930
1964
if os .environ .get ("Platform" ) == "x86" :
1931
1965
target_triple = "i686-pc-windows-msvc"
1932
1966
arch = "x86"
1933
- else :
1967
+ elif os .environ .get ("Platform" ) == "arm64" :
1968
+ target_triple = "aarch64-pc-windows-msvc"
1969
+ arch = "arm64"
1970
+ elif os .environ .get ("Platform" ) == "x64" :
1934
1971
target_triple = "x86_64-pc-windows-msvc"
1935
1972
arch = "amd64"
1973
+ else :
1974
+ raise Exception ("unhandled architecture: %s" % os .environ .get ("Platform" ))
1936
1975
1937
1976
# TODO need better dependency checking.
1938
1977
0 commit comments