From 6e8f869bf37b4aa2e4dbfda10aadf06925226b2e Mon Sep 17 00:00:00 2001 From: Tony Duan Date: Tue, 14 Jun 2022 22:58:15 +0800 Subject: [PATCH] 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 --- .gitignore | 1 + scripts/build.sh | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index a5fcd5d1..40befbf5 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ .idea/ **/target +/runtimetest-target .vagrant/ tags diff --git a/scripts/build.sh b/scripts/build.sh index 045bfa32..9d771d71 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -11,6 +11,7 @@ usage_exit() { 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} @@ -36,8 +37,9 @@ OUTPUT=${output:-$ROOT/bin} cargo build --target ${TARGET} ${OPTION} --bin youki cargo build --target ${TARGET} ${OPTION} --bin integration_test -RUSTFLAGS="-Ctarget-feature=+crt-static" cargo build --target ${TARGET} ${OPTION} --bin runtimetest +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,runtimetest} ${OUTPUT}/ +mv ${ROOT}/target/${TARGET}/${VERSION}/{youki,integration_test} ${OUTPUT}/ +mv ${RUNTIMETEST_TARGET}/${TARGET}/${VERSION}/runtimetest ${OUTPUT}/ exit 0