This repository has been archived by the owner on Jun 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 39
/
build.sh
executable file
·151 lines (140 loc) · 3.33 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
#! /bin/sh
set -e
# build.sh
#
# FRT - A Godot platform targeting single board computers
# Copyright (c) 2017-2023 Emanuele Fornara
# SPDX-License-Identifier: MIT
#
# WARNING:
# This script is quite complex.
# A better place to start is scripts/cc.sh
usage() {
cat <<END
usage: build.sh [-a arch] [-j jobs] [-v] [-p]
END
exit 1
}
die() {
echo "build.sh: $1."
exit 1
}
parse_godot_version() {
gver=`echo $srcdir | cut -b 5- | sed 's/\///g'`
if [ ! -f $srcdir/suffix.txt ] ; then
unset GODOT_VERSION_STATUS
gverext=$gver
else
gsta=`cat $srcdir/suffix.txt`
case $gsta in
alpha*) shortsta=a ; gstaid=`echo $gsta | cut -b 6-` ;;
beta*) shortsta=b ; gstaid=`echo $gsta | cut -b 5-` ;;
rc*) shortsta=c ; gstaid=`echo $gsta | cut -b 3-` ;;
*) die "unsupported godot status: $gsta"
esac
export GODOT_VERSION_STATUS=$gsta
gverext="$gver$shortsta$gstaid"
fi
}
parse_frt_version() {
frtcc="$srcdir/platform/frt/frt.cc"
[ -f $frtcc ] || die "$frtcc not found"
fver=`grep "define FRT_VERSION" $frtcc \
| grep -o '".*"' \
| sed 's/[\."]//g'`
fsta=`grep "define FRT_STATUS" $frtcc \
| grep -o '".*"' \
| sed 's/"//g'`
if [ $fsta = stable ] ; then
fverext=$fver
else
commitid=`git -C $srcdir/platform/frt rev-parse HEAD | cut -b -7`
shortsta=`echo $fsta | cut -b -1`
fverext="$fver$shortsta-$commitid"
fi
}
build() {
local patch
echo "Building frt:$fverext tag:$gverext arch:$arch..."
if [ $arch = arm64v8 -a $fver = 216 ] ; then patch="CCFLAGS=-DNO_THREADS" ; fi
( cd $srcdir ; nice scons \
platform=frt \
frt_arch=$arch \
frt_cross=auto \
use_llvm=yes \
use_static_cpp=yes \
$patch \
$buildopts $verboseopts $jobsopts
)
}
publish() {
echo "Publishing..."
[ -d $exportdir ] || die "export directory $exportdir not found."
bin=$exportdir/frt_${fverext}_${gverext}_${arch}.bin
cp $srcdir/bin/$srcbin $bin
$stripcmd $bin
ls -l $bin
}
arch=auto
exportdir=releases
while getopts a:e:j:vpd name ; do
case $name in
a) arch="$OPTARG" ;;
e) exportdir="$OPTARG" ;;
j) jobsopts="-j $OPTARG" ;;
v) verboseopts="verbose=yes" ;;
p) publish=1 ;;
?) usage ;;
esac
done
shift $(expr $OPTIND - 1 )
if [ $arch = auto ] ; then
if [ -f /usr/bin/arm-linux-gnueabihf-strip ] ; then
if [ -f /etc/dpkg/origins/raspbian ] ; then
arch=arm32v6
else
arch=arm32v7
fi
elif [ -f /usr/bin/aarch64-linux-gnu-strip ] ; then
arch=arm64v8
else
arch=amd64
fi
fi
case $arch in
arm32v6) stripcmd="arm-linux-gnueabihf-strip" ;;
arm32v7) stripcmd="arm-linux-gnueabihf-strip" ;;
arm64v8) stripcmd="aarch64-linux-gnu-strip" ;;
amd64) stripcmd="x86_64-linux-gnu-strip" ;;
*) die "invalid arch: $arch"
esac
export BUILD_NAME=frt
while [ $# -gt 0 ] ; do
srcdir=$1
case $srcdir in
tag_*)
[ -d $srcdir ] || die "tag directory $srcdir not found"
parse_godot_version
parse_frt_version
case $gver in
2*)
buildopts="target=release tools=no"
srcbin="godot.frt.opt.llvm.$arch"
;;
3*)
buildopts="target=release tools=no module_webm_enabled=no"
srcbin="godot.frt.opt.llvm.$arch"
;;
4*)
buildopts="target=template_release optimize=speed debug_symbols=no"
srcbin="godot.frt.template_release.auto.llvm.$arch"
;;
*) die "unsupported godot version: $gver"
esac
build
if [ ! -z "$publish" ] ; then publish ; fi
;;
*) die "invalid tag $srcdir"
esac
shift
done