From a0fe6aeead4aa4fa728a7d243fd1b53e14d00358 Mon Sep 17 00:00:00 2001 From: finn Date: Tue, 20 Dec 2022 02:20:10 -0800 Subject: [PATCH] left some arch-specific stuff in there --- .gitlab-ci.yml | 7 ++----- rustflags.sh | 32 ++++++++++++++++++++++++++++---- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7945068..24e93c7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -43,13 +43,10 @@ compile: - rustup toolchain install nightly - rustup target add "${TARGET}" - if [[ -d ../target ]]; then mv ../target target; fi - - RUSTFLAGS="$(../rustflags.sh)" CARGO_BUILD_TARGET=${TARGET} cargo build -p libsignal-jni --target "${TARGET}" --release --verbose + - . ../rustflags.sh + - cargo build -p libsignal-jni --target "${TARGET}" --release --verbose - cp -v target/${TARGET}/release/libsignal_jni.so ../libsignal_jni-${TARGET}.so - cp -r target/ ../target - variables: - CC: aarch64-linux-gnu-gcc - CXX: aarch64-linux-gnu-g++ - CPATH: /usr/aarch64-linux-gnu/include cache: paths: - target/ diff --git a/rustflags.sh b/rustflags.sh index 214fe01..bae7334 100755 --- a/rustflags.sh +++ b/rustflags.sh @@ -1,8 +1,32 @@ -#!/bin/bash -flags="-C link-arg=-s" +#!/bin/bash -exuo pipefail +RUSTFLAGS="-C link-arg=-s" if [[ "${TARGET}" == *musl ]]; then - flags="${flags} -C target-feature=-crt-static" + RUSTFLAGS="${flags} -C target-feature=-crt-static" fi -echo "${flags}" +export RUSTFLAGS="${RUSTFLAGS}" + +target_debian="" +case "${TARGET}" in + aarch64-unknown-linux-gnu|aarch64-unknown-linux-musl) + target_debian="aarch64-linux-gnu" + ;; + arm-unknown-linux-gnueabi|arm-unknown-linux-musleabi) + target_debian="arm-linux-gnueabi" + ;; + arm-unknown-linux-gnueabihf|arm-unknown-linux-musleabihf) + target_debian="arm-linux-gnueabihf" + ;; + armv7-unknown-linux-gnueabihf|armv7-unknown-linux-musleabihf) + target_debian="arm-linux-gnueabihf" + ;; +esac + +if [[ "${target_debian}" != "" ]]; then + export CC="${target_debian}-gcc" + export CCX="${target_debian}-g++" + export CPATH="/usr/${target_debian}/include" +fi + +export CARGO_BUILD_TARGET="${TARGET}"