1
0
Fork 0
mirror of https://github.com/containers/youki synced 2024-05-04 22:56:15 +02:00
youki/scripts/build.sh
Tony Duan 6e8f869bf3
chore: a separate target directory for runtimetest
building static-linked runtimetest requires additional RUSTFLAGS env
var. Unfortunately, the additional env var invalids the build cache,
leading cargo rebuilding everytime.

See https://github.com/rust-lang/cargo/issues/8716

A temporary solution is to build runtimetest in a seperate
`runtimetest-target` directory.

Signed-off-by: Tony Duan <tony84727@gmail.com>
2022-06-14 23:32:49 +08:00

46 lines
1012 B
Bash
Executable File

#!/bin/bash
set -e
ROOT=$(git rev-parse --show-toplevel)
usage_exit() {
echo "Usage: $0 [-r] [-o dir]" 1>&2
exit 1
}
VERSION=debug
TARGET=x86_64-unknown-linux-gnu
RUNTIMETEST_TARGET="$ROOT/runtimetest-target"
while getopts ro:h OPT; do
case $OPT in
o) output=${OPTARG}
;;
r) VERSION=release
;;
h) usage_exit
;;
\?) usage_exit
;;
esac
done
shift $((OPTIND - 1))
OPTION=""
if [ ${VERSION} = release ]; then
OPTION="--${VERSION}"
fi
OUTPUT=${output:-$ROOT/bin}
[ ! -d $OUTPUT ] && mkdir -p $OUTPUT
cargo build --target ${TARGET} ${OPTION} --bin youki
cargo build --target ${TARGET} ${OPTION} --bin integration_test
CARGO_TARGET_DIR=${RUNTIMETEST_TARGET} RUSTFLAGS="-Ctarget-feature=+crt-static" cargo build --target ${TARGET} ${OPTION} --bin runtimetest
mv ${ROOT}/target/${TARGET}/${VERSION}/{youki,integration_test} ${OUTPUT}/
mv ${RUNTIMETEST_TARGET}/${TARGET}/${VERSION}/runtimetest ${OUTPUT}/
exit 0