forked from renode/renode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·700 lines (639 loc) · 20.6 KB
/
build.sh
File metadata and controls
executable file
·700 lines (639 loc) · 20.6 KB
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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
#!/usr/bin/env bash
set -u
set -e
USE_PARALLEL=false
if command -v env_parallel &> /dev/null
then
# The env_parallel command stores ignored values in this variable
# so it needs to be defined for the `set -u` flag to not error
PARALLEL_IGNORED_NAMES=""
# Source the env_parallel init script
. env_parallel.bash
# If the `--session` start fails it mean that the installed
# version of GNU parallel is too old to have the features we need
if env_parallel --session &> /dev/null
then
USE_PARALLEL=true
fi
fi
ROOT_PATH="$(cd "$(dirname $0)"; echo $PWD)"
export ROOT_PATH
OUTPUT_DIRECTORY="$ROOT_PATH/output"
EXPORT_DIRECTORY=""
UPDATE_SUBMODULES=false
CONFIGURATION="Release"
BUILD_PLATFORM="Any CPU"
CLEAN=false
PACKAGES=false
NIGHTLY=false
PORTABLE=false
UI=false
ANALOG=false
SOURCE_PACKAGE=false
HEADLESS=false
SKIP_FETCH=false
EXTERNAL_LIB_ONLY=false
TLIB_EXPORT_COMPILE_COMMANDS=false
EXTERNAL_LIB_ARCH=""
NET=true
TFM="net8.0"
GENERATE_DOTNET_BUILD_TARGET=true
PARAMS=()
CUSTOM_PROP=
NET_FRAMEWORK_VER=
RID="linux-x64"
HOST_ARCH=
# Common cmake flags
CMAKE_COMMON="${RENODE_EXTRA_CMAKE_ARGS:-}"
function print_help() {
echo "Usage: $0 [-cdvspnt] [-b properties-file.csproj] [--no-gui] [--skip-fetch] [--profile-build] [--external-lib-only] [--tlib-export-compile-commands] [--external-lib-arch <arch>] [--host-arch i386|aarch64] [--source-package] [--ui] [-- <ARGS>]"
echo
echo "-c clean instead of building"
echo "-d build Debug configuration"
echo "-v verbose output"
echo "-p create packages after building"
echo "-t create a portable package"
echo "--source-package build a source package (dotnet on Linux only)"
echo "-n tag built packages as nightly"
echo "-s update submodules"
echo "-b custom build properties file"
echo "-o custom output directory"
echo "--skip-fetch skip fetching submodules and additional resources"
echo "--no-gui build with GUI disabled"
echo "--force-net-framework-version build against different version of .NET Framework than specified in the solution"
echo "--net build with dotnet"
echo "--mono build with mono"
echo "-B bundle target runtime (default value: $RID, requires --net, -t)"
echo "-F select the target framework for which Renode should be built (default value: $TFM)"
echo "--profile-build build optimized for profiling"
echo "--tlib-coverage build tlib with coverage reporting"
echo "--external-lib-only only build external libraries"
echo "--external-lib-arch build only single arch (implies --external-lib-only)"
echo "--tlib-export-compile-commands build tlibs with 'compile_commands.json' (requires --external-lib-arch)"
echo "--host-arch build with a specific tcg host architecture (default: i386)"
echo "--skip-dotnet-target-generation don't generate 'Directory.Build.targets' file, useful when experimenting with different build settings"
echo "--tcg-opcode-backtrace collect a backtrace for each emitted TCG opcode, to track internal TCG errors (implies Debug configuration)"
echo "--ui rebuild the web-based UI"
echo "--analog build with analog simulation enabled"
echo "<ARGS> arguments to pass to the dotnet build system"
}
while getopts "cdvpnstb:o:B:F:-:" opt
do
case $opt in
c)
CLEAN=true
;;
d)
CONFIGURATION="Debug"
;;
v)
PARAMS+=(verbosity:detailed)
;;
p)
PACKAGES=true
;;
n)
NIGHTLY=true
;;
t)
PORTABLE=true
;;
s)
UPDATE_SUBMODULES=true
;;
b)
CUSTOM_PROP=$OPTARG
;;
o)
EXPORT_DIRECTORY=$OPTARG
echo "Setting the output directory to $EXPORT_DIRECTORY"
;;
B)
RID=$OPTARG
;;
F)
if ! $NET; then
echo "-F requires --net being set"
exit 1
fi
TFM=$OPTARG
;;
-)
case $OPTARG in
"no-gui")
HEADLESS=true
;;
"skip-fetch")
SKIP_FETCH=true
;;
"force-net-framework-version")
shift $((OPTIND-1))
NET_FRAMEWORK_VER="p:TargetFrameworkVersion=v$1"
PARAMS+=("$NET_FRAMEWORK_VER")
OPTIND=2
;;
"net")
echo "'--net' flag is a default, use --mono to target an old runtime"
;;
"mono")
NET=false
TFM="net462"
;;
"source-package")
SOURCE_PACKAGE=true
;;
"profile-build")
CMAKE_COMMON+=" -DPROFILING_BUILD=ON"
;;
"external-lib-only")
EXTERNAL_LIB_ONLY=true
;;
"external-lib-arch")
# This only makes sense with '--external-lib-only' set; it might as well imply it
EXTERNAL_LIB_ONLY=true
shift $((OPTIND-1))
EXTERNAL_LIB_ARCH=$1
OPTIND=2
;;
"tlib-export-compile-commands")
if [ -z $EXTERNAL_LIB_ARCH ]; then
echo "--tlib-export-compile-commands requires --external-lib-arch being set"
exit 1
fi
TLIB_EXPORT_COMPILE_COMMANDS=true
;;
"tlib-coverage")
CMAKE_COMMON+=" -DCOVERAGE_REPORTING=ON"
;;
"host-arch")
shift $((OPTIND-1))
if [ $1 == "aarch64" ] || [ $1 == "arm64" ]; then
HOST_ARCH="aarch64"
elif [ $1 == "i386" ] || [ $1 == "x86" ] || [ $1 == "x86_64" ]; then
HOST_ARCH="i386"
else
echo "host architecture $1 not supported. Supported architectures are i386 and aarch64"
exit 1
fi
OPTIND=2
;;
"skip-dotnet-target-generation")
GENERATE_DOTNET_BUILD_TARGET=false
;;
"tcg-opcode-backtrace")
# Doesn't make sense without debug.
CONFIGURATION="Debug"
CMAKE_COMMON+=" -DTCG_OPCODE_BACKTRACE=ON"
;;
"ui")
UI=true
;;
"analog")
ANALOG=true
;;
*)
print_help
exit 1
;;
esac
;;
\?)
print_help
exit 1
;;
esac
done
shift "$((OPTIND-1))"
PARAMS+=(
# By default use CC as Compiler- and LinkerPath, and AR as ArPath
${CC:+"p:CompilerPath=$CC"}
${CC:+"p:LinkerPath=$CC"}
${AR:+"p:ArPath=$AR"}
# But allow users to override it
"$@"
)
if [ -n "${PLATFORM:-}" ]
then
echo "PLATFORM environment variable is currently set to: >>$PLATFORM<<"
echo "This might cause problems during the build."
echo "Please clear it with:"
echo ""
echo " unset PLATFORM"
echo ""
echo " and run the build script again."
exit 1
fi
# We can only update parts of this repository if Renode is built from within the git tree
if [ ! -e .git ]
then
SKIP_FETCH=true
UPDATE_SUBMODULES=false
fi
if $SKIP_FETCH
then
echo "Skipping init/update of submodules"
else
# 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
fi
. "${ROOT_PATH}/tools/common.sh"
if $SKIP_FETCH
then
echo "Skipping library fetch"
else
"${ROOT_PATH}"/tools/building/fetch_libraries.sh
fi
if $HEADLESS
then
BUILD_TARGET=Headless
PARAMS+=(p:GUI_DISABLED=true)
elif $ON_WINDOWS
then
BUILD_TARGET=Windows
TFM="$TFM-windows10.0.17763.0"
else
BUILD_TARGET=Mono
fi
if [[ -z "$HOST_ARCH" ]]; then
HOST_ARCH="$DETECTED_ARCH"
fi
# Set correct RID
if $ON_LINUX; then
RID="linux-x64"
UI_RID="linux_x64"
if [[ $HOST_ARCH == "aarch64" ]]; then
RID="linux-arm64"
UI_RID="linux_arm64"
fi
elif $ON_OSX; then
RID="osx-x64"
UI_RID="mac_x64"
if [[ $HOST_ARCH == "aarch64" ]]; then
RID="osx-arm64"
UI_RID="mac_arm64"
fi
elif $ON_WINDOWS; then
RID="win-x64"
UI_RID="win_x64"
fi
if [[ $GENERATE_DOTNET_BUILD_TARGET = true ]]; then
if $ON_WINDOWS; then
# CsWinRTAotOptimizerEnabled is disabled due to a bug in dotnet-sdk.
# See: https://github.com/dotnet/sdk/issues/44026
OS_SPECIFIC_TARGET_OPTS='<CsWinRTAotOptimizerEnabled>false</CsWinRTAotOptimizerEnabled>'
fi
cat <<EOF > "$(get_path "$PWD/Directory.Build.targets")"
<Project>
<PropertyGroup>
<TargetFrameworks>$TFM</TargetFrameworks>
${OS_SPECIFIC_TARGET_OPTS:+${OS_SPECIFIC_TARGET_OPTS}}
</PropertyGroup>
</Project>
EOF
fi
if $NET
then
export DOTNET_CLI_TELEMETRY_OPTOUT=1
CS_COMPILER="dotnet build"
TARGET="`get_path \"$PWD/Renode_NET.sln\"`"
BUILD_TYPE="dotnet"
PARAMS+=(p:NET=true)
else
TARGET="`get_path \"$PWD/Renode.sln\"`"
BUILD_TYPE="mono"
fi
OUT_BIN_DIR="$(get_path "output/bin/${CONFIGURATION}")"
BUILD_TYPE_FILE=$(get_path "${OUT_BIN_DIR}/build_type")
# Verify Mono and mcs version on Linux and macOS
if ! $ON_WINDOWS && ! $NET
then
if ! [ -x "$(command -v mcs)" ]
then
MINIMUM_MONO=`get_min_mono_version`
echo "mcs not found. Renode requires 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"
if ! $NET
then
# Assets files are not deleted during `dotnet clean`, as it would confuse intellisense per comment in https://github.com/NuGet/Home/issues/7368#issuecomment-457411014,
# but we need to delete them to build Renode again for .NETFramework since `project.assets.json` doesn't play well if project files share the same directory.
# If `Renode_NET.sln` is picked for OmniSharp, it will trigger reanalysis of the project after removing assets files.
# We don't remove these files as part of `clean` target, because other intermediate files are well separated between .NET and .NETFramework
# and enforcing `clean` every time before rebuilding would slow down the build process on both frameworks.
find $ROOT_PATH -type f -name 'project.assets.json' -delete
fi
CORES_PATH="$ROOT_PATH/src/Infrastructure/src/Emulator/Cores"
UI_PATH="$ROOT_PATH/src/UI"
# clean instead of building
if $CLEAN
then
remove_dir() {
output_dir="$(get_path "$1")"
if [[ -d "${output_dir}" ]]
then
echo "Removing: ${output_dir}"
rm -rf "${output_dir}"
fi
}
for project_dir in $(find "$(get_path "${ROOT_PATH}/src")" -iname '*.csproj' -exec dirname '{}' \;)
do
for dir in {bin,obj}/{Debug,Release}
do
remove_dir "${project_dir}/${dir}"
done
done
# Manually clean the main output directories as it's location is non-standard
remove_dir "${OUTPUT_DIRECTORY}/bin"
exit 0
fi
# Check if a full rebuild is needed
if [[ -f "$BUILD_TYPE_FILE" ]]
then
if [[ "$(cat "$BUILD_TYPE_FILE")" != "$BUILD_TYPE" ]]
then
echo "Attempted to build Renode in a different configuration than the previous build"
echo "Please run '$0 -c' to clean the previous build before continuing"
exit 1
fi
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 p:Platform="\"$BUILD_PLATFORM\"" p:Architecture="$HOST_ARCH")
if $ANALOG; then
PARAMS+=(p:ANALOG=true)
fi
# Paths for tlib
CORES_BUILD_PATH="$CORES_PATH/obj/$CONFIGURATION"
CORES_BIN_PATH="$CORES_PATH/bin/$CONFIGURATION"
# Cmake generator, handled in their own variable since the names contain spaces
if $ON_WINDOWS
then
CMAKE_GEN="-GMinGW Makefiles"
else
CMAKE_GEN="-GUnix Makefiles"
fi
# Macos architecture flags, to make rosetta work properly
if $ON_OSX
then
CMAKE_COMMON+=" -DCMAKE_OSX_ARCHITECTURES=x86_64"
if [ $HOST_ARCH == "aarch64" ]; then
CMAKE_COMMON+=" -DCMAKE_OSX_ARCHITECTURES=arm64"
fi
fi
# This list contains all cores that will be built.
# If you are adding a new core or endianness add it here to have the correct tlib built
CORES=(arm.le arm.be arm64.le arm-m.le arm-m.be ppc.le ppc.be ppc64.le ppc64.be i386.le x86_64.le riscv.le riscv64.le sparc.le sparc.be xtensa.le)
# if '--external-lib-arch' was used - pick the first matching one
if [[ ! -z $EXTERNAL_LIB_ARCH ]]; then
NONE_MATCHED=true
for potential_match in "${CORES[@]}"; do
if [[ $potential_match == "$EXTERNAL_LIB_ARCH"* ]]; then
CORES=("$potential_match")
echo "Compiling external lib for $potential_match"
NONE_MATCHED=false
break
fi
done
if $NONE_MATCHED ; then
echo "Failed to match any external lib arch"
exit 1
fi
fi
# build KVM - currently it's supported only on Linux
if $ON_LINUX && [[ "$HOST_ARCH" == "i386" ]] && [[ -z $EXTERNAL_LIB_ARCH || "${CORES[@]}" == "i386kvm.le" ]]; then
KVM_CORE_DIR="$CORES_BUILD_PATH/virt"
mkdir -p $KVM_CORE_DIR
pushd "$KVM_CORE_DIR" > /dev/null
cmake "$CORES_PATH/virt"
cmake --build . -j$(nproc)
CORE_BIN_DIR=$CORES_BIN_PATH/lib
mkdir -p $CORE_BIN_DIR
cp -u -v *.so $CORE_BIN_DIR/
popd > /dev/null
fi
build_core () {
set -e
core_config=$1
if [[ $core_config == *"kvm"* ]]; then
continue
fi
CORE="$(echo $core_config | cut -d '.' -f 1)"
ENDIAN="$(echo $core_config | cut -d '.' -f 2)"
BITS=32
# Check if core is 64-bit
if [[ $CORE =~ "64" ]]; then
BITS=64
fi
# Core specific flags to cmake
CMAKE_CONF_FLAGS="-DTARGET_ARCH=$CORE -DTARGET_WORD_SIZE=$BITS -DCMAKE_BUILD_TYPE=$CONFIGURATION"
CORE_DIR=$CORES_BUILD_PATH/$CORE/$ENDIAN
mkdir -p $CORE_DIR
pushd "$CORE_DIR" > /dev/null
if [[ $ENDIAN == "be" ]]; then
CMAKE_CONF_FLAGS+=" -DTARGET_WORDS_BIGENDIAN=1"
fi
if [[ "$TLIB_EXPORT_COMPILE_COMMANDS" = true ]]; then
CMAKE_CONF_FLAGS+=" -DCMAKE_EXPORT_COMPILE_COMMANDS=1"
fi
cmake "$CMAKE_GEN" $CMAKE_COMMON $CMAKE_CONF_FLAGS -DHOST_ARCH=$HOST_ARCH $CORES_PATH
cmake --build . -j"$(nproc)"
CORE_BIN_DIR=$CORES_BIN_PATH/lib
mkdir -p $CORE_BIN_DIR
if $ON_OSX; then
# macos `cp` does not have the -u flag
cp -v tlib/*.so $CORE_BIN_DIR/
else
cp -u -v tlib/*.so $CORE_BIN_DIR/
fi
# copy compile_commands.json to tlib directory
if [[ "$TLIB_EXPORT_COMPILE_COMMANDS" = true ]]; then
command cp -v -f $CORE_DIR/compile_commands.json $CORES_PATH/tlib/
fi
popd > /dev/null
}
# build tlib
if $USE_PARALLEL
then
echo "Starting parallel tlib build"
env_parallel build_core ::: "${CORES[@]}"
env_parallel --end-session
else
for core_config in "${CORES[@]}"
do
build_core $core_config
done
fi
if $EXTERNAL_LIB_ONLY
then
exit 0
fi
# build
eval "$CS_COMPILER $(build_args_helper "${PARAMS[@]}") $TARGET"
echo -n "$BUILD_TYPE" > "$BUILD_TYPE_FILE"
# copy llvm library
LLVM_LIB="libllvm-disas"
if [[ $HOST_ARCH == "aarch64" ]]; then
# aarch64 host binaries have a different name
LLVM_LIB="libllvm-disas-aarch64"
fi
if [[ "${DETECTED_OS}" == "windows" ]]; then
LIB_EXT="dll"
elif [[ "${DETECTED_OS}" == "osx" ]]; then
LIB_EXT="dylib"
else
LIB_EXT="so"
fi
cp lib/resources/llvm/$LLVM_LIB.$LIB_EXT $OUT_BIN_DIR/libllvm-disas.$LIB_EXT
# on arm64 macOS System.Drawing.Common can't find libgdiplus so we symlink it to the output directory
# this is only used for `FrameBufferTester`
if [[ $RID == "osx-arm64" ]]; then
GDIPLUS_PATH="/opt/homebrew/lib/libgdiplus.dylib"
if [ -e $GDIPLUS_PATH ]; then
# For some reason System.Drawing.Common does not search the binary root when running from a source build
# but does for a package, so just link it to both locations so the packaging scripts do not have to be updated
ln -s -f $GDIPLUS_PATH $OUT_BIN_DIR/runtimes/osx-arm64/native/libgdiplus.dylib
mkdir -p $OUT_BIN_DIR/osx-arm64
ln -s -f $GDIPLUS_PATH $OUT_BIN_DIR/osx-arm64/libgdiplus.dylib
else
echo "libgdiplus.dylib not found by build.sh, FrameBufferTester might not work"
fi
fi
BIN_EXT=""
if [[ "$DETECTED_OS" == "windows" ]]; then
BIN_EXT=".exe"
fi
UI_BIN="$OUT_BIN_DIR/renode-ui$BIN_EXT"
# `UI_BIN`'s base goes through `cygwin -aw` on Windows, so it's already absolute
# The path starts with a drive letter on Windows, so we have to special-case it
if [[ "$UI_BIN" != "/"* ]] && ! $ON_WINDOWS; then
UI_BIN="$PWD/$UI_BIN"
fi
if $UI; then
NO_COLOR=true "$UI_PATH/scripts/build_neutralino.sh"
cp "$UI_PATH/neutralino/dist/renode-ui/renode-ui-$UI_RID$BIN_EXT" "$UI_BIN"
fi
if $ANALOG; then
$ROOT_PATH/src/Analog/scripts/build_ms_sim.sh
fi
# build packages after successful compilation
params=""
if [ $CONFIGURATION == "Debug" ]
then
params="$params -d"
fi
if [ -n "$EXPORT_DIRECTORY" ]
then
if [ "${DETECTED_OS}" != "linux" ]
then
echo "Custom output directory is currently available on Linux only"
exit 1
fi
$ROOT_PATH/tools/packaging/export_${DETECTED_OS}_workdir.sh $EXPORT_DIRECTORY $params
echo "Renode built to $EXPORT_DIRECTORY"
fi
if $NIGHTLY
then
params="$params -n"
fi
if $SOURCE_PACKAGE
then
if $NET && $ON_LINUX
then
# Source package bundles nuget dependencies required for building the dotnet version of Renode
# so it can only be built when using dotnet. The generated package can also be used with Mono/.NETFramework
# Source packages are best built first, so it does not have to copy and then delete the packages from the `output` directory
$ROOT_PATH/tools/packaging/make_source_package.sh $params
else
echo "Source package can only be built using .NET on Linux. Exiting!"
exit 1
fi
fi
if $PACKAGES
then
export UI_BIN
if $NET
then
# dotnet package on linux uses a separate script
if $ON_LINUX
then
# maxcpucount:1 to avoid an error with multithreaded publish
eval "dotnet publish -maxcpucount:1 -f $TFM --self-contained false $(build_args_helper "${PARAMS[@]}") $TARGET"
export RID TFM
$ROOT_PATH/tools/packaging/make_linux_package.sh $params
elif $ON_WINDOWS
then
# No Non portable dotnet package on windows yet
echo "Only portable dotnet packages are supported on windows. Rerun build.sh with -t flag to build portable"
exit 1
elif $ON_OSX
then
# No Non portable dotnet package on macOS
echo "Only portable dotnet packages are supported on macOS. Rerun build.sh with -t flag to build portable"
exit 1
fi
else
if $ON_WINDOWS
then
# Only dotnet packages are supported on Windows
echo "Only dotnet packages are supported on Windows. Rerun build.sh with --net -t to build a Windows package"
else
$ROOT_PATH/tools/packaging/make_${DETECTED_OS}_mono_packages.sh $params
fi
fi
fi
if $PORTABLE
then
export UI_BIN
PARAMS+=(p:PORTABLE=true)
if $NET
then
# maxcpucount:1 to avoid an error with multithreaded publish
echo "RID = $RID"
eval "dotnet publish -maxcpucount:1 -r $RID -f $TFM --self-contained true $(build_args_helper "${PARAMS[@]}") $TARGET"
export RID TFM
$ROOT_PATH/tools/packaging/make_${DETECTED_OS}_portable.sh $params
else
if $ON_LINUX
then
$ROOT_PATH/tools/packaging/make_linux_mono_portable.sh $params
else
echo "Portable packages for Mono are only available on Linux. Exiting!"
exit 1
fi
fi
fi