Skip to content

Commit 1a79e6f

Browse files
committed
release: build-bsd.sh
- in previous builds, a "default" package name was used which required post processing step to create packages for each distribution (different hosts or tools chains) - rework the build process to create the package directly without having to repack the tarball. - this requires the FBPACKTARGET changes in fbc/makefile
1 parent 109aa40 commit 1a79e6f

File tree

1 file changed

+91
-32
lines changed

1 file changed

+91
-32
lines changed

contrib/release/build-bsd.sh

Lines changed: 91 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -24,28 +24,46 @@
2424
# - a remote branch or tag name, must specify "remote-name/branch".
2525
#
2626
# --offline
27-
# when given, build.sh will stop with exit code 1 if the file is not already in
27+
# when given, build.sh will stop with exit code 1 if the file is not already
2828
# in the download cache.
2929
#
3030
# --repo url
31-
# specify an additional repo url to fetch in to the local repo other than the
31+
# specify an additional repo url to fetch in to the local repo other than the
3232
# official https://github.com/freebasic/fbc.git repo.
3333
#
3434
# --remote name
35-
# specifies the remote name to add and use when referring to the other repo url.
36-
# remote name will default to 'other' if the --repo option was given.
35+
# specifies the remote name to add and use when referring to the other repo
36+
# url. remote name will default to 'other' if the --repo option was given.
3737
# remote name will default to 'origin' if the --repo option was not given.
3838
#
3939
# --recipe name
40-
# not used
40+
# specify which build recipe to use:
41+
# * -freebsd-13.0-x86
42+
# * -freebsd-13.0-x86_64
43+
#
44+
# Not all recipes are supported on all targets.
4145
#
4246
# Requirements:
4347
# - gmake and other gnu tools
4448
#
4549
set -e
4650

4751
usage() {
48-
echo "usage: ./build-bsd.sh freebsd-x86|freebsd-x86_64 <fbc commit id> [--offline] [--repo url] [--remote name] [--recipe name]"
52+
echo "usage: ./build.sh target <fbc commit id> [options]"
53+
echo ""
54+
echo "target:"
55+
echo " freebsd-x86|freebsd-x86_64"
56+
echo ""
57+
echo "<fbc commit id>:"
58+
echo " commit-id hash value of the commit"
59+
echo " name-id name of the branch or tag"
60+
echo ""
61+
echo "options:"
62+
echo " --offline only use cached files, don't download from net"
63+
echo " --repo url specify alternate name for repo to fetch from"
64+
echo " in addition to origin repo"
65+
echo " --remote name specify the name to use for the alternate remote"
66+
echo " --recipe name specify a build recipe to use"
4967
exit 1
5068
}
5169

@@ -78,7 +96,7 @@ freebsd-x86|freebsd-x86_64)
7896
*)
7997
fbccommit="$1"
8098
shift
81-
;;
99+
;;
82100
esac
83101
done
84102

@@ -99,15 +117,52 @@ else
99117
fi
100118

101119
# check recipe name
102-
# TODO: error on invalid combination of target and recipe
120+
# recipe_name is from the command line option, empty string if not given
121+
# user_recipe is either explicit (from command line) or automatic (below)
103122
if [ ! -z "$recipe_name" ]; then
104-
recipe=$recipe_name
123+
user_recipe=$recipe_name
105124
else
106-
recipe=""
125+
# if no recipe given, set the default recipe for the main package
126+
user_recipe=
127+
case "$target" in
128+
win32|win64)
129+
user_recipe=-winlibs-gcc-9.3.0
130+
;;
131+
linux-arm)
132+
# named recipe wasn't given, try and figure it out ...
133+
if [ -f /etc/os-release ]; then
134+
host_os_id=$(grep -oP '(?<=^ID=).+' /etc/os-release | tr -d '"')
135+
host_os_ver=$(grep -oP '(?<=^VERSION_ID=).+' /etc/os-release | tr -d '"')
136+
fi
137+
case "$host_os_id-$host_os_ver" in
138+
raspbian-9)
139+
user_recipe=raspbian9-arm
140+
;;
141+
esac
142+
;;
143+
esac
107144
fi
108145

146+
# user_recipe may be blank and optionally start with a dash '-'
147+
# named_recipe must be blank or start with a dash '-'
148+
149+
case "$user_recipe" in
150+
""|-*)
151+
named_recipe=$user_recipe
152+
;;
153+
*)
154+
named_recipe=-$user_recipe
155+
;;
156+
esac
157+
109158
echo "building FB-$target (uname = `uname`, uname -m = `uname -m`)"
110159
echo "from repository: https://github.com/freebasic/fbc.git"
160+
if [ ! -z "$user_recipe" ]; then
161+
echo "user gave recipe '$user_recipe'"
162+
fi
163+
if [ ! -z "$named_recipe" ]; then
164+
echo "using named recipe '$named_recipe'"
165+
fi
111166
if [ ! -z "$repo_url" ]; then
112167
echo "from repository: $repo_url"
113168
fi
@@ -152,14 +207,19 @@ cd ../..
152207

153208
cd build
154209

155-
buildinfo=../output/buildinfo-$target$recipe.txt
210+
if [ ! -z "$named_recipe" ] ; then
211+
buildinfo=../output/buildinfo$named_recipe.txt
212+
else
213+
buildinfo=../output/buildinfo-$target.txt
214+
fi
156215
echo "fbc $fbccommit $target, build based on:" > $buildinfo
216+
echo "named recipe: $named_recipe" >> $buildinfo
157217
echo >> $buildinfo
158218

159219
copyfile() {
160220
srcfile="$1"
161221
dstfile="$2"
162-
222+
163223
if [ -f "$dstfile" ]; then
164224
echo "cached $dstfile"
165225
else
@@ -191,21 +251,36 @@ download() {
191251
echo "download failed"
192252
rm -f "../input/$filename"
193253
exit 1
194-
fi
254+
fi
195255
fi
196256
fi
197257

198258
echo "$filename <$url>" >> $buildinfo
199259
}
200260

201261

262+
BUILD_BOOTFBCFLAGS=
263+
AppendBOOTFBCFLAGS() {
264+
if [ ! -z "$1" ]; then
265+
if [ -z "$BUILD_BOOTFBCFLAGS" ]; then
266+
BUILD_BOOTFBCFLAGS="$1"
267+
else
268+
BUILD_BOOTFBCFLAGS="$BUILD_BOOTFBCFLAGS $1"
269+
fi
270+
fi
271+
}
272+
202273
# choose a bootstrap source for the target
203274
case $fbtarget in
204275
freebsd-x86|freebsd-x86_64)
205276
bootfb_title=FreeBASIC-1.09.0-$fbtarget
206277
;;
207278
esac
208279

280+
if [ ! -z "$named_recipe" ]; then
281+
AppendBOOTFBCFLAGS "FBPACKTARGET=${named_recipe#-}"
282+
fi
283+
209284
case $fbtarget in
210285
freebsd*)
211286
# Special case: freebsd builds use the host gcc toolchain
@@ -229,36 +304,20 @@ freebsdbuild() {
229304
echo
230305
echo "bootstrapping normal fbc"
231306
echo
232-
gmake FBC=../$bootfb_title/bin/fbc FBSHA1=$FBSHA1
307+
gmake FBC=../$bootfb_title/bin/fbc FBSHA1=$FBSHA1 $BUILD_BOOTFBCFLAGS
233308
gmake install prefix=../tempinstall
234309
echo
235310
echo "rebuilding normal fbc"
236311
echo
237312
gmake clean-compiler
238-
gmake FBC=../tempinstall/bin/fbc FBSHA1=$FBSHA1
313+
gmake FBC=../tempinstall/bin/fbc FBSHA1=$FBSHA1 $BUILD_BOOTFBCFLAGS
239314
cd ..
240315

241-
cd fbc && gmake bindist FBSHA1=$FBSHA1 && cd ..
316+
cd fbc && gmake bindist FBSHA1=$FBSHA1 $BUILD_BOOTFBCFLAGS && cd ..
242317
cp fbc/*.tar.* ../output
243318
cp fbc/contrib/manifest/FreeBASIC-$fbtarget.lst ../output
244319
}
245320

246-
libffibuild() {
247-
echo
248-
echo "building libffi"
249-
echo
250-
libffi_build="${libffi_title}-build"
251-
mkdir "$libffi_build"
252-
cd "$libffi_build"
253-
CFLAGS=-O2 ../$libffi_title/configure --disable-shared --enable-static
254-
gmake
255-
# stash some files in the input folder to make rebuilding faster
256-
mkdir -p ../../input/$libffi_title/$target$recipe
257-
cp include/ffi.h include/ffitarget.h ../../input/$libffi_title/$target$recipe
258-
cp .libs/libffi.a ../../input/$libffi_title/$target$recipe
259-
cd ..
260-
}
261-
262321
case $fbtarget in
263322
freebsd*) freebsdbuild | tee log.txt 2>&1;;
264323
esac

0 commit comments

Comments
 (0)