Skip to content

Commit

Permalink
feat: Change node-gyp to @electron/node-gyp (#1157)
Browse files Browse the repository at this point in the history
* fix: Change node-gyp to @electron/node-gyp

* fix: node-gyp has native promises now

* Move to a github version (temporarily)

* fix: Optional chaining

* test: Update the tests to ffi-napi

* fix: Use better-sqlite3 instead

* test: Nevermind, go with a simple module

* test: We're testing on one fewer module

* test: Use farmhash for clang testing
  • Loading branch information
felixrieseberg authored Oct 8, 2024
1 parent a235385 commit 96b462a
Show file tree
Hide file tree
Showing 7 changed files with 200 additions and 275 deletions.
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@
"keywords": [
"electron"
],
"author": "Paul Betts <[email protected]>",
"authors": [
"Ani Betts <[email protected]>",
"Electron Community"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/electron/rebuild/issues"
Expand All @@ -39,6 +42,7 @@
"node": ">=12.13.0"
},
"dependencies": {
"@electron/node-gyp": "https://github.com/electron/node-gyp#06b29aafb7708acef8b3669835c8a7857ebc92d2",
"@malept/cross-spawn-promise": "^2.0.0",
"chalk": "^4.0.0",
"debug": "^4.1.1",
Expand All @@ -47,7 +51,6 @@
"got": "^11.7.0",
"node-abi": "^3.45.0",
"node-api-version": "^0.2.0",
"node-gyp": "^9.0.0",
"ora": "^5.1.0",
"read-binary-file-arch": "^1.0.6",
"semver": "^7.3.5",
Expand Down
5 changes: 2 additions & 3 deletions src/module-type/node-gyp/worker.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import NodeGypRunner from 'node-gyp';
import { promisify } from 'util';
import NodeGypRunner from '@electron/node-gyp';

process.on('message', async ({
nodeGypArgs,
Expand All @@ -23,7 +22,7 @@ process.on('message', async ({
});
};
}
await promisify(nodeGyp.commands[command.name])(command.args);
await nodeGyp.commands[command.name](command.args);
command = nodeGyp.todo.shift();
}
process.exit(0);
Expand Down
2 changes: 1 addition & 1 deletion test/fixture/native-app1/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"devDependencies": {
"@types/node": "^12.0.10",
"ffi-napi": "4.0.3"
"windows-active-process": "1.1.1"
},
"dependencies": {
"@newrelic/native-metrics": "5.3.0",
Expand Down
55 changes: 8 additions & 47 deletions test/fixture/native-app1/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ core-util-is@~1.0.0:
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.3.tgz#a6042d3634c2b27e9328f837b965fac83808db85"
integrity sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==

debug@4, debug@^4.1.1, debug@^4.3.3:
debug@4, debug@^4.3.3:
version "4.3.5"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.5.tgz#e83444eceb9fedd4a1da56d671ae2446a01a6e1e"
integrity sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg==
Expand Down Expand Up @@ -371,18 +371,6 @@ [email protected]:
node-addon-api "^3.1.0"
prebuild-install "^6.0.1"

[email protected]:
version "4.0.3"
resolved "https://registry.yarnpkg.com/ffi-napi/-/ffi-napi-4.0.3.tgz#27a8d42a8ea938457154895c59761fbf1a10f441"
integrity sha512-PMdLCIvDY9mS32RxZ0XGb95sonPRal8aqRhLbeEtWKZTe2A87qRFG9HjOhvG8EX2UmQw5XNRMIOT+1MYlWmdeg==
dependencies:
debug "^4.1.1"
get-uv-event-loop-napi-h "^1.0.5"
node-addon-api "^3.0.0"
node-gyp-build "^4.2.1"
ref-napi "^2.0.1 || ^3.0.2"
ref-struct-di "^1.1.0"

[email protected]:
version "1.0.0"
resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd"
Expand Down Expand Up @@ -455,18 +443,6 @@ gauge@~2.7.3:
strip-ansi "^3.0.1"
wide-align "^1.1.0"

get-symbol-from-current-process-h@^1.0.1, get-symbol-from-current-process-h@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/get-symbol-from-current-process-h/-/get-symbol-from-current-process-h-1.0.2.tgz#510af52eaef873f7028854c3377f47f7bb200265"
integrity sha512-syloC6fsCt62ELLrr1VKBM1ggOpMdetX9hTrdW77UQdcApPHLmf7CI7OKcN1c9kYuNxKcDe4iJ4FY9sX3aw2xw==

get-uv-event-loop-napi-h@^1.0.5:
version "1.0.6"
resolved "https://registry.yarnpkg.com/get-uv-event-loop-napi-h/-/get-uv-event-loop-napi-h-1.0.6.tgz#42b0b06b74c3ed21fbac8e7c72845fdb7a200208"
integrity sha512-t5c9VNR84nRoF+eLiz6wFrEp1SE2Acg0wS+Ysa2zF0eROes+LzOfuTaVHxGy8AbS8rq7FHEJzjnCZo1BupwdJg==
dependencies:
get-symbol-from-current-process-h "^1.0.1"

[email protected]:
version "0.0.0"
resolved "https://registry.yarnpkg.com/github-from-package/-/github-from-package-0.0.0.tgz#97fb5d96bfde8973313f20e8288ef9a167fa64ce"
Expand Down Expand Up @@ -939,11 +915,6 @@ node-fetch@^2.6.7:
dependencies:
whatwg-url "^5.0.0"

node-gyp-build@^4.2.1:
version "4.8.0"
resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.8.0.tgz#3fee9c1731df4581a3f9ead74664369ff00d26dd"
integrity sha512-u6fs2AEUljNho3EYTJNBfImO5QTo/J/1Etd+NVdCj7qWKUSN/bSLkZwhDv7I+w/MSC6qJ4cknepkAYykDdK8og==

node-gyp-build@~4.1.0:
version "4.1.1"
resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.1.1.tgz#d7270b5d86717068d114cc57fff352f96d745feb"
Expand Down Expand Up @@ -1190,23 +1161,6 @@ [email protected]:
debug "^3.1.0"
node-addon-api "^1.6.2"

"ref-napi@^2.0.1 || ^3.0.2":
version "3.0.3"
resolved "https://registry.yarnpkg.com/ref-napi/-/ref-napi-3.0.3.tgz#e259bfc2bbafb3e169e8cd9ba49037dd00396b22"
integrity sha512-LiMq/XDGcgodTYOMppikEtJelWsKQERbLQsYm0IOOnzhwE9xYZC7x8txNnFC9wJNOkPferQI4vD4ZkC0mDyrOA==
dependencies:
debug "^4.1.1"
get-symbol-from-current-process-h "^1.0.2"
node-addon-api "^3.0.0"
node-gyp-build "^4.2.1"

ref-struct-di@^1.1.0:
version "1.1.1"
resolved "https://registry.yarnpkg.com/ref-struct-di/-/ref-struct-di-1.1.1.tgz#5827b1d3b32372058f177547093db1fe1602dc10"
integrity sha512-2Xyn/0Qgz89VT+++WP0sTosdm9oeowLP23wRJYhG4BFdMUrLj3jhwHZNEytYNYgtPKLNTP3KJX4HEgBvM1/Y2g==
dependencies:
debug "^3.1.0"

retry@^0.12.0:
version "0.12.0"
resolved "https://registry.yarnpkg.com/retry/-/retry-0.12.0.tgz#1b42a6266a21f07421d1b0b54b7dc167b01c013b"
Expand Down Expand Up @@ -1485,6 +1439,13 @@ wide-align@^1.1.0, wide-align@^1.1.2, wide-align@^1.1.5:
dependencies:
string-width "^1.0.2 || 2 || 3 || 4"

[email protected]:
version "1.1.1"
resolved "https://registry.yarnpkg.com/windows-active-process/-/windows-active-process-1.1.1.tgz#e64605d8a3f6d8811ea290fdbcec3f885e41f11c"
integrity sha512-L/ZF2JxmqQZxp8gPWTu4BOLsVms/ykZVdkkfQj4xtXvZiPOqRAiuI5gvjQS6WfXcRpSm6j8HrgB1KyG9/I2Mcg==
dependencies:
bindings "^1.2.1"

wrappy@1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
Expand Down
22 changes: 11 additions & 11 deletions test/rebuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('rebuilder', () => {
});

it('should not have rebuilt top level devDependencies', async () => {
await expectNativeModuleToNotBeRebuilt(testModulePath, 'ffi-napi');
await expectNativeModuleToNotBeRebuilt(testModulePath, 'windows-active-process');
});

it('should not download files in the module directory', async () => {
Expand Down Expand Up @@ -81,7 +81,7 @@ describe('rebuilder', () => {
skipped++;
});
await rebuilder;
expect(skipped).to.equal(8);
expect(skipped).to.equal(7);
});

it('should rebuild all modules again when disabled but the electron ABI changed', async () => {
Expand Down Expand Up @@ -169,13 +169,13 @@ describe('rebuilder', () => {
buildPath: testModulePath,
electronVersion: testElectronVersion,
arch: process.arch,
onlyModules: ['ffi-napi', 'ref-napi'], // TODO: check to see if there's a bug with scoped modules
onlyModules: ['windows-active-process', 'ref-napi'], // TODO: check to see if there's a bug with scoped modules
force: true
});
let built = 0;
rebuilder.lifecycle.on('module-done', () => built++);
await rebuilder;
expect(built).to.equal(3);
expect(built).to.equal(2);
});
});

Expand All @@ -185,17 +185,17 @@ describe('rebuilder', () => {
before(async () => await resetTestModule(testModulePath));
after(async() => await cleanupTestModule(testModulePath));

it('should have rebuilt ffi-napi module in Debug mode', async () => {
it('should have rebuilt farmhash module in Debug mode', async () => {
await rebuild({
buildPath: testModulePath,
electronVersion: testElectronVersion,
arch: process.arch,
onlyModules: ['ffi-napi'],
onlyModules: ['farmhash'],
force: true,
debug: true
});
await expectNativeModuleToBeRebuilt(testModulePath, 'ffi-napi', { buildType: 'Debug' });
await expectNativeModuleToNotBeRebuilt(testModulePath, 'ffi-napi');
await expectNativeModuleToBeRebuilt(testModulePath, 'farmhash', { buildType: 'Debug' });
await expectNativeModuleToNotBeRebuilt(testModulePath, 'farmhash');
});
});

Expand All @@ -205,16 +205,16 @@ describe('rebuilder', () => {
before(async () => await resetTestModule(testModulePath));
after(async() => await cleanupTestModule(testModulePath));

it('should have rebuilt ffi-napi module using clang mode', async () => {
it('should have rebuilt farmhash module using clang mode', async () => {
await rebuild({
buildPath: testModulePath,
electronVersion: testElectronVersion,
arch: process.arch,
onlyModules: ['ffi-napi'],
onlyModules: ['farmhash'],
force: true,
useElectronClang: true
});
await expectNativeModuleToBeRebuilt(testModulePath, 'ffi-napi');
await expectNativeModuleToBeRebuilt(testModulePath, 'farmhash');
});
});
});
2 changes: 1 addition & 1 deletion typings/ambient.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
declare module 'node-gyp';
declare module '@electron/node-gyp';
Loading

0 comments on commit 96b462a

Please sign in to comment.