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)"
export CARGO_TARGET_DIR
if [ -n "${1}" ]; then
OUT_PATH="$(realpath "$1")"
if [ "${1}" = "--rename" ]; then
shift
FILENAME="${1}"
shift
OUT_PATH="$(realpath "${1}")"
elif [ "${1}" = "--output" ]; then
shift
OUT_PATH="$(realpath "${1}")"
FILENAME="$(basename "${OUT_PATH}")"
fi
shift
cd "$SOURCE_DIR"
shift
cargo "$@"
if [ -n "${OUT_PATH}" ]; then
FILENAME="$(basename "${OUT_PATH}")"
cp -a "${CARGO_TARGET_DIR}"/debug/"${FILENAME}" "${OUT_PATH}"
fi