(
perl_path,
arch: str,
openssl_archive,
openssl_version: str,
nasm_archive,
build_root: pathlib.Path,
*,
jom_archive,
with_uplink: bool = False,
)
| 785 | |
| 786 | |
| 787 | def build_openssl_for_arch( |
| 788 | perl_path, |
| 789 | arch: str, |
| 790 | openssl_archive, |
| 791 | openssl_version: str, |
| 792 | nasm_archive, |
| 793 | build_root: pathlib.Path, |
| 794 | *, |
| 795 | jom_archive, |
| 796 | with_uplink: bool = False, |
| 797 | ): |
| 798 | nasm_version = DOWNLOADS["nasm-windows-bin"]["version"] |
| 799 | |
| 800 | log("extracting %s to %s" % (openssl_archive, build_root)) |
| 801 | extract_tar_to_directory(openssl_archive, build_root) |
| 802 | log("extracting %s to %s" % (nasm_archive, build_root)) |
| 803 | extract_zip_to_directory(nasm_archive, build_root) |
| 804 | log("extracting %s to %s" % (jom_archive, build_root)) |
| 805 | extract_zip_to_directory(jom_archive, build_root / "jom") |
| 806 | |
| 807 | nasm_path = build_root / ("nasm-%s" % nasm_version) |
| 808 | jom_path = build_root / "jom" |
| 809 | |
| 810 | env = dict(os.environ) |
| 811 | # Add Perl and nasm paths to front of PATH. |
| 812 | env["PATH"] = "%s;%s;%s;%s" % (perl_path.parent, nasm_path, jom_path, env["PATH"]) |
| 813 | |
| 814 | source_root = build_root / ("openssl-%s" % openssl_version) |
| 815 | |
| 816 | if with_uplink: |
| 817 | # uplink.c tries to find the OPENSSL_Applink function exported from the |
| 818 | # current executable. However, it is exported from _ssl[_d].pyd in shared |
| 819 | # builds. So update its source to look for it from there. |
| 820 | static_replace_in_file( |
| 821 | source_root / "ms" / "uplink.c", |
| 822 | b"((h = GetModuleHandle(NULL)) == NULL)", |
| 823 | b'((h = GetModuleHandleA("_ssl.pyd")) == NULL) if ((h = GetModuleHandleA("_ssl_d.pyd")) == NULL) if ((h = GetModuleHandle(NULL)) == NULL)', |
| 824 | ) |
| 825 | |
| 826 | if arch == "x86": |
| 827 | configure = "VC-WIN32" |
| 828 | prefix = "32" |
| 829 | elif arch == "amd64": |
| 830 | configure = "VC-WIN64A" |
| 831 | prefix = "64" |
| 832 | elif arch == "arm64": |
| 833 | configure = "VC-WIN64-ARM" |
| 834 | prefix = "arm64" |
| 835 | else: |
| 836 | raise Exception("unhandled architecture: %s" % arch) |
| 837 | |
| 838 | # Set DESTDIR to affect install location. |
| 839 | dest_dir = build_root / "install" |
| 840 | env["DESTDIR"] = str(dest_dir) |
| 841 | install_root = dest_dir / prefix |
| 842 | |
| 843 | configure_args = [ |
| 844 | str(perl_path), |
no test coverage detected