-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: replacing macro {napi_build_version} in binary filename (#1078)
* fix: replacing macro {napi_build_versions} in binary filename by using `binary.napi_build_versions` in package.json. Fixes: #554 * cleanup * move napi_build_version to separate test fixture refactored rebuild helper * whoops. missed an unused import * log all files? * log upper dir? something is missing on linux builds * fix linux builds by detecting libc family * cleanup * refactor due to new file location (tsc now runs first) * fix test? * fix test? * revert yarnworkspace changes to check against master * add fixtureName to tmp dir * cleanup and simplify * switch back to use detect-libc and see if test passes
- Loading branch information
Showing
8 changed files
with
81 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"name": "workspace-app", | ||
"productName": "Workspace App", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "src/index.js", | ||
"keywords": [], | ||
"author": "", | ||
"license": "MIT", | ||
"dependencies": { | ||
"sqlite3": "5.1.6" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import * as fs from 'fs-extra'; | ||
import * as path from 'path'; | ||
|
||
import { expect } from 'chai'; | ||
import { rebuild } from '../lib/rebuild'; | ||
import { getExactElectronVersionSync } from './helpers/electron-version'; | ||
import { TIMEOUT_IN_MILLISECONDS, TEST_MODULE_PATH as testModulePath, cleanupTestModule, resetTestModule } from './helpers/module-setup'; | ||
import { expectNativeModuleToBeRebuilt } from './helpers/rebuild'; | ||
import detectLibc from 'detect-libc'; | ||
|
||
const testElectronVersion = getExactElectronVersionSync(); | ||
|
||
describe('rebuild with napi_build_versions in binary config', async function () { | ||
this.timeout(TIMEOUT_IN_MILLISECONDS); | ||
|
||
const napiBuildVersion = 6; | ||
const napiBuildVersionSpecificPath = (arch: string, libc: string) => path.resolve(testModulePath, `node_modules/sqlite3/lib/binding/napi-v${ napiBuildVersion }-${ process.platform }-${ libc }-${ arch }/node_sqlite3.node`); | ||
|
||
before(async () => { | ||
await resetTestModule(testModulePath, true, 'napi-build-version') | ||
// Forcing `msvs_version` needed in order for `arm64` `win32` binary to be built | ||
process.env.GYP_MSVS_VERSION = "2019" | ||
}); | ||
after(() => cleanupTestModule(testModulePath)); | ||
|
||
// https://github.com/electron/rebuild/issues/554 | ||
const archs = ['x64', 'arm64'] | ||
for (const arch of archs) { | ||
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) | ||
|
||
if (await fs.pathExists(binaryPath)) { | ||
fs.removeSync(binaryPath) | ||
} | ||
expect(await fs.pathExists(binaryPath)).to.be.false; | ||
|
||
await rebuild({ | ||
buildPath: testModulePath, | ||
electronVersion: testElectronVersion, | ||
arch | ||
}); | ||
|
||
await expectNativeModuleToBeRebuilt(testModulePath, 'sqlite3'); | ||
expect(await fs.pathExists(binaryPath)).to.be.true; | ||
}); | ||
} | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters