Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

indutny
Copy link
Member

@indutny indutny commented Jan 20, 2017

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
Copy link
Member Author

indutny commented Jan 20, 2017

cc @pmed

@pmed
Copy link
Contributor

pmed commented Jan 20, 2017

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.

README.md Show resolved Hide resolved
lib/build.js Show resolved Hide resolved
@indutny indutny mentioned this pull request Jan 21, 2017
@Fishrock123
Copy link
Member

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

@indutny
Copy link
Member Author

indutny commented Jan 24, 2017

@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
Copy link
Member Author

indutny commented Jan 24, 2017

@bnoordhuis PTAL

@Fishrock123
Copy link
Member

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

@indutny
Copy link
Member Author

indutny commented Jan 30, 2017

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

@lin7sh
Copy link

lin7sh commented Feb 7, 2017

any update?

@jskorepa
Copy link

What is status of this?

$ node-gyp configure --gypjs
```

It is also possible to set `npm_config_gypjs` environment variable to turn on
Copy link
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

, 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' :
Copy link
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


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
Contributor

Choose a reason for hiding this comment

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

template

@refack
Copy link
Contributor

refack commented Jun 8, 2017

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

@refack refack mentioned this pull request Jun 8, 2017
@indutny
Copy link
Member Author

indutny commented Jun 8, 2017

@refack feel free to take over.

@refack
Copy link
Contributor

refack commented Jun 8, 2017

@indutny Ack

@Croydon
Copy link

Croydon commented Jul 26, 2017

Any progress so far?

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

LinusU commented Nov 2, 2017

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
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
Copy link
Member Author

indutny commented Nov 2, 2017

@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
Copy link

aduh95 commented Apr 17, 2018

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
Member

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

@AlJohri
Copy link

AlJohri commented Nov 20, 2018

@indutny any chance we could revive this PR?

@indutny
Copy link
Member Author

indutny commented Nov 21, 2018

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

@rvagg
Copy link
Member

rvagg commented Jun 22, 2019

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
Copy link
Member Author

indutny commented Jun 22, 2019

There is ninja.js FWIW.

@rvagg
Copy link
Member

rvagg commented Jun 22, 2019

@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
Copy link
Member Author

indutny commented Jun 22, 2019

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
Copy link
Member

rvagg commented Jun 22, 2019

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.

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.

None yet