5353# remote name will default to 'other' if the --repo option was given.
5454# remote name will default to 'origin' if the --repo option was not given.
5555#
56+ # --recipe name
57+ # specify which build recipe to use. Not all recipes are supported on all targets.
58+ # -gcc-5.2.0
59+ # -gcc-7.1.0
60+ # -gcc-7.3.0
61+ # -gcc-8.1.0
62+ #
5663# Requirements:
5764# - MSYS environment on Windows with: bash, wget/curl, zip, unzip, patch, make, findutils
5865# (win32/win64 builds need to be able to run ./configure scripts, to build libffi)
7481set -e
7582
7683usage () {
77- echo " usage: ./build.sh dos|linux-x86|linux-x86_64|win32|win32-mingworg|win64 <fbc commit id> [--offline] [--repo url] [--remote name]"
84+ echo " usage: ./build.sh dos|linux-x86|linux-x86_64|win32|win32-mingworg|win64 <fbc commit id> [--offline] [--repo url] [--remote name] [--recipe name] "
7885 exit 1
7986}
8087
@@ -95,6 +102,10 @@ case $arg in
95102 remote_name=" $2 "
96103 shift ; shift
97104 ;;
105+ --recipe)
106+ recipe_name=" $2 "
107+ shift ; shift
108+ ;;
98109dos|linux-x86|linux-x86_64|win32|win64)
99110 target=" $1 "
100111 fbtarget=$target
@@ -128,6 +139,14 @@ else
128139 remote_name=${remote_name:- origin}
129140fi
130141
142+ # check recipe name
143+ # TODO: error on invalid combination of target and recipe
144+ if [ ! -z " $recipe_name " ]; then
145+ recipe=$recipe_name
146+ else
147+ recipe=" "
148+ fi
149+
131150echo " building FB-$target (uname = ` uname` , uname -m = ` uname -m` )"
132151echo " from repository: https://github.com/freebasic/fbc.git"
133152if [ ! -z " $repo_url " ]; then
@@ -170,7 +189,7 @@ cd ../..
170189
171190cd build
172191
173- buildinfo=../output/buildinfo-$target .txt
192+ buildinfo=../output/buildinfo-$target$recipe .txt
174193echo " fbc $fbccommit $target , build based on:" > $buildinfo
175194echo >> $buildinfo
176195
@@ -224,15 +243,41 @@ get_mingww64_toolchain() {
224243 bits=" $1 "
225244 arch=" $2 "
226245
227- gccversion=5.2.0
228- mingwbuildsrev=rev0
246+ case " $recipe " in
247+ -gcc-8.1.0)
248+ gccversion=8.1.0
249+ mingwbuildsrev=rev0
250+ mingwruntime=v6
251+ ;;
252+ -gcc-7.3.0)
253+ gccversion=7.3.0
254+ mingwbuildsrev=rev0
255+ mingwruntime=v5
256+ ;;
257+ -gcc-7.1.0)
258+ gccversion=7.1.0
259+ mingwbuildsrev=rev2
260+ mingwruntime=v5
261+ ;;
262+ -gcc-5.2.0)
263+ gccversion=5.2.0
264+ mingwbuildsrev=rev0
265+ mingwruntime=v4
266+ ;;
267+ * )
268+ gccversion=5.2.0
269+ mingwbuildsrev=rev0
270+ mingwruntime=v4
271+ ;;
272+ esac
273+
229274 dir=Toolchains%20targetting%20Win$bits /Personal%20Builds/mingw-builds/$gccversion /threads-win32/sjlj/
230- file=$arch -$gccversion -release-win32-sjlj-rt_v4 -$mingwbuildsrev .7z
275+ file=$arch -$gccversion -release-win32-sjlj-rt_ $mingwruntime -$mingwbuildsrev .7z
231276
232277 mkdir -p ../input/MinGW-w64
233278 download " MinGW-w64/$file " " http://sourceforge.net/projects/mingw-w64/files/$dir$file /download"
234279
235- srcfile=src-$gccversion -release-rt_v4 -$mingwbuildsrev .tar.7z
280+ srcfile=src-$gccversion -release-rt_ $mingwruntime -$mingwbuildsrev .tar.7z
236281 download " MinGW-w64/$srcfile " " http://sourceforge.net/projects/mingw-w64/files/Toolchain%20sources/Personal%20Builds/mingw-builds/$gccversion /$srcfile /download"
237282
238283 7z x " ../input/MinGW-w64/$file " > /dev/null
@@ -348,7 +393,7 @@ win64)
348393 ;;
349394esac
350395
351- bootfb_title=FreeBASIC-1.05 .0-$fbtarget
396+ bootfb_title=FreeBASIC-1.06 .0-$fbtarget
352397
353398case $fbtarget in
354399linux* )
387432case $fbtarget in
388433win32|win64)
389434 # libffi sources
435+ # TODO : new libffi package? at https://github.com/libffi/libffi/releases/download/v3.3-rc0/libffi-3.3-rc0.tar.gz
390436 libffi_title=libffi-3.2.1
391437 libffi_package=" ${libffi_title} .tar.gz"
392438 download " $libffi_package " " ftp://sourceware.org/pub/libffi/$libffi_package "
@@ -481,17 +527,32 @@ linuxbuild() {
481527libffibuild () {
482528
483529 # do we already have the files we need?
484- if [ -f " ../input/$libffi_title /$target /ffi.h" ]; then
485- if [ -f " ../input/$libffi_title /$target /ffitarget.h" ]; then
486- if [ -f " ../input/$libffi_title /$target /libffi.a" ]; then
530+ if [ -f " ../input/$libffi_title /$target$recipe /ffi.h" ]; then
531+ if [ -f " ../input/$libffi_title /$target$recipe /ffitarget.h" ]; then
532+ if [ -f " ../input/$libffi_title /$target$recipe /libffi.a" ]; then
487533 echo
488- echo " using cached libffi: $libffi_title /$target "
534+ echo " using cached libffi: $libffi_title /$target$recipe "
489535 echo
490536 return
491537 fi
492538 fi
493539 fi
494540
541+ # just grab the files we need from the package?
542+ # TODO : maybe once libffi 3.3 is released, we can go back
543+ # to building libffi ourselves.
544+
545+ # copy files from opt/lib/libffi-3.2.1
546+ case " $recipe " in
547+ -gcc-7.1.0|-gcc-7.3.0|-gcc-8.1.0)
548+ mkdir -p ../input/$libffi_title /$target$recipe
549+ cp opt/lib/libffi-3.2.1/include/ffi.h ../input/$libffi_title /$target$recipe
550+ cp opt/lib/libffi-3.2.1/include/ffitarget.h ../input/$libffi_title /$target$recipe
551+ cp opt/lib/libffi.a ../input/$libffi_title /$target$recipe
552+ return
553+ ;;
554+ esac
555+
495556 echo
496557 echo " building libffi"
497558 echo
@@ -508,9 +569,9 @@ libffibuild() {
508569 fi
509570 make
510571 # stash some files in the input folder to make rebuilding faster
511- mkdir -p ../../input/$libffi_title /$target
512- cp include/ffi.h include/ffitarget.h ../../input/$libffi_title /$target
513- cp .libs/libffi.a ../../input/$libffi_title /$target
572+ mkdir -p ../../input/$libffi_title /$target$recipe
573+ cp include/ffi.h include/ffitarget.h ../../input/$libffi_title /$target$recipe
574+ cp .libs/libffi.a ../../input/$libffi_title /$target$recipe
514575 cd ..
515576}
516577
@@ -520,11 +581,12 @@ windowsbuild() {
520581 origPATH=" $PATH "
521582 export PATH=" $PWD /bin:$PATH "
522583
523- libffibuild
524- case " $target " in
525- win32) cp ../input/$libffi_title /$target /ffi.h ../input/$libffi_title /$target /ffitarget.h ./i686-w64-mingw32/include;;
526- win32-mingworg) cp ../input/$libffi_title /$target /ffi.h ../input/$libffi_title /$target /ffitarget.h ./include;;
527- win64) cp ../input/$libffi_title /$target /ffi.h ../input/$libffi_title /$target /ffitarget.h ./x86_64-w64-mingw32/include;;
584+ libffibuild
585+ # copy our stored files to the build
586+ case " $target " in
587+ win32) cp ../input/$libffi_title /$target$recipe /ffi.h ../input/$libffi_title /$target$recipe /ffitarget.h ./i686-w64-mingw32/include;;
588+ win32-mingworg) cp ../input/$libffi_title /$target$recipe /ffi.h ../input/$libffi_title /$target$recipe /ffitarget.h ./include;;
589+ win64) cp ../input/$libffi_title /$target$recipe /ffi.h ../input/$libffi_title /$target$recipe /ffitarget.h ./x86_64-w64-mingw32/include;;
528590 esac
529591
530592 cd fbc
@@ -581,7 +643,7 @@ windowsbuild() {
581643 ;;
582644 esac
583645
584- cp ../input/$libffi_title /$target /libffi.a fbc/lib/$fbtarget
646+ cp ../input/$libffi_title /$target$recipe /libffi.a fbc/lib/$fbtarget
585647
586648 # Reduce .exe sizes by dropping debug info
587649 # (this was at least needed for MinGW.org's gdb, and probably nothing else,
@@ -595,8 +657,8 @@ windowsbuild() {
595657 cd fbc
596658 case " $target " in
597659 win32|win64)
598- make bindist DISABLE_DOCS=1
599- make bindist ENABLE_STANDALONE=1
660+ make bindist DISABLE_DOCS=1 FBPACKSUFFIX= $recipe
661+ make bindist ENABLE_STANDALONE=1 FBPACKSUFFIX= $recipe
600662 ;;
601663 win32-mingworg)
602664 make bindist DISABLE_DOCS=1 FBPACKSUFFIX=-mingworg
@@ -605,17 +667,21 @@ windowsbuild() {
605667 esac
606668 cd ..
607669
670+ # Only build the installer, if we are also
671+ # building the default package
672+ if [ -z " $recipe " ]; then
608673 if [ " $target " = win32 ]; then
609674 cd fbc/contrib/nsis-installer
610675 cp ../../FreeBASIC-* -win32.zip .
611676 make
612677 cd ../../..
613678 cp fbc/contrib/nsis-installer/FreeBASIC-* -win32.exe ../output
614679 fi
680+ fi
615681
616682 cp fbc/* .zip fbc/* .7z ../output
617- cp fbc/contrib/manifest/fbc-$target .lst ../output
618- cp fbc/contrib/manifest/FreeBASIC-$target .lst ../output
683+ cp fbc/contrib/manifest/fbc-$target$recipe .lst ../output
684+ cp fbc/contrib/manifest/FreeBASIC-$target$recipe .lst ../output
619685
620686 export PATH=" $origPATH "
621687 cd ..
0 commit comments