Skip to content

lib: add gyp.js support - #1092

Open
indutny wants to merge 1 commit into
nodejs:mainfrom
indutny:feature/gyp.js-pmed
Open

lib: add gyp.js support#1092
indutny wants to merge 1 commit into
nodejs:mainfrom
indutny:feature/gyp.js-pmed

Conversation

@indutny

@indutny indutny commented Jan 20, 2017

Copy link
Copy Markdown
Member

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

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

indutny commented Jan 20, 2017

Copy link
Copy Markdown
Member Author

cc @pmed

@pmed

pmed commented Jan 20, 2017

Copy link
Copy Markdown
Contributor

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.

Comment thread README.md
Comment thread lib/build.js
@indutny indutny mentioned this pull request Jan 21, 2017
@Fishrock123

Copy link
Copy Markdown
Contributor

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

@indutny

indutny commented Jan 24, 2017

Copy link
Copy Markdown
Member Author

@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

indutny commented Jan 24, 2017

Copy link
Copy Markdown
Member Author

@bnoordhuis PTAL

@Fishrock123

Copy link
Copy Markdown
Contributor

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

@indutny

indutny commented Jan 30, 2017

Copy link
Copy Markdown
Member Author

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

@lin7sh

lin7sh commented Feb 7, 2017

Copy link
Copy Markdown

any update?

@jskorepa

Copy link
Copy Markdown

What is status of this?

Comment thread README.md
$ node-gyp configure --gypjs
```

It is also possible to set `npm_config_gypjs` environment variable to turn on

Copy link
Copy Markdown
Contributor

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

Comment thread lib/build.js
, win = process.platform == 'win32'

exports.usage = 'Invokes `' + (win ? 'msbuild' : 'make') + '` and builds the module'
exports.usage = 'Invokes `' + (process.env.npm_config_gypjs ? 'ninja' :

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can move to ` templates

Comment thread lib/configure.js
, gypjs = undefined

exports.usage = 'Generates ' + (win ? 'MSVC project files' : 'a Makefile') + ' for the current module'
exports.usage = 'Generates ' + (process.env.npm_config_gypjs ? 'ninja build files' :

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

template

@refack

refack commented Jun 8, 2017

Copy link
Copy Markdown
Contributor

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

@refack refack mentioned this pull request Jun 8, 2017
@indutny

indutny commented Jun 8, 2017

Copy link
Copy Markdown
Member Author

@refack feel free to take over.

@refack

refack commented Jun 8, 2017

Copy link
Copy Markdown
Contributor

@indutny Ack

@Croydon

Croydon commented Jul 26, 2017

Copy link
Copy Markdown

Any progress so far?

@bnoordhuis

Copy link
Copy Markdown
Member

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?

@LinusU

LinusU commented Nov 2, 2017

Copy link
Copy Markdown

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

@jbergstroem

Copy link
Copy Markdown
Member

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.

@indutny

indutny commented Nov 2, 2017

Copy link
Copy Markdown
Member Author

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

@aduh95

aduh95 commented Apr 17, 2018

Copy link
Copy Markdown
Contributor

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?

@bnoordhuis

Copy link
Copy Markdown
Member

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

@AlJohri

AlJohri commented Nov 20, 2018

Copy link
Copy Markdown

@indutny any chance we could revive this PR?

@indutny

indutny commented Nov 21, 2018

Copy link
Copy Markdown
Member Author

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

@rvagg

rvagg commented Jun 22, 2019

Copy link
Copy Markdown
Member

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.

@indutny

indutny commented Jun 22, 2019

Copy link
Copy Markdown
Member Author

There is ninja.js FWIW.

@rvagg

rvagg commented Jun 22, 2019

Copy link
Copy Markdown
Member

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

@indutny

indutny commented Jun 22, 2019

Copy link
Copy Markdown
Member Author

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.

@rvagg

rvagg commented Jun 22, 2019

Copy link
Copy Markdown
Member

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.

@Kreijstal

Copy link
Copy Markdown

does gyp.js support mingw builds with msys2?
We had to patch node_gyp because it assumes windows->msvc without considering using gcc.. aka mingw

@cclauss

cclauss commented Apr 8, 2025

Copy link
Copy Markdown
Contributor

@Kreijstal

Copy link
Copy Markdown

22 issues mentioning mingw: https://github.com/search?q=repo%3Anodejs%2Fnode-gyp+mingw&type=issues

I have managed to get mingw working with node-gyp, but it is nothing that I can upstream as it simply removes the msvc hardcoded version and hardcodes mingw on its place.. nothing dynamic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.