-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lib: add gyp.js support #1092
base: main
Are you sure you want to change the base?
lib: add gyp.js support #1092
Conversation
See: nodejs#960 Added initial `gyp.js` support with --gypjs command line option. Environment variable `npm_config_gypjs` also turns this option on. Update configure and build usage strings depending on `npm_config_gypjs` environment variable. Set `npm_config_gypjs` env variable if `--gypjs` command-line option was set to affect usage text for `configure` and `build` commands. Update usage strings if `--gypjs` command-line option was supplied Trying to load gyp.js module only if --gypjs command-line option was supplied.
cc @pmed |
Why does this require Ninja but default builds don't? |
@Fishrock123 it doesn't, default slow version of ninja is included. If it wouldn't be ninja, we'd have to use MSVS on Windows and make on Unixes, meaning that gyp.js will have to support two platform-specific generators instead of one cross-platform generator. |
@bnoordhuis PTAL |
@indutny Oh, I was wondering why gyp.js required it when regular gyp didn't? Just maintenance cost of that? |
@Fishrock123 yep, maintenance cost and a single solution for all platforms. |
any update? |
What is status of this? |
$ node-gyp configure --gypjs | ||
``` | ||
|
||
It is also possible to set `npm_config_gypjs` environment variable to turn on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO no need for this after #1185
, exec = require('child_process').exec | ||
, processRelease = require('./process-release') | ||
, win = process.platform == 'win32' | ||
|
||
exports.usage = 'Invokes `' + (win ? 'msbuild' : 'make') + '` and builds the module' | ||
exports.usage = 'Invokes `' + (process.env.npm_config_gypjs ? 'ninja' : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can move to ` templates
|
||
exports.usage = 'Generates ' + (win ? 'MSVC project files' : 'a Makefile') + ' for the current module' | ||
exports.usage = 'Generates ' + (process.env.npm_config_gypjs ? 'ninja build files' : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
template
@indutny You up for this? I'd be happy to help/take over... |
@refack feel free to take over. |
@indutny Ack |
Any progress so far? |
I've been thinking about this for some time and I've come to the conclusion that I'd rather not have node-gyp be in the business of generating platform- and tooling-specific build files. That's what gyp.js does, it writes ninja files tailored for the platform and the compiler. As the upstream GYP project has demonstrated, keeping up with platforms and toolchains is a never-ending slog. It takes a lot of time and energy that is better spent elsewhere. I'm hoping we can leverage an existing tool. My personal preference is cmake; it's stable and just works. Now to write a tool that translates GYP files to CMakeLists... @indutny WDYT? Reasonable, unreasonable? |
I've been using CMake.js for at least one project, and it works amazingly good! It only requires the cmake binary instead of relying on python which is a huge plus, I also prefer writing cmake files to gyp file to be honest... |
I like |
@bnoordhuis I'm fine with compiling GYP files to CMake in addons, but I have no idea if this is possible in general. IMO, gyp.js + ninja.js is more viable and as @jbergstroem said is self-hosted. |
With Node.js v4 reaching End Of Life in two weeks, |
I wouldn't mind revisiting this if @indutny is up to it. |
@indutny any chance we could revive this PR? |
Of course. Anyone wants to pick it up from me? I haven't touched this code in months now. |
I was thinking of picking this up again but only just realised that gyp.js requires ninja. I'm really not a fan of ninja simply because it's not commonly available. We're replacing a python dependency with a ninja dependency, that's arguably asking for more trouble because at least python is easy to fetch and install on every platform. We're going to have to get into the business of shipping ninja binaries like Chromium does. |
There is ninja.js FWIW. |
@indutny how mature is that? If I ship a node-gyp with --gypjs support, what's your rough % guess for how much of the current ecosystem is going to be able to successfully build without requiring additional tools (python, ninja, just make and c++)? I'm wondering how much investment I'm going to have to make if I take this on. |
This is a very good question. Most addons have very simple (if not identical) configuration. gyp.js should handle it well out of box. The only limiting factor is "python" support: https://github.com/indutny/gyp.js#reduced-python . gyp.js emulates some trivial python commands, but of course cannot do full python support. |
Since we're the only remaining major user of GYP I suspect we'll be able to move the ecosystem to not depend on sophisticated python syntax in their gyp files. Maybe we could even move it to support some JavaScript if people really need advanced stuff in there. |
See: #960
Added initial
gyp.js
support with --gypjs command line option.Environment variable
npm_config_gypjs
also turns this option on.Update configure and build usage strings depending on
npm_config_gypjs
environment variable.
Set
npm_config_gypjs
env variable if--gypjs
command-line optionwas set to affect usage text for
configure
andbuild
commands.Update usage strings if
--gypjs
command-line option was suppliedTrying to load gyp.js module only if --gypjs command-line option was supplied.
cc @bnoordhuis
See #962