Skip to content

Commit

Permalink
feat: support quickjs arm64 for linux and macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
gengjiawen committed Apr 28, 2023
1 parent 0cc505a commit 79f45a5
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 36 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ installing engines to make eshost automatically find the installed engines.
| [Hermes][] | `hermes` || | | | | ||
| [LibJS][] | `serenity-js` ||| || | | |
| [JavaScriptCore][] | `jsc`, `javascriptcore` ||| || | ||
| [QuickJS][] | `quickjs`, `quickjs-run-test262` || ||| |||
| [QuickJS][] | `quickjs`, `quickjs-run-test262` || ||| |||
| [SpiderMonkey][] | `sm`, `spidermonkey` ||||| |||
| [V8][] | `v8` ||||| |||
| [XS][] | `xs` || ||| | ||
Expand Down
63 changes: 30 additions & 33 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions src/engines/quickjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ function getFilename() {
return 'win-i686';
case 'win32-x64':
return 'win-x86_64';
case 'linux-arm64':
return 'linux-aarch64';
default:
throw new Error(`No QuickJS builds available for ${platform}`);
}
Expand All @@ -38,8 +40,15 @@ class QuickJSInstaller extends Installer {
}

getDownloadURL(version) {
const baseVersion = '6.0.0';
if (platform === 'darwin-arm64') {
return `https://github.com/napi-bindings/quickjs-build/releases/download/${baseVersion}/qjs-macOS-arm64.zip`;
}
if (platform === 'darwin-x64') {
return 'https://github.com/napi-bindings/quickjs-build/releases/download/5.2.0/qjs-macOS.zip';
return `https://github.com/napi-bindings/quickjs-build/releases/download/${baseVersion}/qjs-macOS.zip`;
}
if (platform === 'linux-arm64') {
return `https://github.com/napi-bindings/quickjs-build/releases/download/${baseVersion}/qjs-linux-arm64.zip`;
}
return `https://bellard.org/quickjs/binary_releases/quickjs-${getFilename()}-${version}.zip`;
}
Expand All @@ -49,7 +58,7 @@ class QuickJSInstaller extends Installer {
}

async install() {
if (platform === 'darwin-x64') {
if (platform === 'darwin-x64' || platform === 'linux-arm64') {
this.binPath = await this.registerBinary('quickjs');
await this.registerBinary('run-test262', 'quickjs-run-test262');
} else if (platform.startsWith('win')) {
Expand Down

0 comments on commit 79f45a5

Please sign in to comment.