15 stdenv.mkDerivation rec {
20 # Bootstrap tarball has sources pretranslated from FreeBASIC to C
21 url = "https://github.com/freebasic/fbc/releases/download/${version}/FreeBASIC-${version}-source-bootstrap.tar.xz";
22 hash = "sha256-7FmyEfykOAgHaL2AG8zIgftzOszhwVzNKEqskiLGpfk=";
26 patchShebangs tests/warnings/test.sh
32 buildPackages.stdenv.cc
40 ] ++ lib.optionals stdenv.hostPlatform.isLinux [
49 enableParallelBuilding = true;
55 makeFlags = lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
56 "TARGET=${stdenv.hostPlatform.config}"
60 export buildJobs=$NIX_BUILD_CORES
61 if [ -z "$enableParallelBuilding" ]; then
65 echo Bootstrap an unpatched build compiler
66 make bootstrap-minimal -j$buildJobs \
67 BUILD_PREFIX=${buildPackages.stdenv.cc.targetPrefix} LD=${buildPackages.stdenv.cc.targetPrefix}ld
69 echo Compile patched build compiler and host rtlib
70 make compiler -j$buildJobs \
71 "FBC=$PWD/bin/fbc${stdenv.buildPlatform.extensions.executable} -i $PWD/inc" \
72 BUILD_PREFIX=${buildPackages.stdenv.cc.targetPrefix} LD=${buildPackages.stdenv.cc.targetPrefix}ld
73 make rtlib -j$buildJobs \
74 "FBC=$PWD/bin/fbc${stdenv.buildPlatform.extensions.executable} -i $PWD/inc" \
75 ${if (stdenv.buildPlatform == stdenv.hostPlatform) then
76 "BUILD_PREFIX=${buildPackages.stdenv.cc.targetPrefix} LD=${buildPackages.stdenv.cc.targetPrefix}ld"
78 "TARGET=${stdenv.hostPlatform.config}"
81 echo Install patched build compiler and host rtlib to local directory
82 make install-compiler prefix=$PWD/patched-fbc
83 make install-rtlib prefix=$PWD/patched-fbc ${lib.optionalString (stdenv.buildPlatform != stdenv.hostPlatform) "TARGET=${stdenv.hostPlatform.config}"}
86 echo Compile patched host everything with previous patched stage
87 buildFlagsArray+=("FBC=$PWD/patched-fbc/bin/fbc${stdenv.buildPlatform.extensions.executable} -i $PWD/inc")
91 "prefix=${placeholder "out"}"
94 # Tests do not work when cross-compiling even if build platform can execute
95 # host binaries, compiler struggles to find the cross compiler's libgcc_s
96 doCheck = stdenv.buildPlatform == stdenv.hostPlatform;
98 checkTarget = "unit-tests warning-tests log-tests";
101 "UNITTEST_RUN_ARGS=--verbose" # see what unit-tests are doing
102 "ABORT_CMD=false" # abort log-tests on failure
108 # Some tests fail with too much parallelism
109 export maxCheckJobs=50
110 export checkJobs=$(($NIX_BUILD_CORES<=$maxCheckJobs ? $NIX_BUILD_CORES : $maxCheckJobs))
111 if [ -z "$enableParallelChecking" ]; then
115 # Run check targets in series, else the logs are a mess
116 for target in $checkTarget; do
117 make $target -j$checkJobs $makeFlags $checkFlags
124 homepage = "https://www.freebasic.net/";
125 description = "A multi-platform BASIC Compiler";
127 FreeBASIC is a completely free, open-source, multi-platform BASIC compiler (fbc),
128 with syntax similar to (and support for) MS-QuickBASIC, that adds new features
129 such as pointers, object orientation, unsigned data types, inline assembly,
132 license = licenses.gpl2Plus; # runtime & graphics libraries are LGPLv2+ w/ static linking exception
133 maintainers = with maintainers; [ OPNA2608 ];
134 platforms = with platforms; windows ++ linux;