Commit graph

158 commits

Author SHA1 Message Date
Luke Karrys
192eec2aca
Sync deps and engines with npm (#2770)
* feat!: update `engines.node` to `^14.17.0 || ^16.13.0 || >=18.0.0`

* deps: nopt@^7.0.0

* feat: replace npmlog with proc-log

* deps: standard@17.0.0 and fix linting errors

* deps: which@3.0.0
- this also promiisifies the build command

* deps: glob@8.0.3

* feat: drop rimraf dependency

* fix: use fs/promises in favor of fs.promises
2023-06-20 15:44:18 +02:00
Kevin Adler
a26494fbb8 feat: Add proper support for IBM i
Python 3.9 on IBM i now properly returns "os400" for sys.platform
instead of claiming to be AIX as it did previously. While the IBM i PASE
environment is compatible with AIX, it is a subset and has numerous
differences which makes it beneficial to distinguish, however this means
that it now needs explicit support here.
2022-09-24 02:17:10 +01:00
alexcfyung
83c0a12bf2
lib: enable support for zoslib on z/OS (#2600)
Check if zos-base.h is in the directory identified by environment
variable ZOSLIB_INCLUDES if set; otherwise search for it from a set of
candidates under nodeRootDir. Then pass it as
-Dzoslib_include_dir=<path-found> to gyp_main.py for use in common.gypi
to set 'includes_dir' when compiling addons.

Co-authored-by: Gaby Baghdadi <baghdadi@ca.ibm.com>

Co-authored-by: Gaby Baghdadi <baghdadi@ca.ibm.com>
2022-07-15 10:13:27 +08:00
DeeDeeG
b9ddcd5bbd
Add Python symlink to path (for non-Windows OSes only) (#2362)
* lib: create a Python symlink and add it to PATH

Helps to ensure a version of Python validated by lib/find-python.js
is used to run various Python scripts generated by gyp.

Known to affect gyp-mac-tool, probably affects gyp-flock-tool as well.

These Python scripts (such as `gyp-mac-tool`) are invoked directly,
via the generated Makefile, so their shebang lines determine
which Python binary is used to run them.
The shebang lines of these scripts are all `#!/usr/bin/env python3`,
so the first `python3` on the user's PATH will be used.

By adding a symlink to the Python binary validated by find-python.js,
and putting this symlink first on the PATH, we can ensure we use
a compatible version of Python to run these scripts.

(Only on Unix/Unix-like OSes. Symlinks are tricky on Windows,
and Python isn't used at build-time anyhow on Windows,
so this intervention isn't useful or necessary on Windows.

A similar technique for Windows, no symlinks required,
would be to make batch scripts which execute the target binary,
much like what Node does for its bundled copy of npm on Windows.)

* test: update mocked graceful-fs for configure test

Add missing functions "unlink()" and "symlink()" to mocked module.

* lib: log any errors when creating Python symlink

Warn users about errors, but continue on in case the user does
happen to have new enough Python on their PATH.

(The symlinks are only meant to fix an issue in a corner case,
where the user told `node-gyp` where new enough Python is,
but it's not the first `python3` on their PATH.
We should not introduce a new potential failure mode to all users
when fixing this bug. So no hard errors during the symlink process.)

* lib: improve error formatting for Python symlink

Logging the entire error object shows the stack twice,
and all the other information is contained in the stack.

It also messes with the order of what is logged.

Rather than logging a bunch of redundant information in a messy way,
we can log only the stack. Logging it in a separate log.warn()
also gets rid of an extra space character at the beginning of the line.

* lib: restore err.errno to logs for symlink errors

This info (err.errno) is the only piece of information
in the error object that is not redundant to err.stack.

* lib: use log.verbose, not log.warn

These messages aren't important enough to be `log.warn`s.

Log as verbose only; they will also appear in full error output.
2022-06-10 14:11:23 +02:00
alexcfyung
1d499dd560 lib: add lib.target as path for searching libnode on z/OS 2022-02-25 09:45:50 +11:00
Cheng Zhao
a27dc08696 feat: build with config.gypi from node headers 2021-11-05 20:08:28 +11:00
Cheng Zhao
f2ad87ff65 chore: refactor the creation of config.gypi file 2021-09-10 15:22:01 +10:00
DeeDeeG
5f1a06c50f
lib: deep-copy process.config during configure (#2368) 2021-05-29 10:22:21 +08:00
DeeDeeG
245dee5b62
lib: log as yes/no whether build dir was created (#2370)
This bit of logging apparently expected to be given a boolean, but was
receiving either a path or undefined based on the result of fs.mkdir.

Now it prints either "Yes" or "No",
rather than printing either a path or "undefined", respectively.
2021-05-19 15:30:17 +08:00
Michaël Zasso
392b7760b4
lib: avoid changing process.config (#2322)
PR-URL: https://github.com/nodejs/node-gyp/pull/2322
Refs: https://github.com/nodejs/node/pull/36902
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
2021-02-14 12:47:47 +08:00
Samuel Attard
f461d56c53
build: support apple silicon (arm64 darwin) builds
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
PR-URL: https://github.com/nodejs/node-gyp/pull/2165
2020-07-20 15:08:20 +10:00
Rod Vagg
4937722cf5
deps: replace mkdirp with {recursive} mkdir
only supported on Node.js 10+

Closes: #2084
PR-URL: https://github.com/nodejs/node-gyp/pull/2123
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
2020-06-03 12:56:39 +10:00
Rod Vagg
ab2a4cc209
src: update to standard@14
PR-URL: https://github.com/nodejs/node-gyp/pull/1899
Reviewed-By: João Reis <reis@janeasystems.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-10-02 13:57:30 +10:00
Jose Quijada
c7f1bcaff5
gyp: improve Windows+Cygwin compatibility
Fixes: #1782
PR-URL: https://github.com/nodejs/node-gyp/pull/1817
Reviewed-By: Christian Clauss <cclauss@me.com>
Reviewed-By: Rod Vagg <r@va.gg>
2019-08-01 10:48:30 +10:00
João Reis
7e7fce3fed python: move Python detection to its own file
PR-URL: https://github.com/nodejs/node-gyp/pull/1815
Reviewed-By: Christian Clauss <cclauss@me.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-07-11 05:13:59 +01:00
Rod Vagg
e40c99e283
src: implement standard.js linting
In addition:

* moved module.exports to the bottom
* no single-line if statements
* no if statements without a {
* const for requires
* array declarations get spaces inside [ ]
* 'use strict' in all .js files

PR-URL: https://github.com/nodejs/node-gyp/pull/1794
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: João Reis <reis@janeasystems.com>
2019-07-06 14:36:37 +10:00
João Reis
a20faedc91 gyp: enable MARMASM items only on new VS versions
PR-URL: https://github.com/nodejs/node-gyp/pull/1762
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Refael Ackermann <refack@gmail.com>
2019-06-04 16:38:05 +01:00
João Reis
8f43f68275 win: detect all VS versions in node-gyp
PR-URL: https://github.com/nodejs/node-gyp/pull/1762
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Refael Ackermann <refack@gmail.com>
2019-06-04 16:39:49 +01:00
João Reis
7fe4095974 win: generic Visual Studio 2017 detection
PR-URL: https://github.com/nodejs/node-gyp/pull/1762
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Refael Ackermann <refack@gmail.com>
2019-06-04 16:38:05 +01:00
Richard Townsend
91744bfecc gyp: add support for Windows on Arm
Cherry-pick of https://github.com/refack/GYP/pull/33, supersedes
https://github.com/nodejs/node-gyp/pull/1678 until GYP3 is merged.

`npm test` passes

Change-Id: I2b1e1e03e378b4812d34afa527087793864d1576

PR-URL: https://github.com/nodejs/node-gyp/pull/1739
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: João Reis <reis@janeasystems.com>
2019-05-07 16:28:40 +01:00
João Reis
43031fadcb
python: clean-up detection
Try everything until Python is found.

PR-URL: https://github.com/nodejs/node-gyp/pull/1582
Reviewed-By: Rod Vagg <rod@vagg.org>
2019-04-24 10:29:00 +10:00
Refael Ackermann
49ab79d221
python: more informative error
PR-URL: https://github.com/nodejs/node-gyp/pull/1269
Refs: https://github.com/nodejs/node-gyp/pull/1582
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: João Reis <reis@janeasystems.com>
2019-04-24 10:29:00 +10:00
Selwyn
8098ebdeb4
deps: replace osenv dependency with native os
Breaking change: needs Node.js version 6 or higher

https://github.com/nodejs/node-gyp/pull/1570
Reviewed-By: Refael Ackermann <refack@gmail.com>
2019-04-24 10:29:00 +10:00
Jon Moss
a5b7410497
Add ESLint no-unused-vars rule
- Uses `.eslintrc.yaml` for configuration
- `npm run lint` is part of `npm test`

PR-URL: https://github.com/nodejs/node-gyp/pull/1497
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: João Reis <reis@janeasystems.com>
2019-04-24 10:27:29 +10:00
Jon Moss
9e46872ea3
bin,lib: remove extra comments/lines/spaces
- Removes "module dependencies" comments and things that, IMHO, don't add
too much value. Happy to add back if helps some people when reading
through `node-gyp`.
- DRY up `lib/process-release.js`.
- Removes a bunch of extra blank lines, as well as random spaces.

PR-URL: https://github.com/nodejs/node-gyp/pull/1508
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-04-24 10:27:29 +10:00
GreenAddress
0c6bf530a0 lib: use print() for python version detection
PR-URL: https://github.com/nodejs/node-gyp/pull/1534
Reviewed-By: Refael Ackermann <refack@gmail.com>
2019-04-11 20:01:47 -04:00
Yang Guo
536759c7e9 configure: use sys.version_info to get python version
This is cleaner than filtering additional strings from
platform.python_version().

PR-URL: https://github.com/nodejs/node-gyp/pull/1504
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Reviewed-By: Rod Vagg <rod@vagg.org>
2018-08-09 10:45:12 +10:00
John Barboza
e5a69010ed zos: add search locations for libnode.x
Node.js on z/OS uses shared dll (libnode.so). When linking native
addons, node-gyp needs to find the corresponding libnode.x during
the link step.

PR-URL: https://github.com/nodejs/node-gyp/pull/1451
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Refael Ackermann <refack@gmail.com>
2018-06-08 17:09:27 +02:00
John Barboza
b2024dee7b zos: support platform
Initial work to add z/OS support to node-gyp.


PR-URL: https://github.com/nodejs/node-gyp/pull/1276
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2018-06-08 17:09:27 +02:00
Gibson Fahnestock
0a07e481f7 configure: don't set ensure if tarball is set
If you're providing a path to a header tarball to install, you probably
want it to always be re-installed.

PR-URL: https://github.com/nodejs/node-gyp/pull/1220
Fixes: https://github.com/nodejs/node-gyp/issues/1216
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Refael Ackermann <refack@gmail.com>
2018-06-08 17:09:27 +02:00
Pavel Medvedev
386746c7d1 configure: use full path in node_lib_file GYP var
Set path to node lib in `$(Configuration)` dir when `--nodedir` option
is supplied, otherwise use value of `target_arch` variable.

PR-URL: https://github.com/nodejs/node-gyp/pull/964
Reviewed-By: João Reis <reis@janeasystems.com>
2017-05-15 23:12:46 +01:00
Pavel Medvedev
0913b2dd99 build, win: use target_arch to link with node.lib
Using `target_arch` in addon.gypi to link against Node.js library. This
variable was written into build/config.gypi on the `configure` stage.

Do not copy node.lib into node_root_dir/Release or node_root_dir/Debug
on Windows, link it from node_root_dir/target_arch directory.

PR-URL: https://github.com/nodejs/node-gyp/pull/964
Reviewed-By: João Reis <reis@janeasystems.com>
2017-05-15 23:04:18 +01:00
Ben Noordhuis
49801716c2
test: fix test-find-python on v0.10.x buildbot.
Work around a v0.10.x CI issue where path.resolve() on UNIX systems
prefixes Windows paths with the current working directory.

v0.12 and up are free of this issue because they use
path.win32.resolve() which does the right thing.

PR-URL: https://github.com/nodejs/node-gyp/pull/1172
Reviewed-By: João Reis <reis@janeasystems.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2017-04-25 15:52:51 +01:00
Refael Ackermann
ae141e1906 win: find and setup for VS2017
PR-URL: https://github.com/nodejs/node-gyp/pull/1130
Reviewed-By: João Reis <reis@janeasystems.com>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Rod Vagg <rod@vagg.org>
2017-03-15 11:54:08 +00:00
Kunal Pathak
a04ea3051a Add support to build node.js with chakracore.
Microsoft's chakracore engine is dependent on Windows SDK, and build
tools should know the version installed on user machine. This change
adds those dependencies in node-gyp tools. Below is the summary:

* Configure msvs_windows_target_platform_version to use the right
  Windows SDK.

* Configure msvs_use_library_dependency_inputs to export symbols
  correctly (otherwise functions not used by node.exe but might be
  needed by native addon modules could be optimized away by linker).

These changes were originally made in nodejs/node#4765, but as @shigeki
mentioned, it was more sensible to send these changes as PR to node-gyp
repo.

PR-URL: https://github.com/nodejs/node-gyp/pull/873
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2017-02-15 04:54:20 +01:00
Ben Noordhuis
37ae7be114 Try python launcher when stock python is python 3.
Consult the python launcher when the python on the path is python 3.
If a python 2 exists on the system, it will tell us.

Fixes: https://github.com/nodejs/node-gyp/issues/987
PR-URL: https://github.com/nodejs/node-gyp/pull/992
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
2016-10-08 10:45:36 +02:00
Ben Noordhuis
e3778d9907 Add lots of findPython() tests.
Break up findPython() into pieces that can be tested in isolation and
add tests that do so.

PR-URL: https://github.com/nodejs/node-gyp/pull/992
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
2016-10-08 10:45:03 +02:00
Michael Hart
ddac348991 Use push on PYTHONPATH and add tests
Using push instead of the original unshift makes the logic a little
cleaner to read here.

PR-URL: https://github.com/nodejs/node-gyp/pull/990
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-10-07 10:38:25 +02:00
Michael Hart
7c08b85c5a Revert "configure: use "path-array" for PYTHONPATH"
This reverts commit ff88e5fd12.

Of the 5.5MB footprint of node-gyp, path-array makes up 3.6MB.

Removing this reduces the weight of npm (and thus node) appreciably.

PR-URL: https://github.com/nodejs/node-gyp/pull/990
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-10-07 10:37:06 +02:00
Richard Lau
77383ddd85 Replace fs.accessSync call to fs.statSync
fs.accessSync does not exist in Node 0.10.x.

PR-URL: https://github.com/nodejs/node-gyp/pull/955
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-06-17 19:57:46 +02:00
Ben Noordhuis
ac29d23a7c Upgrade to glob@7.0.3.
Matches what npm v2.15.5 and npm v3.8.6 use.

Fixes: https://github.com/nodejs/node-gyp/issues/941
PR-URL: https://github.com/nodejs/node-gyp/pull/943
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
2016-05-31 09:40:24 +02:00
Patrick Westerhoff
3bcb1720e4 Add support for the Python launcher on Windows
When looking for a Python executable on Windows, before falling back to
guessing the default location or failing completely, attempt to use the
Python launcher to figure out the location of the Python executable.

The Python launcher is being distributed by default with Python
distributions on Windows, and is placed in the %WINDIR% folder (which is
in the PATH). This allows us to locate a Python installation even if it
was installed without putting the python.exe executable itself into the
PATH.

Because the Python launcher supports all versions of Python, we have to
explicitly request a Python 2 version. This is done by supplying "-2" as
the first command line argument. Since "py.exe -2" would be an invalid
executable for "execFile", we have to use the launcher to figure out where
the actual "python.exe" executable is located.

PR-URL: https://github.com/nodejs/node-gyp/pull/894
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-03-31 13:28:41 +02:00
Refael Ackermann
268f1ca4c7 Use result of which when searching for python.
Fixes: https://github.com/nodejs/node-gyp/issues/667
Fixes: https://github.com/nodejs/node-gyp/issues/750
PR-URL: https://github.com/nodejs/node-gyp/pull/668
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-11-24 15:06:13 +01:00
Ben Noordhuis
817ed9bd78 Add test for python executable search logic.
Break out the search logic into a separate function and add a regression
test.

References: https://github.com/nodejs/node-gyp/pull/668
PR-URL: https://github.com/nodejs/node-gyp/pull/756
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2015-11-24 14:59:38 +01:00
Michael Dawson
9bfa0876b4 Add support for AIX
For AIX we need to use gmake.

For AIX we need to set up the path to the exp file which contains the
symbols needed for linking.  The file will either be in one of the
following depeding on whether are are in installed or development
environment:

  - the include/node directory
  - the out/Release directory

PR-URL: https://github.com/nodejs/node-gyp/pull/753
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2015-11-18 18:23:36 +01:00
Rod Vagg
938dd18d1c refactor for clarity, fix dist-url, add env var dist-url functionality
PR-URL: https://github.com/nodejs/node-gyp/pull/711
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-09-08 10:01:07 +10:00
Rod Vagg
9e9df66a06 use process.release, make aware of io.js & node v4 differences
PR-URL: https://github.com/nodejs/node-gyp/pull/711
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-09-08 09:59:31 +10:00
Yonggang Luo
9a2637e8d8 Setting NODE_GYP_DIR for addon.gypi to setting absolute path for src/win_delay_load_hook.c,
and fixes of the long relative path issue on Win32.
Fixes of #636
2015-05-31 09:36:35 +08:00
Nathan Rajlich
4dd6b1df0f configure: try/catcht the semver range.test() call
Should fix #621.
2015-05-28 11:09:59 -07:00
Nathan Rajlich
78a6e07a64 configure: fix "python" fallback logic
/cc @bendavis78. Part of #527.
2015-05-24 14:50:09 -07:00