-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathbuild
executable file
·112 lines (100 loc) · 3.15 KB
/
build
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/usr/bin/env bash
set -e
FLEXUS_ROOT=$(realpath flexus)
QEMU_ROOT=$(realpath qemu)
# Default values
BUILD_TYPE="release"
CUSTOM_GCC=0
NIX=0
# Print help message
print_help() {
echo "Usage: $0 [options] <sim>"
echo "Options:"
echo " -b, --build-type <type> Build type (default: release)"
echo " -c, --custom-gcc <gcc> Use custom GCC (default: false)"
echo " -n, --nix Will use raw cmake command to comply with Nix"
echo " -h, --help Print this help message"
exit 0
}
# Parse command-line arguments
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-b|--build-type)
# Accept all type present in CMake (release, relwithdebinfo, debug)
BUILD_TYPE="$2"
shift
shift
;;
-c|--custom-gcc)
# Will use a custom GCC installed in /opt/qflex
CUSTOM_GCC=1
shift
;;
-n|--nix)
# Build Flexus without Conan (dumb IMO)
NIX=1
shift
;;
-h|--help)
print_help
;;
*)
# simulator, supported every directory name in flexus/target (knottykraken, semikraken)
SIM="$1"
shift
break
;;
esac
done
# Check if SIM is set
if [ -z "$SIM" ]; then
echo "Error: <sim> argument is required"
print_help
fi
profile="-pr ${FLEXUS_ROOT}/target/_profile/${BUILD_TYPE}"
case $SIM in
*kraken)
if [[ $NIX -gt 0 ]]; then
# Shanqing needed that. I wont support it.
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DSIMULATOR=$SIM -G Ninja $FLEXUS_ROOT
exit 0
fi
if [[ $CUSTOM_GCC -gt 0 ]]; then
profile="${profile} -pr ${FLEXUS_ROOT}/target/_profile/custom-gcc"
fi
conan build $FLEXUS_ROOT $profile --name=$SIM -of out -b missing
conan export-pkg $FLEXUS_ROOT $profile --name=$SIM -of out
;;
[cC][Qq]|qemu)
pushd $QEMU_ROOT
if [ "$BUILD_TYPE" = "debug" ]; then
./configure --target-list=aarch64-softmmu \
--disable-docs \
--enable-capstone \
--enable-slirp \
--enable-libqflex \
--enable-snapvm-external \
--enable-debug
else
./configure --target-list=aarch64-softmmu \
--disable-docs \
--enable-capstone \
--enable-slirp \
--enable-libqflex \
--enable-snapvm-external
fi
popd
make -C qemu -j
;;
[Qq])
make -C qemu -j
;;
docker)
docker buildx build -t parsa/qflex-${BUILD_TYPE}:latest --build-arg MODE=${BUILD_TYPE} .
;;
*)
echo "Never heard of '${SIM}'"
exit 1
;;
esac