forked from renode/renode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·214 lines (185 loc) · 4.68 KB
/
build.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
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
#!/bin/bash
set -u
set -e
UPDATE_SUBMODULES=false
export ROOT_PATH="`dirname \"\`realpath "$0"\`\"`"
OUTPUT_DIRECTORY="$ROOT_PATH/output"
CONFIGURATION="Release"
CLEAN=false
PACKAGES=false
NIGHTLY=false
PORTABLE=false
HEADLESS=false
PARAMS=()
CUSTOM_PROP=
function print_help() {
echo "Usage: $0 [-cdvspnt] [-b properties-file.csproj] [--no-gui]"
echo ""
echo "-c clean instead of building"
echo "-d build Debug configuration"
echo "-v verbose output"
echo "-p create packages after building"
echo "-n create nightly packages after building"
echo "-t create a portable package (experimental, Linux only)"
echo "-s update submodules"
echo "-b custom build properties file"
echo "--no-gui build with GUI disabled"
}
while getopts "cdvpnstb:-:" opt
do
case $opt in
c)
CLEAN=true
;;
d)
CONFIGURATION="Debug"
;;
v)
PARAMS+=(/verbosity:detailed)
;;
p)
PACKAGES=true
;;
n)
NIGHTLY=true
PACKAGES=true
;;
t)
PORTABLE=true
;;
s)
UPDATE_SUBMODULES=true
;;
b)
CUSTOM_PROP=$OPTARG
;;
-)
case $OPTARG in
"no-gui")
HEADLESS=true
;;
*)
print_help
exit 1
;;
esac
;;
\?)
print_help
exit 1
;;
esac
done
shift "$((OPTIND-1))"
# Update submodules if not initialized or if requested by the user
# Warn if not updating, but unclean
# Disabling -e to allow grep to fail
set +e
git submodule status --recursive | grep -q "^-"
SUBMODULES_NOT_INITED=$?
git submodule status --recursive | grep -q "^+"
SUBMODULES_NOT_CLEAN=$?
set -e
if $UPDATE_SUBMODULES || [ $SUBMODULES_NOT_INITED -eq 0 ]
then
echo "Updating submodules..."
git submodule update --init --recursive
elif [ $SUBMODULES_NOT_CLEAN -eq 0 ]
then
echo "Submodules are not updated. Use -s to force update."
fi
. "${ROOT_PATH}/tools/common.sh"
"${ROOT_PATH}"/tools/building/fetch_libraries.sh
if $HEADLESS
then
BUILD_TARGET=Headless
PARAMS+=(/p:GUI_DISABLED=true)
elif $ON_WINDOWS
then
BUILD_TARGET=Windows
else
BUILD_TARGET=Mono
fi
TARGET="`get_path \"$PWD/Renode.sln\"`"
# Update references to Xwt
TERMSHARP_PROJECT="${CURRENT_PATH:=.}/lib/termsharp/TermSharp.csproj"
if [ -e "$TERMSHARP_PROJECT" ]
then
sed -i.bak 's/"xwt\\Xwt\\Xwt.csproj"/"..\\xwt\\Xwt\\Xwt.csproj"/' "$TERMSHARP_PROJECT"
rm "$TERMSHARP_PROJECT.bak"
fi
# Verify Mono and mcs version on Linux and macOS
if ! $ON_WINDOWS
then
if ! [ -x "$(command -v mcs)" ]
then
echo "mcs not found. Renode requries Mono $MINIMUM_MONO or newer. Please refer to documentation for installation instructions. Exiting!"
exit 1
fi
verify_mono_version
fi
# Copy properties file according to the running OS
mkdir -p "$OUTPUT_DIRECTORY"
if [ -n "${CUSTOM_PROP}" ]; then
PROP_FILE=$CUSTOM_PROP
else
if $ON_OSX
then
PROP_FILE="$CURRENT_PATH/src/Infrastructure/src/Emulator/Cores/osx-properties.csproj"
elif $ON_LINUX
then
PROP_FILE="$CURRENT_PATH/src/Infrastructure/src/Emulator/Cores/linux-properties.csproj"
else
PROP_FILE="$CURRENT_PATH/src/Infrastructure/src/Emulator/Cores/windows-properties.csproj"
fi
fi
cp "$PROP_FILE" "$OUTPUT_DIRECTORY/properties.csproj"
# Build CCTask in Release configuration
$CS_COMPILER /p:Configuration=Release "`get_path \"$ROOT_PATH/lib/cctask/CCTask.sln\"`" > /dev/null
# clean instead of building
if $CLEAN
then
PARAMS+=(/t:Clean)
for conf in Debug Release
do
for build_target in Windows Mono Headless
do
$CS_COMPILER "${PARAMS[@]}" /p:Configuration=${conf}${build_target} "$TARGET"
done
rm -fr $OUTPUT_DIRECTORY/bin/$conf
done
exit 0
fi
# check weak implementations of core libraries
pushd "$ROOT_PATH/tools/building" > /dev/null
./check_weak_implementations.sh
popd > /dev/null
PARAMS+=(/p:Configuration=${CONFIGURATION}${BUILD_TARGET} /p:GenerateFullPaths=true)
# build
$CS_COMPILER "${PARAMS[@]}" "$TARGET"
# copy llvm library
cp src/Infrastructure/src/Emulator/LLVMDisassembler/bin/$CONFIGURATION/libllvm-disas.* output/bin/$CONFIGURATION
# build packages after successful compilation
params=""
if [ $CONFIGURATION == "Debug" ]
then
params="$params -d"
fi
if $PACKAGES
then
if $NIGHTLY
then
params="$params -n"
fi
$ROOT_PATH/tools/packaging/make_${DETECTED_OS}_packages.sh $params
fi
if $PORTABLE
then
if $ON_LINUX
then
$ROOT_PATH/tools/packaging/make_linux_portable.sh $params
else
echo "Portable packages are only available on Linux. Exiting!"
exit 1
fi
fi