Where are node-gyp's [options] documented?

2019-06-20 18:25发布

问题:

node-gyp --help says:

Usage: node-gyp <command> [options]

where <command> is one of:
 - build - Invokes `make` and builds the module
 - clean - Removes any generated build files and the "out" dir
 - configure - Generates a Makefile for the current module
 - rebuild - Runs "clean", "configure" and "build" all at once
 - install - Install node development files for the specified node version.
 - list - Prints a listing of the currently installed node development files
 - remove - Removes the node development files for the specified version

node-gyp@1.0.2  /usr/local/lib/node_modules/node-gyp
node@1.8.1

But where are the [options] actually documented? I've picked through various .js source files to try to figure it out and have come up with nothing.

Do [options] just pass-thru to gyp?

Specifically, I'm trying to use a bindings file that is not named 'binding.gyp' but it seems like the node -> Python wrapper that sits between node.js and gyp doesn't allow it due to some hard-coding (as best as I can figure out).

For example: node-gyp configure custom.gyp produces:

<snip>
gyp info spawn python
gyp info spawn args [ '/usr/local/lib/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp', <-- NOT OK
gyp info spawn args   'custom.gyp', <-- OK
<snip>
gyp info spawn args   '-I',
gyp info spawn args   '/usr/local/lib/node_modules/node-gyp/custom.gypi', <-- MAYBE OK? DON'T LIKE IT BEING GLOBAL (race condition here...)
<snip>
gyp: binding.gyp not found (cwd: <snip>) while trying to load binding.gyp
gyp ERR! configure error <-- YES because it doesn't exist, I want to use 'custom.gyp'
gyp ERR! stack Error: `gyp` failed with exit code: 1
<snip>

where <snip> just represents me deleting irrelevant information.

Maybe I can get around it by modifying the Python wrapper itself, but is there some other way? Some node-gyp --option=x for instance?

回答1:

Looks like there is now quite a bit of documentation for this at the node-gyp repo.



回答2:

Node-gyp is not quite well documented, so statements below are my findings from the project sources.

Options for node-gyp are depended on command. These options are listed in configDefs object. Some of them are translated into GYP options, others are not.

GYP file name binding.gyp is hard-coded in configure.js

GYP options probably may be set in GYP_* environment variables before node-gyp invocation. Please refer GYP command-line help and sources, since GYP is not well documented too.



标签: node-gyp