From 7a77f31aa3d95a4fb322ca805a448c009ba3e846 Mon Sep 17 00:00:00 2001 From: Christopher Davis Date: Mon, 4 Mar 2019 12:53:07 -0500 Subject: [PATCH] build: Place target in meson build dir Instead of putting target/ and target_test/ in the source directory, we can tell our cargo script to put both target and our cargo-home in meson's build directory. In addition, makes tests and builds use the same target directory, significantly reducing the time it takes to run tests. --- meson.build | 1 + podcasts-gtk/src/meson.build | 4 +--- scripts/cargo.sh | 11 +++++------ scripts/test.sh | 5 ++--- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/meson.build b/meson.build index 46fb73e..1ebec4f 100644 --- a/meson.build +++ b/meson.build @@ -78,6 +78,7 @@ meson.add_dist_script( test( 'cargo-test', test_script, + args: meson.build_root(), workdir: meson.source_root(), timeout: 3000 ) diff --git a/podcasts-gtk/src/meson.build b/podcasts-gtk/src/meson.build index 75f0084..edbe8c7 100644 --- a/podcasts-gtk/src/meson.build +++ b/podcasts-gtk/src/meson.build @@ -41,8 +41,6 @@ cargo_release = custom_target('cargo-build', command: [cargo_script, '@SOURCE_ROOT@', '@OUTPUT@', - podcasts_localedir, - application_id, - podcasts_version + version_suffix, + meson.build_root(), profile ]) diff --git a/scripts/cargo.sh b/scripts/cargo.sh index 38f4a09..ad47db3 100755 --- a/scripts/cargo.sh +++ b/scripts/cargo.sh @@ -2,11 +2,10 @@ set -ex -export CARGO_HOME=$1/target/cargo-home -export LOCALEDIR="$3" -export APP_ID="$4" -export VERSION="$5" -export PROFILE="$6" +export OUTPUT="$2" +export CARGO_TARGET_DIR="$3"/target +export CARGO_HOME="$CARGO_TARGET_DIR"/cargo-home +export PROFILE="$4" TARGET=debug ARGS=() @@ -23,4 +22,4 @@ if test -d vendor; then fi cargo build ${ARGS[@]} --manifest-path="$1"/Cargo.toml -p podcasts-gtk && -cp $1/target/${TARGET}/podcasts-gtk $2 +cp "$CARGO_TARGET_DIR"/${TARGET}/podcasts-gtk "$OUTPUT" diff --git a/scripts/test.sh b/scripts/test.sh index 367bed3..35ed241 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -1,10 +1,9 @@ #! /usr/bin/sh set -o errexit -set -o nounset set -o pipefail -export CARGO_HOME="target/cargo-home" -export CARGO_TARGET_DIR="target_test/" +export CARGO_TARGET_DIR="$1/target/" +export CARGO_HOME="$CARGO_TARGET_DIR/cargo-home" cargo test -j 1 -- --test-threads=1 --nocapture