build: Handle output files better

This commit is contained in:
Dorota Czaplejewicz
2019-11-19 10:01:21 +00:00
parent 9571adb107
commit 1db561d33a
2 changed files with 13 additions and 7 deletions

View File

@ -11,15 +11,21 @@ SOURCE_DIR="$(dirname "$SCRIPT_PATH")"
CARGO_TARGET_DIR="$(pwd)" CARGO_TARGET_DIR="$(pwd)"
export CARGO_TARGET_DIR export CARGO_TARGET_DIR
if [ -n "${1}" ]; then if [ "${1}" = "--rename" ]; then
OUT_PATH="$(realpath "$1")" shift
FILENAME="${1}"
shift
OUT_PATH="$(realpath "${1}")"
elif [ "${1}" = "--output" ]; then
shift
OUT_PATH="$(realpath "${1}")"
FILENAME="$(basename "${OUT_PATH}")"
fi fi
shift
cd "$SOURCE_DIR" cd "$SOURCE_DIR"
shift
cargo "$@" cargo "$@"
if [ -n "${OUT_PATH}" ]; then if [ -n "${OUT_PATH}" ]; then
FILENAME="$(basename "${OUT_PATH}")"
cp -a "${CARGO_TARGET_DIR}"/debug/"${FILENAME}" "${OUT_PATH}" cp -a "${CARGO_TARGET_DIR}"/debug/"${FILENAME}" "${OUT_PATH}"
fi fi

View File

@ -58,7 +58,7 @@ rslibs = custom_target(
output: ['librs.a'], output: ['librs.a'],
install: false, install: false,
console: true, console: true,
command: [cargo_script, '@OUTPUT@', 'build', '--lib'] command: [cargo_script, '--output', '@OUTPUT@', 'build', '--lib']
) )
build_rstests = custom_target( build_rstests = custom_target(
@ -129,8 +129,8 @@ test_layout = custom_target('squeekboard_test_layout',
build_by_default: true, build_by_default: true,
# meson doesn't track all inputs, cargo does # meson doesn't track all inputs, cargo does
build_always_stale: true, build_always_stale: true,
output: ['test_layout'], output: ['squeekboard_test_layout'],
console: true, console: true,
command: [cargo_script, '@OUTPUT@', 'build', '--bin', 'test_layout'], command: [cargo_script, '--rename', 'test_layout', '@OUTPUT@', 'build', '--bin', 'test_layout'],
install_dir: bindir, install_dir: bindir,
) )