Commit graph

96 commits

Author SHA1 Message Date
Felix Rieseberg
3f80e318cd test: Require with empty cache 2024-10-08 10:49:03 -04:00
Chengzhong Wu
d38af2e0c2
feat: allow VCINSTALLDIR to specify a portable instance (#3036) 2024-07-09 16:13:40 +01:00
Toyo Li
6318d2b210
feat: support rebuild and build for cross-compiling Node-API module to wasm on Windows (#2974) 2024-06-28 15:36:30 +01:00
Hüseyin Açacak
323957b74e
win: add an arch check to VS 2019 (#3025) 2024-04-23 15:46:11 +02:00
Christian Clauss
0bab6a071b
GitHub Actions: npm test is failing Windows tests on M1 Macs (#3011)
* GitHub Actions: npm test is failing Windows tests on M1 Macs

`npm test` is running and failing Windows `find-visualstudio` tests on an M1 Mac!!!

These tests are not being run or not failing on Intel Macs.

* Only run "Find Visual Studio" tests on Windows

* Update test/test-find-visualstudio.js

Co-authored-by: Christian Clauss <cclauss@me.com>

---------

Co-authored-by: Stefan Stojanovic <StefanStojanovic@users.noreply.github.com>
2024-04-11 17:34:49 +02:00
Hüseyin Açacak
c4729129da
lib: print Python executable path using UTF-8 (#2995)
* lib: print Python executable path using UTF-8

The Python executable path may have non-ASCII characters, which can make
the print function fail if the environment encoding is different. This fixes
this issue by using stdout.buffer, which can be used with UTF-8 encoding
for the output, regardless of the environment encoding.

Fixes: https://github.com/nodejs/node-gyp/issues/2829

* fixup! lib: print Python executable path using UTF-8
2024-03-13 09:20:35 -07:00
Stefan Stojanovic
391cc5b9b2
win: update supported vs versions (#2959)
Drop VS2017 support for Node.js v22 and above.

Refs: https://github.com/nodejs/build/pull/3603
Refs: https://github.com/nodejs/node/pull/45427
2024-03-06 17:32:44 +01:00
Jaroslav
109e3d4245
feat: improve visual studio detection (#2957)
Detect visual studio installation using the VSSetup module and
Get-VSSetupInstance method. It works even in systems with the
Constrained language mode of PowerShell.
2024-02-09 02:33:54 +01:00
Michael Dawson
329873141f
src: add support for locally installed headers (#2964)
Some linux distros allow headers to be installed through
tools like rpm. If the runtime sets
process.config.variables.use_prefix_to_find_headers, look
for matching headers based on the directory set for the
prefix in process.config.variables.prefix

Signed-off-by: Michael Dawson <midawson@redhat.com>
Co-authored-by: Luke Karrys <luke@lukekarrys.com>
2024-01-29 12:03:30 -07:00
Luke Karrys
a68586a67d
chore: use platform specific timeouts in tests 2023-10-29 11:06:34 -07:00
Luke Karrys
4e0ed99256
chore: lint fixes 2023-10-29 10:45:50 -07:00
Luke Karrys
7de1f5f32d
chore: add parallel test logging 2023-10-29 10:29:40 -07:00
Luke Karrys
4e493d4fb2
chore: misc testing fixes (#2930)
* chore: misc test fixes

* Sort test runs by os first

* Use cross-env for test env var

* Try sorting matrix params

* Make FAST_TEST the default and rename to FULL_TEST

* Separate helper functions to not need to export test obj in files
2023-10-28 14:13:10 -07:00
Luke Karrys
d52997e975 feat: convert internal classes from util.inherits to classes
BREAKING CHANGE: the `Gyp` class exported is now created using
ECMAScript classes and therefore might have small differences to classes
that were previously created with `util.inherits`.
2023-10-28 09:29:04 -07:00
Luke Karrys
355622f4aa feat: convert all internal functions to async/await
BREAKING CHANGE: All internal functions have been coverted to return
promises and no longer accept callbacks. This is not a breaking change
for users but may be breaking to consumers of `node-gyp` if you are
requiring internal functions directly.
2023-10-28 08:59:57 -07:00
Rich Trott
5746691a36
test: update expired certs (#2908) 2023-09-28 07:56:36 +02:00
Tim Perry
0f1f667b73
fix: create Python symlink only during builds, and clean it up after (#2721)
* fix: create Python symlink only during builds, and clean it up after

Previously in b9ddcd5bbd this was created
during configuration, and the symlink persisted indefinitely. This
causes problems with many tools that do not expect a codebase to include
symlinks to external absolute paths.

This PR largely reverts that commit, and instead writes the path to
link to into the config, and then creates the symlink only temporarily
during the build process, always deleting it afterwards.

* assert install_path == self.output, f"{install_path} != {self.output}"

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
2023-08-01 10:02:59 +02:00
James Cook
53c99ae573
Fix reading msvs version on Windows (#2644)
* fix: fix reading msvs version on windows
2023-06-25 17:35:41 +02:00
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
Stefan Stojanovic
7a3fe1c437
win,install: only download target_arch node.lib (#2857)
Instead of downloading node.lib for all architectures, just download the
one that will be needed. Install.js changed to enable downloading just
node.lib for node versions that already have tarball downloaded and
extracted. Not fetching lib now fails the installation. Increased
installVersion because of the changes.

Refs: https://github.com/nodejs/node-gyp/issues/2847
2023-06-09 17:38:42 +02:00
Stefan Stojanovic
5df2b72a8f
Migration from tap to mocha (#2851)
* migrate from tap to mocha

After make-fetch-happen update GitHub Actions started failing. Migrating
from tap to mocha testing framework for GitHub Action stability.

* write custom test reporter for more verbose output

Implemented a simple custom mocha test reporter to replace the default
one. Made test report more developer friendly.
2023-06-05 17:05:29 +02:00
David Sanders
aaa117c514
fix: extract tarball to temp directory on Windows (#2846)
* fix: check for errors while extracting downloaded tarball

Signed-off-by: David Sanders <dsanders11@ucsbalum.com>

* test: parallel installs

Signed-off-by: David Sanders <dsanders11@ucsbalum.com>

* fix: extract tarball to temp directory on Windows

Signed-off-by: David Sanders <dsanders11@ucsbalum.com>

---------

Signed-off-by: David Sanders <dsanders11@ucsbalum.com>
2023-05-25 17:24:07 +02:00
Dennis Ameling
bb76021d35 feat: add support for native windows arm64 build tools
Visual Studio 2022 17.4 adds a native C++ compiler for Windows on ARM.
This allows arm64 devices to leverage native build tools, leading to
a 35% (or more) speed increase.
https://devblogs.microsoft.com/visualstudio/arm64-visual-studio-is-officially-here/

Signed-off-by: Dennis Ameling <dennis@dennisameling.com>
2023-05-25 12:29:04 +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
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
Rod Vagg
147e3d34f4 fix: new ca & server certs, bundle in .js file and unpack for testing
bundling in certs.js rather than including the raw files should avoid some
false positives that low-quality security scanners keep on complaining about.
2022-05-12 13:31:40 +10:00
Cheng Zhao
eef4eefccb fix: _ in npm_config_ env variables 2022-02-16 10:48:47 +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
Christian Clauss
0093ec8646 gyp: Improve our flake8 linting tests
PR-URL: https://github.com/nodejs/node-gyp/pull/2356
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
2021-03-31 07:38:26 +00:00
DeeDeeG
1bd18f3e77
lib: drop Python 2 support in find-python.js (#2333)
Co-authored-by: Christian Clauss <cclauss@me.com>

PR-URL: https://github.com/nodejs/node-gyp/pull/2333
Reviewed-By: Christian Clauss <cclauss@me.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
2021-03-26 19:57:06 +08:00
Matias Lopez
e81602ef55
lib: migrate requests to fetch (#2220)
PR-URL: https://github.com/nodejs/node-gyp/pull/2220
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
2021-03-18 09:30:04 +08:00
Christian Clauss
a78b584236
gyp: remove support for Python 2 (#2300)
PR-URL: https://github.com/nodejs/node-gyp/pull/2300
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
2021-02-14 12:51:19 +08:00
Shelley Vohr
2317dc400c
ci: switch to GitHub Actions
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: Matias Lopez <imatlopez@gmail.com>
PR-URL: https://github.com/nodejs/node-gyp/pull/2210
Closes: #2127
Closes: #2209
2020-10-15 10:24:59 +11: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
DeeDeeG
c255ffbf6a
lib: drop "-2" flag for "py.exe" launcher
Now that node-gyp supports both Python 2 and Python 3,
We don't need to explicitly try to find only Python 2.

Fixes: https://github.com/nodejs/node-gyp/issues/2130
Refs: https://docs.python.org/3/using/windows.html#launcher
PR-URL: https://github.com/nodejs/node-gyp/pull/2131
Reviewed-By: Christian Clauss <cclauss@me.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
2020-05-18 11:08:46 +10:00
Rod Vagg
470cc2178e test: remove old docker test harness (#1993)
PR-URL: https://github.com/nodejs/node-gyp/pull/1993
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
2019-12-29 15:49:13 +08:00
Richard Lau
5a729e86ee
test: fix typo in header download test (#2001)
PR-URL: https://github.com/nodejs/node-gyp/pull/2001
Reviewed-By: Christian Clauss <cclauss@me.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
2019-12-23 02:58:15 +00:00
Matias Lopez
3bcba2a01a
lib: noproxy support, match proxy detection to request
PR-URL: https://github.com/nodejs/node-gyp/pull/1978
Reviewed-By: Rod Vagg <rod@vagg.org>
2019-12-16 10:53:03 +11:00
Rod Vagg
0670e5189d
test: add header download test
PR-URL: https://github.com/nodejs/node-gyp/pull/1796
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-11-18 13:31:15 +11:00
Rod Vagg
c506a6a150
test: configure proper devDir for invoking configure()
test/test-configure-python.js downloads a fresh set of headers to the
package directory each time. By setting to the default global cache dir
we get to re-use cached headers and skip the download step.

PR-URL: https://github.com/nodejs/node-gyp/pull/1796
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-11-18 13:30:35 +11:00
Sam Roberts
dd0e97ef0b
lib: try to find python after python3
Unadorned `python` can be either Python 2 or Python 3, but it is likely
to be Python 2 for quite a while.

To find Python3, it is recommended to use the explicit name `python3`.

See:
- https://www.python.org/dev/peps/pep-0394/#for-python-runtime-distributors
- https://github.com/nodejs/node-gyp/pull/1892#issuecomment-537637433

PR-URL: https://github.com/nodejs/node-gyp/pull/1907
Reviewed-By: Christian Clauss <cclauss@me.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: João Reis <reis@janeasystems.com>
2019-10-04 13:25:04 +10:00
João Reis
968c9067d7
win: support VS 2017 Desktop Express
Fixes: https://github.com/nodejs/node-gyp/issues/1881
PR-URL: https://github.com/nodejs/node-gyp/pull/1902
Reviewed-By: Rod Vagg <rod@vagg.org>
2019-10-03 11:08:29 +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
Richard Townsend
2441932dc4 src,win: add support for fetching arm64 node.lib
Windows on Arm support is available in some versions of Node.js v12 and
Electron v6. This update allows node-gyp to fetch the appropriate
node.lib to build native modules. If an arm64 binary is not available
for the target node version, it's logged but ignored.

arm64 is not expected to work in very old node.lib distribution formats,
the test URLs in these cases are added to be consistent with x64.

PR-URL: https://github.com/nodejs/node-gyp/pull/1875
Reviewed-By: João Reis <reis@janeasystems.com>
2019-09-30 22:49:26 +01:00
João Reis
a2a862f6ba test: accept Python 3 in test-find-python.js
Fixes: https://github.com/nodejs/node-gyp/issues/1826
PR-URL: https://github.com/nodejs/node-gyp/pull/1843
Reviewed-By: Christian Clauss <cclauss@me.com>
Reviewed-By: Rod Vagg <r@va.gg>
Reviewed-By: Matt Cowley <me@mattcowley.co.uk>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-07-26 15:40:15 +01:00
Ben Noordhuis
0878db3b81
Revert "build,test: add duplicate symbol test"
This reverts commit 2761afbf73.

Building with `-fvisibility=hidden` breaks some of Node's add-on tests
and therefore likely also affects third-party add-ons. This change was
landed in a patch release so I'm opting to revert it until the next
major release.

PR-URL: https://github.com/nodejs/node-gyp/pull/1828
Refs: https://github.com/nodejs/node/pull/28647#issuecomment-511715968
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
2019-07-17 14:29:16 +10:00
João Reis
66ad305775 python: accept Python 3 conditionally
This allows us to start testing Python 3 without breaking node-gyp
for users.

This also adds support for NODE_GYP_FORCE_PYTHON, which will be the
only Python binary acceptable when defined.

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
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
João Reis
656117cc4a win: make VS path match case-insensitive
Fixes: https://github.com/nodejs/node-gyp/issues/1805
PR-URL: https://github.com/nodejs/node-gyp/pull/1806
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
2019-07-08 16:06:24 +01:00