diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e1f2a79a9..92887abdf 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -73,6 +73,13 @@ jobs: uses: docker/setup-qemu-action@v1.2.0 if: matrix.use_qemu && fromJSON(env.USE_QEMU) + - name: Cache OpenSSL build + if: runner.os == 'Linux' + uses: actions/cache@v2 + with: + path: .cache-openssl + key: ${{ matrix.os }}-${{ matrix.arch }}-${{ hashFiles('scripts/manylinux-build-and-install-openssl.sh') }} + - name: Build wheels uses: pypa/cibuildwheel@v2.0.1 if: (!matrix.use_qemu) || fromJSON(env.USE_QEMU) diff --git a/.gitignore b/.gitignore index 18f666f1c..ddc3869ab 100644 --- a/.gitignore +++ b/.gitignore @@ -60,3 +60,6 @@ docs/_build # IDE junk .idea/* *.swp + +# OpenSSL build cache +.cache-openssl/ diff --git a/pyproject.toml b/pyproject.toml index 58f606074..ba186ec71 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,6 +33,7 @@ manylinux-i686-image = "manylinux1" [tool.cibuildwheel.linux.environment] SKBUILD_CONFIGURE_OPTIONS = "-DOPENSSL_ROOT_DIR:PATH=/usr/local/ssl -DCMAKE_JOB_POOL_COMPILE:STRING=compile -DCMAKE_JOB_POOL_LINK:STRING=link -DCMAKE_JOB_POOLS:STRING=compile=2;link=1" +OPENSSL_CACHE_DIR = "home/runner/work/cmake-python-distributions/cmake-python-distributions/.cache-openssl" [tool.cibuildwheel.macos.environment] MACOSX_DEPLOYMENT_TARGET = "10.10" diff --git a/scripts/manylinux-build-and-install-openssl.sh b/scripts/manylinux-build-and-install-openssl.sh index 0a856212f..92723f1dd 100755 --- a/scripts/manylinux-build-and-install-openssl.sh +++ b/scripts/manylinux-build-and-install-openssl.sh @@ -14,42 +14,53 @@ OPENSSL_ROOT=openssl-1.1.1k # Hash from https://www.openssl.org/source/openssl-1.1.1k.tar.gz.sha256 OPENSSL_HASH=892a0875b9872acd04a9fde79b1f943075d5ea162415de3047c327df33fbaee5 -cd /tmp +OPENSSL_ARCHIVE=/host/${OPENSSL_CACHE_DIR}/${OPENSSL_ROOT}-${AUDITWHEEL_PLAT}.tar.gz -if ! perl -e 'use 5.10.0' &> /dev/null; then - # perl>=5.10.0 is needed to build openssl - PERL_ROOT=perl-5.32.1 - # Hash from https://www.cpan.org/src/5.0/perl-5.32.1.tar.gz.sha256.txt - PERL_HASH=03b693901cd8ae807231b1787798cf1f2e0b8a56218d07b7da44f784a7caeb2c - curl -fsSLO https://www.cpan.org/src/5.0/${PERL_ROOT}.tar.gz - check_sha256sum ${PERL_ROOT}.tar.gz ${PERL_HASH} - tar -xzf ${PERL_ROOT}.tar.gz - rm -rf ${PERL_ROOT}.tar.gz +if ! [ -e "${OPENSSL_ARCHIVE}" ]; then + cd /tmp - pushd ${PERL_ROOT} - ./Configure -des -Dprefix=/tmp/perl-openssl > /dev/null - make -j$(nproc) > /dev/null - make install > /dev/null - popd - export PATH=/tmp/perl-openssl/bin:${PATH} -fi + if ! perl -e 'use 5.10.0' &> /dev/null; then + # perl>=5.10.0 is needed to build openssl + PERL_ROOT=perl-5.32.1 + # Hash from https://www.cpan.org/src/5.0/perl-5.32.1.tar.gz.sha256.txt + PERL_HASH=03b693901cd8ae807231b1787798cf1f2e0b8a56218d07b7da44f784a7caeb2c + + curl -fsSLO https://www.cpan.org/src/5.0/${PERL_ROOT}.tar.gz + check_sha256sum ${PERL_ROOT}.tar.gz ${PERL_HASH} + tar -xzf ${PERL_ROOT}.tar.gz + rm -rf ${PERL_ROOT}.tar.gz + + pushd ${PERL_ROOT} + ./Configure -des -Dprefix=/tmp/perl-openssl > /dev/null + make -j$(nproc) > /dev/null + make install > /dev/null + popd + export PATH=/tmp/perl-openssl/bin:${PATH} + fi -# Download -curl -fsSLO http://www.openssl.org/source/${OPENSSL_ROOT}.tar.gz -check_sha256sum ${OPENSSL_ROOT}.tar.gz ${OPENSSL_HASH} -tar -xzf ${OPENSSL_ROOT}.tar.gz -rm -rf ${OPENSSL_ROOT}.tar.gz + # Download + curl -fsSLO http://www.openssl.org/source/${OPENSSL_ROOT}.tar.gz + check_sha256sum ${OPENSSL_ROOT}.tar.gz ${OPENSSL_HASH} + tar -xzf ${OPENSSL_ROOT}.tar.gz + rm -rf ${OPENSSL_ROOT}.tar.gz -# Configure -pushd ${OPENSSL_ROOT} -./config no-shared -fPIC --prefix=/usr/local/ssl --openssldir=/usr/local/ssl > /dev/null + # Configure + pushd ${OPENSSL_ROOT} + ./config no-shared -fPIC --prefix=/usr/local/ssl --openssldir=/usr/local/ssl > /dev/null -# Build -make -j$(nproc) > /dev/null + # Build + make -j$(nproc) > /dev/null + + # Install + make install_sw DESTDIR=/tmp/${OPENSSL_ROOT}-root > /dev/null + + # Create cache archive + mkdir -p "$(dirname ${OPENSSL_ARCHIVE})" + tar -C /tmp/${OPENSSL_ROOT}-root -czf "${OPENSSL_ARCHIVE}" usr -# Install -make install_sw > /dev/null + popd + rm -rf ${OPENSSL_ROOT} +fi -popd -rm -rf ${OPENSSL_ROOT} +tar -C / -xf "${OPENSSL_ARCHIVE}"