waf: make executable runnable (#388010)

This commit is contained in:
Dmitry Kalinkin 2025-03-27 12:42:10 -04:00 committed by GitHub
parent 9f7eb43375
commit 1da8df70f6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 5 deletions

View file

@ -14,7 +14,7 @@ The variables below are exclusive of `wafHook`.
Location of the `waf` tool. It defaults to `./waf`, to honor software projects that include it directly inside their source trees. Location of the `waf` tool. It defaults to `./waf`, to honor software projects that include it directly inside their source trees.
If `wafPath` doesn't exist, then `wafHook` will copy the `waf` provided from Nixpkgs to it. If the file pointed by `wafPath` doesn't exist, then `waf` provided by Nixpkgs will be used.
#### `wafFlags` {#waf-flags} #### `wafFlags` {#waf-flags}

View file

@ -4,6 +4,7 @@
, callPackage , callPackage
, ensureNewerSourcesForZipFilesHook , ensureNewerSourcesForZipFilesHook
, python3 , python3
, makeWrapper
# optional list of extra waf tools, e.g. `[ "doxygen" "pytest" ]` # optional list of extra waf tools, e.g. `[ "doxygen" "pytest" ]`
, extraTools ? [] , extraTools ? []
}: }:
@ -22,6 +23,7 @@ stdenv.mkDerivation (finalAttrs: {
nativeBuildInputs = [ nativeBuildInputs = [
ensureNewerSourcesForZipFilesHook ensureNewerSourcesForZipFilesHook
python3 python3
makeWrapper
]; ];
buildInputs = [ buildInputs = [
@ -49,14 +51,20 @@ stdenv.mkDerivation (finalAttrs: {
python waf-light build ${extraToolsList} python waf-light build ${extraToolsList}
substituteInPlace waf \
--replace "w = test(i + '/lib/' + dirname)" \
"w = test('$out/${python3.sitePackages}')"
runHook postBuild runHook postBuild
''; '';
installPhase = '' installPhase = ''
runHook preInstall runHook preInstall
install -D waf $out/bin/waf install -D waf "$out"/bin/waf
wrapProgram "$out"/bin/waf --set PYTHONPATH "$out"/${python3.sitePackages}
mkdir -p "$out"/${python3.sitePackages}/
cp -r waflib "$out"/${python3.sitePackages}/
runHook postInstall runHook postInstall
''; '';

View file

@ -4,8 +4,7 @@ wafConfigurePhase() {
runHook preConfigure runHook preConfigure
if ! [ -f "${wafPath:=./waf}" ]; then if ! [ -f "${wafPath:=./waf}" ]; then
echo "copying waf to $wafPath..." wafPath="@waf@/bin/waf"
cp @waf@/bin/waf "$wafPath"
fi fi
if [ -z "${dontAddPrefix:-}" ] && [ -n "$prefix" ]; then if [ -z "${dontAddPrefix:-}" ] && [ -n "$prefix" ]; then