Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)

wafHook: init

The waf build system is python-based and hosted locally in each package in the executable file named "waf". Unlike CMake, it cannot generate makefiles so we end up having to override the configure, build, and install phases. I've tried to keep these as close to what's in setup.sh as possible. If there is no waf file in the root directory, then we just copy the one hosted in Nixpkgs. Otherwise the only thing you have to add to a package using Waf is "wafHook" into nativeBuildInputs. wafFlags controls the flags specifically passed to waf while configureFlags, buildFlags, and installFlags are still used as in the generic builder.

+66
+62
pkgs/development/tools/build-managers/waf/setup-hook.sh
··· 1 + wafConfigurePhase() { 2 + runHook preConfigure 3 + 4 + if ! [ -f ./waf ]; then 5 + cp @waf@ waf 6 + fi 7 + 8 + if [[ -z "${dontAddPrefix:-}" && -n "$prefix" ]]; then 9 + configureFlags="${prefixKey:---prefix=}$prefix $configureFlags" 10 + fi 11 + 12 + local flagsArray=( 13 + $configureFlags ${configureFlagsArray[@]} 14 + ${configureTargets:-configure} 15 + ) 16 + echoCmd 'configure flags' "${flagsArray[@]}" 17 + python waf "${flagsArray[@]}" 18 + 19 + runHook postConfigure 20 + } 21 + 22 + wafBuildPhase () { 23 + runHook preBuild 24 + 25 + # set to empty if unset 26 + : ${wafFlags=} 27 + 28 + local flagsArray=( 29 + ${enableParallelBuilding:+-j ${NIX_BUILD_CORES}} 30 + $wafFlags ${wafFlagsArray[@]} 31 + $buildFlags ${buildFlagsArray[@]} 32 + ${buildTargets:-build} 33 + ) 34 + 35 + echoCmd 'build flags' "${flagsArray[@]}" 36 + python waf "${flagsArray[@]}" 37 + 38 + runHook postBuild 39 + } 40 + 41 + wafInstallPhase() { 42 + runHook preInstall 43 + 44 + if [ -n "$prefix" ]; then 45 + mkdir -p "$prefix" 46 + fi 47 + 48 + local flagsArray=( 49 + $wafFlags ${wafFlagsArray[@]} 50 + $installFlags ${installFlagsArray[@]} 51 + ${installTargets:-install} 52 + ) 53 + 54 + echoCmd 'install flags' "${flagsArray[@]}" 55 + python waf "${flagsArray[@]}" 56 + 57 + runHook postInstall 58 + } 59 + 60 + configurePhase=wafConfigurePhase 61 + buildPhase=wafBuildPhase 62 + installPhase=wafInstallPhase
+4
pkgs/top-level/all-packages.nix
··· 6203 6203 volumeicon = callPackage ../tools/audio/volumeicon { }; 6204 6204 6205 6205 waf = callPackage ../development/tools/build-managers/waf { python = python3; }; 6206 + wafHook = makeSetupHook { 6207 + deps = [ python ]; 6208 + substitutions = { inherit waf; }; 6209 + } ../development/tools/build-managers/waf/setup-hook.sh; 6206 6210 6207 6211 wakelan = callPackage ../tools/networking/wakelan { }; 6208 6212