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.
This commit is contained in:
Christopher Davis 2019-03-04 12:53:07 -05:00 committed by Jordan Petridis
parent 78f29e726e
commit 7a77f31aa3
No known key found for this signature in database
GPG Key ID: E8523968931763BE
4 changed files with 9 additions and 12 deletions

View File

@ -78,6 +78,7 @@ meson.add_dist_script(
test( test(
'cargo-test', 'cargo-test',
test_script, test_script,
args: meson.build_root(),
workdir: meson.source_root(), workdir: meson.source_root(),
timeout: 3000 timeout: 3000
) )

View File

@ -41,8 +41,6 @@ cargo_release = custom_target('cargo-build',
command: [cargo_script, command: [cargo_script,
'@SOURCE_ROOT@', '@SOURCE_ROOT@',
'@OUTPUT@', '@OUTPUT@',
podcasts_localedir, meson.build_root(),
application_id,
podcasts_version + version_suffix,
profile profile
]) ])

View File

@ -2,11 +2,10 @@
set -ex set -ex
export CARGO_HOME=$1/target/cargo-home export OUTPUT="$2"
export LOCALEDIR="$3" export CARGO_TARGET_DIR="$3"/target
export APP_ID="$4" export CARGO_HOME="$CARGO_TARGET_DIR"/cargo-home
export VERSION="$5" export PROFILE="$4"
export PROFILE="$6"
TARGET=debug TARGET=debug
ARGS=() ARGS=()
@ -23,4 +22,4 @@ if test -d vendor; then
fi fi
cargo build ${ARGS[@]} --manifest-path="$1"/Cargo.toml -p podcasts-gtk && 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"

View File

@ -1,10 +1,9 @@
#! /usr/bin/sh #! /usr/bin/sh
set -o errexit set -o errexit
set -o nounset
set -o pipefail set -o pipefail
export CARGO_HOME="target/cargo-home" export CARGO_TARGET_DIR="$1/target/"
export CARGO_TARGET_DIR="target_test/" export CARGO_HOME="$CARGO_TARGET_DIR/cargo-home"
cargo test -j 1 -- --test-threads=1 --nocapture cargo test -j 1 -- --test-threads=1 --nocapture