Skip to content

Commit

Permalink
Try using GITHUB_ENV for cross-compile options
Browse files Browse the repository at this point in the history
Signed-off-by: Timothy Johnson <[email protected]>
  • Loading branch information
t1m0thyj committed Nov 1, 2023
1 parent 924018b commit 8a92ece
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 23 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/secrets-sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,24 @@ jobs:
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Set environment variables
run: src/secrets/scripts/configure-cross.sh
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist --find-interpreter
sccache: "true"
container: ghcr.io/rust-cross/manylinux2014-cross:${{ matrix.target }}
manylinux: auto
docker-options: --env-file $GITHUB_ENV
working-directory: src/secrets/src/keyring
before-script-linux: ../../scripts/configure-cross.sh ${{ matrix.target }}
before-script-linux: |
if command -v yum &> /dev/null; then
yum update && yum install -y libsecret-devel.${{ env.CROSS_DEB_ARCH }}
else
dpkg --add-architecture ${{ env.CROSS_DEB_ARCH }}
apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y libsecret-1-dev:${{ env.CROSS_DEB_ARCH }}
fi
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
Expand Down
31 changes: 10 additions & 21 deletions src/secrets/scripts/configure-cross.sh
Original file line number Diff line number Diff line change
@@ -1,42 +1,31 @@
#!/bin/bash

# Install libsecret for the architecture we are compiling for
install_libs() {
dpkg --add-architecture $1
apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y libsecret-1-dev:$1
}

# Set environment variables needed for cross-compilation in current shell
set_env() {
export PKG_CONFIG_SYSROOT_DIR="${CHROOT:-/}"
export RUSTFLAGS="-L $CHROOT$1 $RUSTFLAGS"
export PKG_CONFIG_PATH="$CHROOT$1/pkgconfig"
echo "CROSS_DEB_ARCH=$1" >> $GITHUB_ENV
echo "PKG_CONFIG_SYSROOT_DIR=\"${CHROOT:-/}\"" >> $GITHUB_ENV
echo "RUSTFLAGS=\"-L $CHROOT$2 $RUSTFLAGS\"" >> $GITHUB_ENV
echo "PKG_CONFIG_PATH=\"$CHROOT$2/pkgconfig\"" >> $GITHUB_ENV
}

case "$1" in
"aarch64")
install_libs arm64
set_env "/usr/lib/aarch64-linux-gnu"
set_env arm64 "/usr/lib/aarch64-linux-gnu"
;;
"armv7")
install_libs armhf
set_env "/usr/lib/arm-linux-gnueabihf"
set_env armhf "/usr/lib/arm-linux-gnueabihf"
;;
"ppc64le")
install_libs ppc64el
set_env "/usr/lib/powerpc64le-unknown-linux-gnu"
set_env ppc64el "/usr/lib/powerpc64le-unknown-linux-gnu"
;;
"s390x")
install_libs s390x
set_env "/usr/lib/s390x-unknown-linux-gnu"
set_env s390x "/usr/lib/s390x-unknown-linux-gnu"
;;
"x86")
install_libs i386
set_env "/usr/lib/i386-linux-gnu"
set_env i686 "/usr/lib/i386-linux-gnu"
;;
"x86_64")
install_libs amd64
set_env "/usr/lib/x86_64-linux-gnu"
set_env x86_64 "/usr/lib/x86_64-linux-gnu"
;;
*)
;;
Expand Down

0 comments on commit 8a92ece

Please sign in to comment.