git.iko.soy/typeable/nixpkgs
on master help sign in
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.

commit92ebfa13833065a23cd3479eefc2624b46ec45dd authorMatthew Bauer <mjbauer95@gmail.com> dateSat 10 Nov 2018, 14:30 (8 years ago) parentdf9334b
2 files changed+66
pkgs/development/tools/build-managers/waf/setup-hook.sh+62 pkgs/top-level/all-packages.nix+4
pkgs/development/tools/build-managers/waf/setup-hook.shnew file+62
@@ -0,0 +1,62 @@
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
pkgs/top-level/all-packages.nix+4
@@ -6203,6 +6203,10 @@ with pkgs;
62036203 volumeicon = callPackage ../tools/audio/volumeicon { };
62046204
62056205 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;
62066210
62076211 wakelan = callPackage ../tools/networking/wakelan { };
62086212