Skip to content

Commit 4e5bcea

Browse files
committed
Make paths non-relative in build.sh
Now you can call the script from outside the tree.
1 parent 542c3b3 commit 4e5bcea

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

build.sh

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
set -euo pipefail
44

5-
RELEASE_DIR=./release
5+
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
6+
7+
RELEASE_DIR=${SCRIPT_DIR}/release
68

79
mkdir -p ${RELEASE_DIR}
810

@@ -11,15 +13,15 @@ for TARGET_ARCH in thumbv6m-none-eabi thumbv7m-none-eabi thumbv7em-none-eabi; do
1113
echo "TARGET is ${TARGET_ARCH}"
1214
for BINARY in flash0002 flash0802 flash1002; do
1315
echo "BINARY is ${BINARY}"
14-
cargo build $* --release --target=${TARGET_ARCH} --bin ${BINARY}
16+
( cd ${SCRIPT_DIR} && cargo build $* --release --target=${TARGET_ARCH} --bin ${BINARY} )
1517
# objcopy would do the build for us first, but it doesn't have good build output
16-
rust-objcopy -O binary ./target/${TARGET_ARCH}/release/${BINARY} ${RELEASE_DIR}/${TARGET_ARCH}-${BINARY}-libneotron_os.bin
18+
rust-objcopy -O binary ${SCRIPT_DIR}/target/${TARGET_ARCH}/release/${BINARY} ${RELEASE_DIR}/${TARGET_ARCH}-${BINARY}-libneotron_os.bin
1719
# Keep the ELF file too (for debugging)
18-
cp ./target/${TARGET_ARCH}/release/${BINARY} ${RELEASE_DIR}/${TARGET_ARCH}-${BINARY}-libneotron_os.elf
20+
cp ${SCRIPT_DIR}/target/${TARGET_ARCH}/release/${BINARY} ${RELEASE_DIR}/${TARGET_ARCH}-${BINARY}-libneotron_os.elf
1921
done
2022
done
2123

2224
# Build the host version
2325
echo "Building HOST"
24-
cargo build --verbose --lib --release --target=x86_64-unknown-linux-gnu
25-
cp ./target/x86_64-unknown-linux-gnu/release/libneotron_os.so ${RELEASE_DIR}/x86_64-unknown-linux-gnu-libneotron_os.so
26+
( cd ${SCRIPT_DIR} && cargo build --verbose --lib --release --target=x86_64-unknown-linux-gnu )
27+
cp ${SCRIPT_DIR}/target/x86_64-unknown-linux-gnu/release/libneotron_os.so ${RELEASE_DIR}/x86_64-unknown-linux-gnu-libneotron_os.so

0 commit comments

Comments
 (0)