Skip to content

Commit 896f5e0

Browse files
committed
Make build_and_run.sh work from repo root
1 parent c896ab0 commit 896f5e0

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

uvclang/build_and_run.sh

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
#!/bin/sh
22
# Compile a source file with uvclang and run the result in the UVM VM.
3-
# All arguments are forwarded to uvclang, so flags work as usual:
3+
# All arguments are forwarded to uvclang, so flags work as usual. Works from any
4+
# directory; input paths resolve against your current directory:
45
# ./build_and_run.sh examples/synth.c
5-
# ./build_and_run.sh -O0 tests/printf.c
6+
# uvclang/build_and_run.sh uvclang/tests/printf.c # e.g. from the repo root
67
set -e
7-
cd "$(dirname "$0")"
8+
9+
# Resolve this script's directory so we can find the crates and write out.asm
10+
# here regardless of the caller's working directory. We deliberately do NOT cd:
11+
# staying in the caller's directory lets relative input paths resolve naturally
12+
# (uvclang's own include dir is compiled-in absolute, so it needs no cd).
13+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
14+
815
export RUST_BACKTRACE=1
9-
cargo run -q -- "$@" -o out.asm
10-
exec cargo run -q --manifest-path ../vm/Cargo.toml -- out.asm
16+
cargo run -q --manifest-path "$SCRIPT_DIR/Cargo.toml" -- "$@" -o "$SCRIPT_DIR/out.asm"
17+
exec cargo run -q --manifest-path "$SCRIPT_DIR/../vm/Cargo.toml" -- "$SCRIPT_DIR/out.asm"

0 commit comments

Comments
 (0)