Skip to content

Commit

Permalink
Build Windows binary using Python script
Browse files Browse the repository at this point in the history
  • Loading branch information
jlaine committed Nov 4, 2023
1 parent 7f4324a commit 9d2b90d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 58 deletions.
15 changes: 4 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,17 @@ jobs:
- uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install nasm
if: matrix.os == 'windows-latest'
run: choco install -y nasm
- name: Install nmake
if: matrix.os == 'windows-latest'
run: |
& "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe" modify `
--installPath "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise" `
--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --passive --norestart
shell: powershell
- name: Install qemu
if: matrix.os == 'ubuntu-latest'
uses: docker/setup-qemu-action@v3
- name: Install nasm
if: matrix.os == 'windows-latest'
run: choco install -y nasm
- name: Build OpenSSL
env:
CIBW_ARCHS: ${{ matrix.arch }}
CIBW_BEFORE_BUILD: python scripts/build-openssl.py /tmp/vendor
CIBW_BEFORE_BUILD_WINDOWS: scripts\build-openssl.bat C:\cibw\vendor
CIBW_BEFORE_BUILD_WINDOWS: python scripts\build-openssl.py C:\cibw\vendor
CIBW_BUILD: cp38-*
CIBW_SKIP: '*-musllinux*'
CIBW_TEST_COMMAND: python -c "import dummy"
Expand Down
44 changes: 0 additions & 44 deletions scripts/build-openssl.bat

This file was deleted.

17 changes: 14 additions & 3 deletions scripts/build-openssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ def run(cmd, *, env=None):
run(["yum", "-y", "install", "perl-IPC-Cmd"])
elif platform.system() == "Darwin" and os.environ.get("ARCHFLAGS") == "-arch arm64":
configure_args = ["darwin64-arm64"]
elif platform.system() == "Windows":
os.environ["PATH"] = "C:\\Program Files\\NASM;" + os.environ["PATH"]
if get_platform() == "win_amd64":
configure_args = ["VC-WIN64A"]
else:
configure_args = ["VC-WIN32"]

output_tarball = os.path.join(output_dir, f"openssl-{get_platform()}.tar.gz")

for d in [build_dir, output_dir, source_dir]:
Expand All @@ -82,8 +89,12 @@ def run(cmd, *, env=None):
# build openssl
extract("openssl", "https://www.openssl.org/source/openssl-3.1.4.tar.gz")
os.chdir("openssl")
run(["./config"] + configure_args + ["no-comp", "no-shared", "no-tests"])
run(["make", "-j"])
run(["make", "install_sw", "INSTALLTOP=" + dest_dir, "LIBDIR=lib"])
run(["perl", "Configure"] + configure_args + ["no-comp", "no-shared", "no-tests"])
if platform.system() == "Windows":
run(["nmake"])
run(["nmake", "install_sw"])
else:
run(["make", "-j"])
run(["make", "install_sw", "INSTALLTOP=" + dest_dir, "LIBDIR=lib"])

run(["tar", "czvf", output_tarball, "-C", dest_dir, "include", "lib"])

0 comments on commit 9d2b90d

Please sign in to comment.