Skip to content

Commit

Permalink
Revert "feat: add node-pre-gyp support (#1095)"
Browse files Browse the repository at this point in the history
This reverts commit e71316b.
  • Loading branch information
georgexu99 authored Aug 21, 2023
1 parent e71316b commit be3893c
Show file tree
Hide file tree
Showing 13 changed files with 14 additions and 167 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"detect-libc": "^2.0.1",
"fs-extra": "^10.0.0",
"got": "^11.7.0",
"node-abi": "^3.45.0",
"node-abi": "^3.0.0",
"node-api-version": "^0.1.4",
"node-gyp": "^9.0.0",
"ora": "^5.1.0",
Expand Down
1 change: 0 additions & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ process.on('unhandledRejection', handler);
useElectronClang: !!argv.useElectronClang,
disablePreGypCopy: !!argv.disablePreGypCopy,
projectRootPath,
buildFromSource: !!argv.buildFromSource,
});

const lifecycle = rebuilder.lifecycle;
Expand Down
31 changes: 3 additions & 28 deletions src/module-rebuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { cacheModuleState } from './cache';
import { NodeGyp } from './module-type/node-gyp/node-gyp';
import { Prebuildify } from './module-type/prebuildify';
import { PrebuildInstall } from './module-type/prebuild-install';
import { NodePreGyp } from './module-type/node-pre-gyp';
import { IRebuilder } from './types';

const d = debug('electron-rebuild');
Expand All @@ -17,7 +16,6 @@ export class ModuleRebuilder {
private rebuilder: IRebuilder;
private prebuildify: Prebuildify;
private prebuildInstall: PrebuildInstall;
private nodePreGyp: NodePreGyp;

constructor(rebuilder: IRebuilder, modulePath: string) {
this.modulePath = modulePath;
Expand All @@ -26,7 +24,6 @@ export class ModuleRebuilder {
this.nodeGyp = new NodeGyp(rebuilder, modulePath);
this.prebuildify = new Prebuildify(rebuilder, modulePath);
this.prebuildInstall = new PrebuildInstall(rebuilder, modulePath);
this.nodePreGyp = new NodePreGyp(rebuilder, modulePath);
}

get metaPath(): string {
Expand Down Expand Up @@ -92,21 +89,6 @@ export class ModuleRebuilder {
return false;
}

async findNodePreGypInstallModule(cacheKey: string): Promise<boolean> {
if (await this.nodePreGyp.usesTool()) {
d(`assuming is node-pre-gyp powered: ${this.nodePreGyp.moduleName}`);

if (await this.nodePreGyp.findPrebuiltModule()) {
d('installed prebuilt module:', this.nodePreGyp.moduleName);
await this.writeMetadata();
await this.cacheModuleState(cacheKey);
return true;
}
}

return false;
}

async rebuildNodeGypModule(cacheKey: string): Promise<boolean> {
await this.nodeGyp.rebuildModule();
d('built via node-gyp:', this.nodeGyp.moduleName);
Expand Down Expand Up @@ -142,15 +124,8 @@ export class ModuleRebuilder {
}

async rebuild(cacheKey: string): Promise<boolean> {
if (
!this.rebuilder.buildFromSource && (
(await this.findPrebuildifyModule(cacheKey)) ||
(await this.findPrebuildInstallModule(cacheKey)) ||
(await this.findNodePreGypInstallModule(cacheKey)))
) {
return true;
}

return await this.rebuildNodeGypModule(cacheKey);
return (await this.findPrebuildifyModule(cacheKey)) ||
(await this.findPrebuildInstallModule(cacheKey)) ||
(await this.rebuildNodeGypModule(cacheKey));
}
}
68 changes: 0 additions & 68 deletions src/module-type/node-pre-gyp.ts

This file was deleted.

3 changes: 0 additions & 3 deletions src/rebuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export interface RebuildOptions {
projectRootPath?: string;
forceABI?: number;
disablePreGypCopy?: boolean;
buildFromSource?: boolean;
}

export interface RebuilderOptions extends RebuildOptions {
Expand Down Expand Up @@ -61,7 +60,6 @@ export class Rebuilder implements IRebuilder {
public msvsVersion?: string;
public useElectronClang: boolean;
public disablePreGypCopy: boolean;
public buildFromSource: boolean;

constructor(options: RebuilderOptions) {
this.lifecycle = options.lifecycle;
Expand All @@ -78,7 +76,6 @@ export class Rebuilder implements IRebuilder {
this.prebuildTagPrefix = options.prebuildTagPrefix || 'v';
this.msvsVersion = process.env.GYP_MSVS_VERSION;
this.disablePreGypCopy = options.disablePreGypCopy || false;
this.buildFromSource = options.buildFromSource || false;

if (this.useCache && this.force) {
console.warn('[WARNING]: Electron Rebuild has force enabled and cache enabled, force take precedence and the cache will not be used.');
Expand Down
1 change: 0 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export interface IRebuilder {
msvsVersion?: string;
platform: string;
prebuildTagPrefix: string;
buildFromSource: boolean;
useCache: boolean;
useElectronClang: boolean;
}
3 changes: 1 addition & 2 deletions test/fixture/native-app1/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
"farmhash": "3.2.1",
"level": "6.0.0",
"native-hello-world": "2.0.0",
"ref-napi": "1.4.2",
"sqlite3": "5.1.6"
"ref-napi": "1.4.2"
},
"optionalDependencies": {
"bcrypt": "3.0.6"
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/module-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export async function resetTestModule(testModulePath: string, installModules = t
}

export async function cleanupTestModule(testModulePath: string): Promise<void> {
await fs.rmdir(testModulePath, { recursive: true, maxRetries: 10 });
await fs.remove(testModulePath);
resetMSVSVersion();
}

Expand Down
50 changes: 0 additions & 50 deletions test/module-type-node-pre-gyp.ts

This file was deleted.

5 changes: 1 addition & 4 deletions test/module-type-prebuild-install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ describe('prebuild-install', () => {
])
});

it('should not fail running prebuild-install', async function () {
if (process.platform === 'darwin' && process.arch === 'arm64') {
this.skip(); // farmhash module has no prebuilt binaries for ARM64
}
it('should not fail running prebuild-install', async () => {
const rebuilder = new Rebuilder(rebuilderArgs);
const prebuildInstall = new PrebuildInstall(rebuilder, modulePath);
expect(await prebuildInstall.findPrebuiltModule()).to.equal(true);
Expand Down
5 changes: 2 additions & 3 deletions test/rebuild-napibuildversion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('rebuild with napi_build_versions in binary config', async function ()
// https://github.com/electron/rebuild/issues/554
const archs = ['x64', 'arm64']
for (const arch of archs) {
it(`${ arch } arch should have rebuilt binary with 'napi_build_versions' array and 'libc' provided`, async () => {
it(`${ arch } arch should have rebuilt bianry with 'napi_build_versions' array and 'libc' provided`, async () => {
const libc = await detectLibc.family() || 'unknown'
const binaryPath = napiBuildVersionSpecificPath(arch, libc)

Expand All @@ -38,8 +38,7 @@ describe('rebuild with napi_build_versions in binary config', async function ()
await rebuild({
buildPath: testModulePath,
electronVersion: testElectronVersion,
arch,
buildFromSource: true, // need to skip node-pre-gyp prebuilt binary
arch
});

await expectNativeModuleToBeRebuilt(testModulePath, 'sqlite3');
Expand Down
2 changes: 1 addition & 1 deletion test/rebuild.ts
Original file line number Diff line number Diff line change
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
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3210,10 +3210,10 @@ nerf-dart@^1.0.0:
resolved "https://registry.yarnpkg.com/nerf-dart/-/nerf-dart-1.0.0.tgz#e6dab7febf5ad816ea81cf5c629c5a0ebde72c1a"
integrity sha512-EZSPZB70jiVsivaBLYDCyntd5eH8NTSMOn3rB+HxwdmKThGELLdYv8qVIMWvZEFy9w8ZZpW9h9OB32l1rGtj7g==

node-abi@^3.45.0:
version "3.45.0"
resolved "https://registry.yarnpkg.com/node-abi/-/node-abi-3.45.0.tgz#f568f163a3bfca5aacfce1fbeee1fa2cc98441f5"
integrity sha512-iwXuFrMAcFVi/ZoZiqq8BzAdsLw9kxDfTC0HMyjXfSL/6CSDAGD5UmR7azrAgWV1zKYq7dUUMj4owusBWKLsiQ==
node-abi@^3.0.0:
version "3.30.0"
resolved "https://registry.yarnpkg.com/node-abi/-/node-abi-3.30.0.tgz#d84687ad5d24ca81cdfa912a36f2c5c19b137359"
integrity sha512-qWO5l3SCqbwQavymOmtTVuCWZE23++S+rxyoHjXqUmPyzRcaoI4lA2gO55/drddGnedAyjA7sk76SfQ5lfUMnw==
dependencies:
semver "^7.3.5"

Expand Down

0 comments on commit be3893c

Please sign in to comment.