-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-test.sh
executable file
·66 lines (61 loc) · 1.72 KB
/
build-test.sh
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
66
#!/usr/bin/env bash
set -e
realpath() {
OURPWD=$PWD
cd "$(dirname "$1")"
LINK=$(readlink "$(basename "$1")")
while [ "$LINK" ]; do
cd "$(dirname "$LINK")"
LINK=$(readlink "$(basename "$1")")
done
REALPATH="$PWD/$(basename "$1")"
cd "$OURPWD"
echo "$REALPATH"
}
SCRIPT_NAME=
if [ -z $BASH_SOURCE ]; then
SCRIPT_NAME=$0
else
SCRIPT_NAME=${BASH_SOURCE[0]}
fi
SCRIPT_DIR=$(realpath "$(dirname "$SCRIPT_NAME")")
source $SCRIPT_DIR/env.sh
TOOLCHAIN=$1
if [ -z $TOOLCHAIN ]; then
echo "Need to specify a toolchain"
exit 1
fi
shift
MAIN=$1
if [ -z $MAIN ]; then
echo "Need at least 1 argument, likely a source file"
exit 1
fi
OUTNAME=$ZIRCON_TEST_BUILD/$(basename $MAIN | sed 's/\(.*\)\..*/\1/')
mkdir -p $ZIRCON_TEST_BUILD
if [[ $TOOLCHAIN == "native" ]]; then
PREFIX=
OUTNAME+="-native.out"
elif [[ $TOOLCHAIN == "elf" ]]; then
PREFIX=$ZIRCON_RV64IMA_ELF/bin/riscv64-unknown-elf-
OUTNAME+="-elf.out"
elif [[ $TOOLCHAIN == "elf-debug" ]]; then
PREFIX=$ZIRCON_RV64IMA_ELF_DEBUG/bin/riscv64-unknown-elf-
OUTNAME+="-elf-debug.out"
elif [[ $TOOLCHAIN == "linux" ]]; then
PREFIX=$ZIRCON_RV64IMA_LINUX/bin/riscv64-unknown-linux-gnu-
OUTNAME+="-linux.out"
elif [[ $TOOLCHAIN == "linux-debug" ]]; then
PREFIX=$ZIRCON_RV64IMA_LINUX_DEBUG/bin/riscv64-unknown-linux-gnu-
OUTNAME+="-linux-debug.out"
elif [[ $TOOLCHAIN == "musl" ]]; then
PREFIX=$ZIRCON_RV64IMA_MUSL/bin/riscv64-unknown-linux-musl-
OUTNAME+="-musl.out"
elif [[ $TOOLCHAIN == "musl-debug" ]]; then
PREFIX=$ZIRCON_RV64IMA_MUSL_DEBUG/bin/riscv64-unknown-linux-musl-
OUTNAME+="-musl-debug.out"
else
echo "Invalid Toolchain"
exit 1
fi
(set -x && ${PREFIX}gcc -o $OUTNAME -g -static -Wall -Wextra $@)