Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at flake-libs 145 lines 4.1 kB view raw
1{ 2 stdenv, 3 buildPackages, 4 lib, 5 fetchzip, 6 gpm, 7 libffi, 8 libGL, 9 libX11, 10 libXext, 11 libXpm, 12 libXrandr, 13 ncurses, 14}: 15 16stdenv.mkDerivation rec { 17 pname = "fbc"; 18 version = "1.10.1"; 19 20 src = fetchzip { 21 # Bootstrap tarball has sources pretranslated from FreeBASIC to C 22 url = "https://github.com/freebasic/fbc/releases/download/${version}/FreeBASIC-${version}-source-bootstrap.tar.xz"; 23 hash = "sha256-LBROv3m1DrEfSStMbNuLC+fldYNfSS+D09bJyNMNPP0="; 24 }; 25 26 postPatch = '' 27 patchShebangs tests/warnings/test.sh 28 ''; 29 30 dontConfigure = true; 31 32 depsBuildBuild = [ 33 buildPackages.stdenv.cc 34 buildPackages.ncurses 35 buildPackages.libffi 36 ]; 37 38 buildInputs = 39 [ 40 ncurses 41 libffi 42 ] 43 ++ lib.optionals stdenv.hostPlatform.isLinux [ 44 gpm 45 libGL 46 libX11 47 libXext 48 libXpm 49 libXrandr 50 ]; 51 52 enableParallelBuilding = true; 53 54 hardeningDisable = [ 55 "format" 56 ]; 57 58 makeFlags = lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ 59 "TARGET=${stdenv.hostPlatform.config}" 60 ]; 61 62 preBuild = '' 63 export buildJobs=$NIX_BUILD_CORES 64 if [ -z "$enableParallelBuilding" ]; then 65 buildJobs=1 66 fi 67 68 echo Bootstrap an unpatched build compiler 69 make bootstrap-minimal -j$buildJobs \ 70 BUILD_PREFIX=${buildPackages.stdenv.cc.targetPrefix} LD=${buildPackages.stdenv.cc.targetPrefix}ld 71 72 echo Compile patched build compiler and host rtlib 73 make compiler -j$buildJobs \ 74 "FBC=$PWD/bin/fbc${stdenv.buildPlatform.extensions.executable} -i $PWD/inc" \ 75 BUILD_PREFIX=${buildPackages.stdenv.cc.targetPrefix} LD=${buildPackages.stdenv.cc.targetPrefix}ld 76 make rtlib -j$buildJobs \ 77 "FBC=$PWD/bin/fbc${stdenv.buildPlatform.extensions.executable} -i $PWD/inc" \ 78 ${ 79 if (stdenv.buildPlatform == stdenv.hostPlatform) then 80 "BUILD_PREFIX=${buildPackages.stdenv.cc.targetPrefix} LD=${buildPackages.stdenv.cc.targetPrefix}ld" 81 else 82 "TARGET=${stdenv.hostPlatform.config}" 83 } 84 85 echo Install patched build compiler and host rtlib to local directory 86 make install-compiler prefix=$PWD/patched-fbc 87 make install-rtlib prefix=$PWD/patched-fbc ${ 88 lib.optionalString ( 89 stdenv.buildPlatform != stdenv.hostPlatform 90 ) "TARGET=${stdenv.hostPlatform.config}" 91 } 92 make clean 93 94 echo Compile patched host everything with previous patched stage 95 buildFlagsArray+=("FBC=$PWD/patched-fbc/bin/fbc${stdenv.buildPlatform.extensions.executable} -i $PWD/inc") 96 ''; 97 98 installFlags = [ 99 "prefix=${placeholder "out"}" 100 ]; 101 102 # Tests do not work when cross-compiling even if build platform can execute 103 # host binaries, compiler struggles to find the cross compiler's libgcc_s 104 doCheck = stdenv.buildPlatform == stdenv.hostPlatform; 105 106 checkTarget = "unit-tests warning-tests log-tests"; 107 108 checkFlags = [ 109 "UNITTEST_RUN_ARGS=--verbose" # see what unit-tests are doing 110 "ABORT_CMD=false" # abort log-tests on failure 111 ]; 112 113 checkPhase = '' 114 runHook preCheck 115 116 # Some tests fail with too much parallelism 117 export maxCheckJobs=50 118 export checkJobs=$(($NIX_BUILD_CORES<=$maxCheckJobs ? $NIX_BUILD_CORES : $maxCheckJobs)) 119 if [ -z "$enableParallelChecking" ]; then 120 checkJobs=1 121 fi 122 123 # Run check targets in series, else the logs are a mess 124 for target in $checkTarget; do 125 make $target -j$checkJobs $makeFlags $checkFlags 126 done 127 128 runHook postCheck 129 ''; 130 131 meta = with lib; { 132 homepage = "https://www.freebasic.net/"; 133 description = "Multi-platform BASIC Compiler"; 134 mainProgram = "fbc"; 135 longDescription = '' 136 FreeBASIC is a completely free, open-source, multi-platform BASIC compiler (fbc), 137 with syntax similar to (and support for) MS-QuickBASIC, that adds new features 138 such as pointers, object orientation, unsigned data types, inline assembly, 139 and many others. 140 ''; 141 license = licenses.gpl2Plus; # runtime & graphics libraries are LGPLv2+ w/ static linking exception 142 maintainers = with maintainers; [ OPNA2608 ]; 143 platforms = with platforms; windows ++ linux; 144 }; 145}