Skip to content

Commit

Permalink
ci: use cache for OpenSSL build
Browse files Browse the repository at this point in the history
  • Loading branch information
mayeut committed Aug 1, 2021
1 parent e6df5a9 commit 339c4e9
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 31 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ jobs:
uses: docker/[email protected]
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/[email protected]
if: (!matrix.use_qemu) || fromJSON(env.USE_QEMU)
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,6 @@ docs/_build
# IDE junk
.idea/*
*.swp

# OpenSSL build cache
.cache-openssl/
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
73 changes: 42 additions & 31 deletions scripts/manylinux-build-and-install-openssl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

0 comments on commit 339c4e9

Please sign in to comment.