node-gyp icon indicating copy to clipboard operation
node-gyp copied to clipboard

lib: add gyp.js support

Open indutny opened this issue 7 years ago • 26 comments

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 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 @bnoordhuis

See #962

indutny avatar Jan 20 '17 03:01 indutny

cc @pmed

indutny avatar Jan 20 '17 03:01 indutny

Hi Fedor @indutny

I glad to see that gyp.js feature is again moving forward 👍

Is it a rebased version of #962? If so, please note that PR is based on #964, and those two PRs probably should be closed after merging of this one.

pmed avatar Jan 20 '17 10:01 pmed

Why does this require Ninja but default builds don't?

Fishrock123 avatar Jan 24 '17 21:01 Fishrock123

@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.

indutny avatar Jan 24 '17 21:01 indutny

@bnoordhuis PTAL

indutny avatar Jan 24 '17 21:01 indutny

@indutny Oh, I was wondering why gyp.js required it when regular gyp didn't? Just maintenance cost of that?

Fishrock123 avatar Jan 30 '17 22:01 Fishrock123

@Fishrock123 yep, maintenance cost and a single solution for all platforms.

indutny avatar Jan 30 '17 22:01 indutny

any update?

lin7sh avatar Feb 07 '17 21:02 lin7sh

What is status of this?

jskorepa avatar Apr 23 '17 16:04 jskorepa

@indutny You up for this? I'd be happy to help/take over...

refack avatar Jun 08 '17 14:06 refack

@refack feel free to take over.

indutny avatar Jun 08 '17 19:06 indutny

@indutny Ack

refack avatar Jun 08 '17 20:06 refack

Any progress so far?

Croydon avatar Jul 26 '17 02:07 Croydon

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?

bnoordhuis avatar Nov 02 '17 11:11 bnoordhuis

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...

https://github.com/cmake-js/cmake-js#why-cmake

LinusU avatar Nov 02 '17 12:11 LinusU

I like gyp.js because of the vision being self-hosted with installing node.js. I'm totally fine if node.js itself uses something else; but a big community win would be having gyp.js Good Enough to build a majority of the node-gyp projects.

jbergstroem avatar Nov 02 '17 18:11 jbergstroem

@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.

indutny avatar Nov 02 '17 19:11 indutny

With Node.js v4 reaching End Of Life in two weeks, gyp.js will be compatible with all supported Node versions! Maybe we could consider getting rid of the Python dependency. What is the status of this? Is there something I can do to help?

aduh95 avatar Apr 17 '18 10:04 aduh95

I wouldn't mind revisiting this if @indutny is up to it.

bnoordhuis avatar Apr 17 '18 10:04 bnoordhuis

@indutny any chance we could revive this PR?

AlJohri avatar Nov 20 '18 21:11 AlJohri

Of course. Anyone wants to pick it up from me? I haven't touched this code in months now.

indutny avatar Nov 21 '18 21:11 indutny

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. Maybe getting it beyond ninja is a reasonable task, but that's not a trivial amount of work.

rvagg avatar Jun 22 '19 01:06 rvagg

There is ninja.js FWIW.

indutny avatar Jun 22 '19 01:06 indutny

@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.

rvagg avatar Jun 22 '19 01:06 rvagg

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.

indutny avatar Jun 22 '19 01:06 indutny

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.

rvagg avatar Jun 22 '19 02:06 rvagg