node-gyp
node-gyp copied to clipboard
Action command gets added `..` for Windows
With node v18.4.0 and node-gyp v9.0.0 on windows-latest of GitHub's CI (actions).
With a binding.gyp of contents
{
"targets": [{
"target_name": "minify",
"product_extension": "node",
"type": "<(library)",
"cflags": ["-Wall"],
"sources": ["minify.c"],
"libraries": ["../minify.a"],
"actions": [{
"action_name": "build_go",
"message": "Building Go library...",
"inputs": ["minify.go", "minify.c"],
"outputs": ["minify.a"],
"action": ["make", "compile"]
}],
}],
}
where Makefile is in the same directory as binding.gyp. This works fine for Linux and MacOS, but fails on Windows as it seems to prepend .. to the second argument of action, resulting in calling make ../compile.
Full output:
gyp info it worked if it ends with ok gyp info using [email protected] gyp info using [email protected] | win32 | x64 gyp info find Python using Python version 3.9.13 found at "C:\hostedtoolcache\windows\Python\3.9.13\x64\python3.exe" gyp http GET https://nodejs.org/download/release/v18.4.0/node-v18.4.0-headers.tar.gz gyp http 200 https://nodejs.org/download/release/v18.4.0/node-v18.4.0-headers.tar.gz gyp http GET https://nodejs.org/download/release/v18.4.0/SHASUMS256.txt gyp http GET https://nodejs.org/download/release/v18.4.0/win-x86/node.lib gyp http GET https://nodejs.org/download/release/v18.4.0/win-x64/node.lib gyp http GET https://nodejs.org/download/release/v18.4.0/win-arm64/node.lib gyp http 200 https://nodejs.org/download/release/v18.4.0/SHASUMS256.txt gyp http 200 https://nodejs.org/download/release/v18.4.0/win-x86/node.lib gyp http 200 https://nodejs.org/download/release/v18.4.0/win-x64/node.lib gyp http 404 https://nodejs.org/download/release/v18.4.0/win-arm64/node.lib gyp info find VS using VS2022 (17.2.32616.157) found at: gyp info find VS "C:\Program Files\Microsoft Visual Studio\2022\Enterprise" gyp info find VS run with --verbose for detailed information gyp info spawn C:\hostedtoolcache\windows\Python\3.9.13\x64\python3.exe gyp info spawn args [ gyp info spawn args 'C:\hostedtoolcache\windows\node\18.4.0\x64\node_modules\npm\node_modules\node-gyp\gyp\gyp_main.py', gyp info spawn args 'binding.gyp', gyp info spawn args '-f', gyp info spawn args 'msvs', gyp info spawn args '-I', gyp info spawn args 'D:\a\minify\minify\bindings\js\build\config.gypi', gyp info spawn args '-I', gyp info spawn args 'C:\hostedtoolcache\windows\node\18.4.0\x64\node_modules\npm\node_modules\node-gyp\addon.gypi', gyp info spawn args '-I', gyp info spawn args 'C:\Users\runneradmin\AppData\Local\node-gyp\Cache\18.4.0\include\node\common.gypi', gyp info spawn args '-Dlibrary=shared_library', gyp info spawn args '-Dvisibility=default', gyp info spawn args '-Dnode_root_dir=C:\Users\runneradmin\AppData\Local\node-gyp\Cache\18.4.0', gyp info spawn args '-Dnode_gyp_dir=C:\hostedtoolcache\windows\node\18.4.0\x64\node_modules\npm\node_modules\node-gyp', gyp info spawn args '-Dnode_lib_file=C:\\Users\\runneradmin\\AppData\\Local\\node-gyp\\Cache\\18.4.0\\<(target_arch)\\node.lib', gyp info spawn args '-Dmodule_root_dir=D:\a\minify\minify\bindings\js', gyp info spawn args '-Dnode_engine=v8', gyp info spawn args '--depth=.', gyp info spawn args '--no-parallel', gyp info spawn args '--generator-output', gyp info spawn args 'D:\a\minify\minify\bindings\js\build', gyp info spawn args '-Goutput_dir=.' gyp info spawn args ] gyp info spawn C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\MSBuild.exe gyp info spawn args [ gyp info spawn args 'build/binding.sln', gyp info spawn args '/clp:Verbosity=minimal', gyp info spawn args '/nologo', gyp info spawn args '/p:Configuration=Release;Platform=x64' gyp info spawn args ] Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch. Building Go library... mingw32-make: *** No rule to make target '../compile'. Stop. C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(245,5): error MSB8066: Custom build for '..\minify.go' exited with code 2. [D:\a\minify\minify\bindings\js\build\minify.vcxproj] gyp ERR! build error gyp ERR! stack Error:
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\MSBuild.exefailed with exit code: 1 gyp ERR! stack at ChildProcess.onExit (C:\hostedtoolcache\windows\node\18.4.0\x64\node_modules\npm\node_modules\node-gyp\lib\build.js:194:23) gyp ERR! stack at ChildProcess.emit (node:events:537:28) gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:291:12) gyp ERR! System Windows_NT 10.0.20348 gyp ERR! command "C:\hostedtoolcache\windows\node\18.4.0\x64\node.exe" "C:\hostedtoolcache\windows\node\18.4.0\x64\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild" gyp ERR! cwd D:\a\minify\minify\bindings\js gyp ERR! node -v v18.4.0 gyp ERR! node-gyp -v v9.0.0 gyp ERR! not ok npm ERR! code 1 npm ERR! path D:\a\minify\minify\bindings\js npm ERR! command failed npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node-gyp-build
@DeeDeeG
I haven't written a binding.gyp file before, and I don't do a lot with C/C++ to be honest (or go/other compiled languages). I don't know a lot about how the gyp part of node-gyp works.
Someone else may be the better person to ask? Also, there's the gyp documentation (https://gyp.gsrc.io/docs/UserDocumentation.md), but I personally find it confusing and not very detailed in a lot of places... I hope it helps?
This issue seems no longer relevant as it has been stale for a long time. If there are no objections, I will close this issue next Mon-Tue. In case something similar happens again please open a new issue.
This is probably a bug in node-gyp, or at least an inconsistency that requires a workaround for building to multiple platforms. I've add a file compile.bat with content mingw32-make -C .. compile, which is referenced in the binding.gyp as "action": ["../compile.bat"] for the Window platform only. See https://github.com/tdewolff/minify/blob/master/bindings/js/binding.gyp
I believe this should be fixed, but if this is a problem in a third-party library or if there is no intention to fix, you can go ahead and close this issue if you like.
This is probably a bug in node-gyp
@tdewolff Are you able to create a pull request that contains a GitHub Action that fails in this way so that we can diagnose and fix the problem?