-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgo
executable file
·65 lines (51 loc) · 1.38 KB
/
go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
set -e
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
function error {
echo -e >&2 "\033[31m${1}\033[0m";
exit 1;
}
function notice {
echo -e >&2 "\033[33m${1}\033[0m";
}
function ensure_env {
git submodule update --init
command -v make >/dev/null 2>&1 || error "Please install make (needed to build lc3tools)"
command -v rustc >/dev/null 2>&1 || error "Please install Rust >= 1.33"
command -v cargo >/dev/null 2>&1 || error "Please install Cargo (Rust's package manager)"
}
function cmd_test {
RUST_LOG="" cargo test "$@"
}
function cmd_os {
cargo run --bin=repl -- --program testcases/assembly/os.asm --entrypoint 0x200 "$@"
}
function cmd_bench {
cargo build --release
export RUST_LOG=${RUST_LOG:-info}
if [[ "$1" == "flamegraph" ]]; then
sudo flamegraph target/release/repl --program testcases/assembly/divisible.asm --entrypoint 0x3000
else
target/release/repl --program testcases/assembly/divisible.asm --entrypoint 0x3000
fi
}
function cmd_usage {
echo "
./go [cmd]
test TODO
bench TODO
os Runs the 'LC3 OS' test case in interactive mode
";
}
ensure_env
command=""
if (( $# > 0 )); then
command="${1}"
shift
fi
case "${command}" in
test) cmd_test "$@" ;;
bench) cmd_bench "$@" ;;
os) cmd_os "$@" ;;
*) cmd_usage
esac