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 Jul 31, 2023
1 parent f5b6067 commit 3a4c11a
Show file tree
Hide file tree
Showing 3 changed files with 44 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.

15 changes: 13 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 @@ -29,6 +31,9 @@ class QuickJSInstaller extends Installer {
}

static resolveVersion(version) {
if (['darwin-arm64', 'darwin-x64', 'linux-arm64'].includes(platform)) {
return '6.0.0';
}
if (version === 'latest') {
return fetch('https://bellard.org/quickjs/binary_releases/LATEST.json')
.then((r) => r.json())
Expand All @@ -38,8 +43,14 @@ class QuickJSInstaller extends Installer {
}

getDownloadURL(version) {
if (platform === 'darwin-arm64') {
return `https://github.com/napi-bindings/quickjs-build/releases/download/${version}/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/${version}/qjs-macOS.zip`;
}
if (platform === 'linux-arm64') {
return `https://github.com/napi-bindings/quickjs-build/releases/download/${version}/qjs-linux-arm64.zip`;
}
return `https://bellard.org/quickjs/binary_releases/quickjs-${getFilename()}-${version}.zip`;
}
Expand All @@ -49,7 +60,7 @@ class QuickJSInstaller extends Installer {
}

async install() {
if (platform === 'darwin-x64') {
if (platform === 'darwin-x64' || platform === 'darwin-arm64' || 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 3a4c11a

Please sign in to comment.