From f075de5c258ee9adfb300c8aee07125948b6f03d Mon Sep 17 00:00:00 2001 From: Symphorien Gibol Date: Thu, 28 Mar 2019 18:30:07 +0100 Subject: [PATCH 1/7] wafHook: let derivations use an existing waf in a non-standard location this is necessary for talloc --- doc/stdenv.xml | 6 +++--- .../tools/build-managers/waf/setup-hook.sh | 11 ++++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/doc/stdenv.xml b/doc/stdenv.xml index a3990dec052..4a5c1ba7423 100644 --- a/doc/stdenv.xml +++ b/doc/stdenv.xml @@ -2751,9 +2751,9 @@ addEnvHooks "$hostOffset" myBashFunction Overrides the configure, build, and install phases. This will run the - "waf" script used by many projects. If waf doesn’t exist, it will copy - the version of waf available in Nixpkgs wafFlags can be used to pass - flags to the waf script. + "waf" script used by many projects. If wafPath (default ./waf) doesn’t + exist, it will copy the version of waf available in Nixpkgs. wafFlags can + be used to pass flags to the waf script. diff --git a/pkgs/development/tools/build-managers/waf/setup-hook.sh b/pkgs/development/tools/build-managers/waf/setup-hook.sh index b8a448df8ef..c1ff160982a 100644 --- a/pkgs/development/tools/build-managers/waf/setup-hook.sh +++ b/pkgs/development/tools/build-managers/waf/setup-hook.sh @@ -1,8 +1,9 @@ wafConfigurePhase() { runHook preConfigure - if ! [ -f ./waf ]; then - cp @waf@ waf + if ! [ -f "${wafPath:=./waf}" ]; then + echo "copying waf to $wafPath..." + cp @waf@ "$wafPath" fi if [[ -z "${dontAddPrefix:-}" && -n "$prefix" ]]; then @@ -14,7 +15,7 @@ wafConfigurePhase() { ${configureTargets:-configure} ) echoCmd 'configure flags' "${flagsArray[@]}" - python waf "${flagsArray[@]}" + python "$wafPath" "${flagsArray[@]}" runHook postConfigure } @@ -33,7 +34,7 @@ wafBuildPhase () { ) echoCmd 'build flags' "${flagsArray[@]}" - python waf "${flagsArray[@]}" + python "$wafPath" "${flagsArray[@]}" runHook postBuild } @@ -52,7 +53,7 @@ wafInstallPhase() { ) echoCmd 'install flags' "${flagsArray[@]}" - python waf "${flagsArray[@]}" + python "$wafPath" "${flagsArray[@]}" runHook postInstall } From f23a21514c99974307aff74946ce1150d5aa3653 Mon Sep 17 00:00:00 2001 From: Symphorien Gibol Date: Thu, 28 Mar 2019 18:33:08 +0100 Subject: [PATCH 2/7] wafHook: ignore --disable-static and such options These options are forcefully added by pkgsStatic but are not understood by waf. --- .../tools/build-managers/waf/setup-hook.sh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/pkgs/development/tools/build-managers/waf/setup-hook.sh b/pkgs/development/tools/build-managers/waf/setup-hook.sh index c1ff160982a..01392c9a342 100644 --- a/pkgs/development/tools/build-managers/waf/setup-hook.sh +++ b/pkgs/development/tools/build-managers/waf/setup-hook.sh @@ -10,8 +10,21 @@ wafConfigurePhase() { configureFlags="${prefixKey:---prefix=}$prefix $configureFlags" fi - local flagsArray=( - $configureFlags ${configureFlagsArray[@]} + local flagsArray=(); + for flag in $configureFlags "${configureFlagsArray[@]}"; + do + # waf does not support these flags, but they are "blindly" added by the + # pkgsStatic overlay, for example. + if [[ $flag != "--enable-static" + && $flag != "--disable-static" + && $flag != "--enable-shared" + && $flag != "--disable-shared" ]]; + then + flagsArray=("${flagsArray[@]}" "$flag"); + fi; + done + flagsArray=( + "${flagsArray[@]}" ${configureTargets:-configure} ) echoCmd 'configure flags' "${flagsArray[@]}" From 1001d0034c5fb815fffa66bc25d88ad6761a9d00 Mon Sep 17 00:00:00 2001 From: Symphorien Gibol Date: Thu, 28 Mar 2019 19:59:16 +0100 Subject: [PATCH 3/7] wafHook: ignore configurePlatforms waf does support --build and --host, but the only effect of these options is an error message telling to use --cross-compile instead. So we ignore these flags. --- .../development/tools/build-managers/waf/setup-hook.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pkgs/development/tools/build-managers/waf/setup-hook.sh b/pkgs/development/tools/build-managers/waf/setup-hook.sh index 01392c9a342..a837bfd17f2 100644 --- a/pkgs/development/tools/build-managers/waf/setup-hook.sh +++ b/pkgs/development/tools/build-managers/waf/setup-hook.sh @@ -13,12 +13,18 @@ wafConfigurePhase() { local flagsArray=(); for flag in $configureFlags "${configureFlagsArray[@]}"; do + if [[ # waf does not support these flags, but they are "blindly" added by the # pkgsStatic overlay, for example. - if [[ $flag != "--enable-static" + $flag != "--enable-static" && $flag != "--disable-static" && $flag != "--enable-shared" - && $flag != "--disable-shared" ]]; + && $flag != "--disable-shared" + # these flags are added by configurePlatforms but waf just uses them + # to bail out in cross compilation cases + && $flag != --build=* + && $flag != --host=* + ]]; then flagsArray=("${flagsArray[@]}" "$flag"); fi; From 3d60a00c63705e2e2d6e98e72a42dd1928eac746 Mon Sep 17 00:00:00 2001 From: Symphorien Gibol Date: Thu, 28 Mar 2019 20:02:08 +0100 Subject: [PATCH 4/7] wafHook: cross compilation support for this to work, wafHook must be in nativeBuildInputs. --- pkgs/development/tools/build-managers/waf/setup-hook.sh | 2 +- pkgs/top-level/all-packages.nix | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkgs/development/tools/build-managers/waf/setup-hook.sh b/pkgs/development/tools/build-managers/waf/setup-hook.sh index a837bfd17f2..6e9fac0200d 100644 --- a/pkgs/development/tools/build-managers/waf/setup-hook.sh +++ b/pkgs/development/tools/build-managers/waf/setup-hook.sh @@ -10,7 +10,7 @@ wafConfigurePhase() { configureFlags="${prefixKey:---prefix=}$prefix $configureFlags" fi - local flagsArray=(); + local flagsArray=(@crossFlags@); for flag in $configureFlags "${configureFlagsArray[@]}"; do if [[ diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 1240d373dbb..dc44e55ed6f 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -6366,7 +6366,11 @@ in waf = callPackage ../development/tools/build-managers/waf { python = python3; }; wafHook = makeSetupHook { deps = [ python ]; - substitutions = { inherit waf; }; + substitutions = { + inherit waf; + crossFlags = lib.optionalString (stdenv.hostPlatform != stdenv.targetPlatform) + ''--cross-compile "--cross-execute=${stdenv.targetPlatform.emulator pkgs}"''; + }; } ../development/tools/build-managers/waf/setup-hook.sh; wakelan = callPackage ../tools/networking/wakelan { }; From cbd94090867cf2af7bd8e8b3dc5bc2233906885a Mon Sep 17 00:00:00 2001 From: Symphorien Gibol Date: Thu, 28 Mar 2019 20:15:55 +0100 Subject: [PATCH 5/7] talloc, tdb: fix cross-compilation after wafHook improvements --- pkgs/development/libraries/talloc/default.nix | 17 ++++++++--------- pkgs/development/libraries/tdb/default.nix | 14 ++++---------- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/pkgs/development/libraries/talloc/default.nix b/pkgs/development/libraries/talloc/default.nix index 1fbbecf71a6..fc6f499985b 100644 --- a/pkgs/development/libraries/talloc/default.nix +++ b/pkgs/development/libraries/talloc/default.nix @@ -1,6 +1,6 @@ { stdenv, fetchurl, python, pkgconfig, readline, libxslt , docbook_xsl, docbook_xml_dtd_42, fixDarwinDylibNames -, buildPackages +, wafHook }: stdenv.mkDerivation rec { @@ -11,23 +11,22 @@ stdenv.mkDerivation rec { sha256 = "1kk76dyav41ip7ddbbf04yfydb4jvywzi2ps0z2vla56aqkn11di"; }; - nativeBuildInputs = [ pkgconfig fixDarwinDylibNames python + nativeBuildInputs = [ pkgconfig fixDarwinDylibNames python wafHook docbook_xsl docbook_xml_dtd_42 ]; buildInputs = [ readline libxslt ]; - prePatch = '' - patchShebangs buildtools/bin/waf - ''; + wafPath = "buildtools/bin/waf"; configureFlags = [ "--enable-talloc-compat1" "--bundled-libraries=NONE" "--builtin-libraries=replace" - ] ++ stdenv.lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ - "--cross-compile" - "--cross-execute=${stdenv.hostPlatform.emulator buildPackages}" ]; - configurePlatforms = []; + + # this must not be exported before the ConfigurePhase otherwise waf whines + preBuild = stdenv.lib.optionalString stdenv.hostPlatform.isMusl '' + export NIX_CFLAGS_LINK="-no-pie -shared"; + ''; postInstall = '' ${stdenv.cc.targetPrefix}ar q $out/lib/libtalloc.a bin/default/talloc_[0-9]*.o diff --git a/pkgs/development/libraries/tdb/default.nix b/pkgs/development/libraries/tdb/default.nix index 21f062998b4..e1e91be7373 100644 --- a/pkgs/development/libraries/tdb/default.nix +++ b/pkgs/development/libraries/tdb/default.nix @@ -1,5 +1,5 @@ -{ stdenv, fetchurl, python2, pkgconfig, readline, libxslt -, docbook_xsl, docbook_xml_dtd_42, buildPackages +{ stdenv, fetchurl, wafHook, pkgconfig, readline, libxslt +, docbook_xsl, docbook_xml_dtd_42 }: stdenv.mkDerivation rec { @@ -10,23 +10,17 @@ stdenv.mkDerivation rec { sha256 = "1ibcz466xwk1x6xvzlgzd5va4lyrjzm3rnjak29kkwk7cmhw4gva"; }; - nativeBuildInputs = [ pkgconfig python2 ]; + nativeBuildInputs = [ pkgconfig wafHook ]; buildInputs = [ readline libxslt docbook_xsl docbook_xml_dtd_42 ]; - preConfigure = '' - patchShebangs buildtools/bin/waf - ''; + wafPath = "buildtools/bin/waf"; configureFlags = [ "--bundled-libraries=NONE" "--builtin-libraries=replace" - ] ++ stdenv.lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ - "--cross-compile" - "--cross-execute=${stdenv.hostPlatform.emulator buildPackages}" ]; - configurePlatforms = [ ]; meta = with stdenv.lib; { description = "The trivial database"; From 52566c3b7b5f96d198dd6e57e2db37012fd9b71b Mon Sep 17 00:00:00 2001 From: Symphorien Gibol Date: Thu, 28 Mar 2019 21:57:51 +0100 Subject: [PATCH 6/7] proot: fix cross compilation --- pkgs/tools/system/proot/default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/tools/system/proot/default.nix b/pkgs/tools/system/proot/default.nix index 2381ce6c0db..c8028ed74a7 100644 --- a/pkgs/tools/system/proot/default.nix +++ b/pkgs/tools/system/proot/default.nix @@ -15,6 +15,8 @@ stdenv.mkDerivation rec { postPatch = '' substituteInPlace src/GNUmakefile \ --replace /bin/echo ${coreutils}/bin/echo + # our cross machinery defines $CC and co just right + sed -i /CROSS_COMPILE/d src/GNUmakefile ''; buildInputs = [ talloc ] ++ stdenv.lib.optional enablePython python; From a79a8f29bc509b2d51158846c9562e64e1239b4c Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Tue, 9 Apr 2019 23:44:37 -0400 Subject: [PATCH 7/7] waf: use wafConfigureFlags for waf flags MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This avoids the potential conflict between autoconf flags and the waf flags. There is some overlap between the two but waf errors when it doesn’t recognize the flag. --- pkgs/applications/audio/ardour/default.nix | 2 +- pkgs/applications/audio/guitarix/default.nix | 2 +- pkgs/applications/misc/xiphos/default.nix | 2 +- .../libraries/audio/lvtk/default.nix | 2 +- .../development/libraries/ndn-cxx/default.nix | 2 +- .../science/networking/ns3/default.nix | 2 +- pkgs/development/libraries/talloc/default.nix | 2 +- pkgs/development/libraries/tdb/default.nix | 2 +- .../tools/build-managers/waf/setup-hook.sh | 27 ++++--------------- pkgs/misc/emulators/wxmupen64plus/default.nix | 2 +- pkgs/misc/jackaudio/default.nix | 2 +- pkgs/tools/graphics/glmark2/default.nix | 2 +- 12 files changed, 16 insertions(+), 33 deletions(-) diff --git a/pkgs/applications/audio/ardour/default.nix b/pkgs/applications/audio/ardour/default.nix index 1bb1e404b5c..30a4e052d77 100644 --- a/pkgs/applications/audio/ardour/default.nix +++ b/pkgs/applications/audio/ardour/default.nix @@ -49,7 +49,7 @@ stdenv.mkDerivation rec { patchShebangs ./tools/ ''; - configureFlags = [ + wafConfigureFlags = [ "--optimize" "--docs" "--with-backends=jack,alsa,dummy" diff --git a/pkgs/applications/audio/guitarix/default.nix b/pkgs/applications/audio/guitarix/default.nix index bc4c18aab08..465544e7c6a 100644 --- a/pkgs/applications/audio/guitarix/default.nix +++ b/pkgs/applications/audio/guitarix/default.nix @@ -28,7 +28,7 @@ stdenv.mkDerivation rec { zita-resampler curl ]; - configureFlags = [ + wafConfigureFlags = [ "--shared-lib" "--no-desktop-update" "--enable-nls" diff --git a/pkgs/applications/misc/xiphos/default.nix b/pkgs/applications/misc/xiphos/default.nix index 7148caf35d3..88ab52313b0 100644 --- a/pkgs/applications/misc/xiphos/default.nix +++ b/pkgs/applications/misc/xiphos/default.nix @@ -37,7 +37,7 @@ stdenv.mkDerivation rec { export SWORD_HOME=${sword}; ''; - configureFlags= [ "--enable-webkit2" ]; + wafConfigureFlags = [ "--enable-webkit2" ]; meta = with stdenv.lib; { description = "A GTK Bible study tool"; diff --git a/pkgs/development/libraries/audio/lvtk/default.nix b/pkgs/development/libraries/audio/lvtk/default.nix index b6203a159e6..78763ca29e2 100644 --- a/pkgs/development/libraries/audio/lvtk/default.nix +++ b/pkgs/development/libraries/audio/lvtk/default.nix @@ -19,7 +19,7 @@ stdenv.mkDerivation rec { sed -i '/target[ ]*= "ttl2c"/ ilib=["boost_system"],' tools/wscript_build ''; - configureFlags = [ + wafConfigureFlags = [ "--boost-includes=${boost.dev}/include" "--boost-libs=${boost.out}/lib" ]; diff --git a/pkgs/development/libraries/ndn-cxx/default.nix b/pkgs/development/libraries/ndn-cxx/default.nix index 923bc61f67d..cbe1f984059 100644 --- a/pkgs/development/libraries/ndn-cxx/default.nix +++ b/pkgs/development/libraries/ndn-cxx/default.nix @@ -13,7 +13,7 @@ stdenv.mkDerivation { }; nativeBuildInputs = [ pkgconfig wafHook ]; buildInputs = [ openssl doxygen boost sqlite python pythonPackages.sphinx]; - configureFlags = [ + wafConfigureFlags = [ "--with-openssl=${openssl.dev}" "--boost-includes=${boost.dev}/include" "--boost-libs=${boost.out}/lib" diff --git a/pkgs/development/libraries/science/networking/ns3/default.nix b/pkgs/development/libraries/science/networking/ns3/default.nix index d5c3ca2457a..5218de07509 100644 --- a/pkgs/development/libraries/science/networking/ns3/default.nix +++ b/pkgs/development/libraries/science/networking/ns3/default.nix @@ -63,7 +63,7 @@ stdenv.mkDerivation rec { patchShebangs doc/ns3_html_theme/get_version.sh ''; - configureFlags = with stdenv.lib; [ + wafConfigureFlags = with stdenv.lib; [ "--enable-modules=${stdenv.lib.concatStringsSep "," modules}" "--with-python=${pythonEnv.interpreter}" ] diff --git a/pkgs/development/libraries/talloc/default.nix b/pkgs/development/libraries/talloc/default.nix index fc6f499985b..5a8ebe84ba6 100644 --- a/pkgs/development/libraries/talloc/default.nix +++ b/pkgs/development/libraries/talloc/default.nix @@ -17,7 +17,7 @@ stdenv.mkDerivation rec { wafPath = "buildtools/bin/waf"; - configureFlags = [ + wafConfigureFlags = [ "--enable-talloc-compat1" "--bundled-libraries=NONE" "--builtin-libraries=replace" diff --git a/pkgs/development/libraries/tdb/default.nix b/pkgs/development/libraries/tdb/default.nix index e1e91be7373..4df80140aa5 100644 --- a/pkgs/development/libraries/tdb/default.nix +++ b/pkgs/development/libraries/tdb/default.nix @@ -17,7 +17,7 @@ stdenv.mkDerivation rec { wafPath = "buildtools/bin/waf"; - configureFlags = [ + wafConfigureFlags = [ "--bundled-libraries=NONE" "--builtin-libraries=replace" ]; diff --git a/pkgs/development/tools/build-managers/waf/setup-hook.sh b/pkgs/development/tools/build-managers/waf/setup-hook.sh index 6e9fac0200d..3da86d3201f 100644 --- a/pkgs/development/tools/build-managers/waf/setup-hook.sh +++ b/pkgs/development/tools/build-managers/waf/setup-hook.sh @@ -6,31 +6,14 @@ wafConfigurePhase() { cp @waf@ "$wafPath" fi - if [[ -z "${dontAddPrefix:-}" && -n "$prefix" ]]; then - configureFlags="${prefixKey:---prefix=}$prefix $configureFlags" + if [ -z "${dontAddPrefix:-}" ] && [ -n "$prefix" ]; then + wafConfigureFlags="${prefixKey:---prefix=}$prefix $wafConfigureFlags" fi - local flagsArray=(@crossFlags@); - for flag in $configureFlags "${configureFlagsArray[@]}"; - do - if [[ - # waf does not support these flags, but they are "blindly" added by the - # pkgsStatic overlay, for example. - $flag != "--enable-static" - && $flag != "--disable-static" - && $flag != "--enable-shared" - && $flag != "--disable-shared" - # these flags are added by configurePlatforms but waf just uses them - # to bail out in cross compilation cases - && $flag != --build=* - && $flag != --host=* - ]]; - then - flagsArray=("${flagsArray[@]}" "$flag"); - fi; - done - flagsArray=( + local flagsArray=( + @crossFlags@ "${flagsArray[@]}" + $wafConfigureFlags "${wafConfigureFlagsArray[@]}" ${configureTargets:-configure} ) echoCmd 'configure flags' "${flagsArray[@]}" diff --git a/pkgs/misc/emulators/wxmupen64plus/default.nix b/pkgs/misc/emulators/wxmupen64plus/default.nix index e63d27ec403..1199f987bb6 100644 --- a/pkgs/misc/emulators/wxmupen64plus/default.nix +++ b/pkgs/misc/emulators/wxmupen64plus/default.nix @@ -17,7 +17,7 @@ stdenv.mkDerivation { export CXXFLAGS="-I${libX11.dev}/include/X11 -DLIBDIR=\\\"${mupen64plus}/lib/\\\"" export LDFLAGS="-lwx_gtk2u_adv-2.9" - configureFlagsArray+=("--mupenapi=$APIDIR" "--wxconfig=`type -P wx-config`") + wafConfigureFlagsArray+=("--mupenapi=$APIDIR" "--wxconfig=`type -P wx-config`") ''; NIX_CFLAGS_COMPILE = "-fpermissive"; diff --git a/pkgs/misc/jackaudio/default.nix b/pkgs/misc/jackaudio/default.nix index a47c2018444..556b66befe6 100644 --- a/pkgs/misc/jackaudio/default.nix +++ b/pkgs/misc/jackaudio/default.nix @@ -56,7 +56,7 @@ stdenv.mkDerivation rec { export NIX_CFLAGS_COMPILE="-F${CoreFoundation}/Library/Frameworks $NIX_CFLAGS_COMPILE" ''; - configureFlags = [ + wafConfigureFlags = [ "--classic" "--autostart=${if (optDbus != null) then "dbus" else "classic"}" ] ++ optional (optDbus != null) "--dbus" diff --git a/pkgs/tools/graphics/glmark2/default.nix b/pkgs/tools/graphics/glmark2/default.nix index 70821468992..566d6f48e1c 100644 --- a/pkgs/tools/graphics/glmark2/default.nix +++ b/pkgs/tools/graphics/glmark2/default.nix @@ -17,7 +17,7 @@ stdenv.mkDerivation rec { libjpeg libpng xorg.libxcb libX11 libGL libdrm python27 wayland udev mesa_noglu ]; - configureFlags = ["--with-flavors=x11-gl,x11-glesv2,drm-gl,drm-glesv2,wayland-gl,wayland-glesv2"]; + wafConfigureFlags = ["--with-flavors=x11-gl,x11-glesv2,drm-gl,drm-glesv2,wayland-gl,wayland-glesv2"]; meta = with stdenv.lib; { description = "OpenGL (ES) 2.0 benchmark";