build,tools: make addons tests work with GN
This PR refactors the install
and build_addons
scripts so they can be reused by node-ci and electron projects to build the addons tests.
In detail, this PR does following things:
- Minor modifications of the GN configurations to fix loading native modules.
- Add some flags to
tools/install.py
script to allow customize locations ofconfig.gypi
,v8
, etc. With some refactoring to remove global variables. - Rewrite the
tools/build_addons.py
script:- Rewrite it from js to python, because implementing cmd args handling with vanilla Node.js would take much longer time than a simple rewrite.
- Add a few more flags to make it easier to use for embedders.
- Modify the
Makefile
to generate headers in out dir first, and then callsbuild_addons.py --headers-dir=out_dir/headers
(which callsnode-gyp --nodedir=out_dir/headers
) to build addons. Previously the build system was just callingnode-gyp --nodedir=.
, which relied on quirky behavior of node-gyp and did not really test whether the generated headers work.
Users that rely on make
or vcbuild.bat
to work on Node are not affected.