Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support quickjs arm64 and linux and macOS #47

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
17 changes: 15 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,11 @@ class QuickJSInstaller extends Installer {
}

static resolveVersion(version) {
if (['darwin-arm64', 'darwin-x64', 'linux-arm64'].includes(platform)) {
return fetch('https://api.github.com/repos/napi-bindings/quickjs-build/releases')
.then((r) => r.json())
.then((b) => b[0].tag_name);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think this is inherently sorted the way you might expect. see graal for example.

}
if (version === 'latest') {
return fetch('https://bellard.org/quickjs/binary_releases/LATEST.json')
.then((r) => r.json())
Expand All @@ -38,8 +45,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`;
}
Comment on lines +48 to +50
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think these could all be collapsed into

`https://github.com/napi-bindings/quickjs-build/releases/download/${version}/${getFilename()}.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 +62,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