Skip to content

Commit

Permalink
Merge pull request #48 from Aidan63/arm-mac
Browse files Browse the repository at this point in the history
Support ARM OSX
  • Loading branch information
krdlab authored Jul 14, 2024
2 parents 1abb31a + 822c0a7 commit 66f10ed
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
fail-fast: false
matrix:
os:
- macos-13
- macos-latest
- ubuntu-latest
- windows-latest
haxe:
Expand Down
24 changes: 13 additions & 11 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,12 @@ class Asset {
return found ? toolRoot : null;
}
}
// * NOTE https://github.com/HaxeFoundation/neko/releases/download/v2-3-0/neko-2.3.0-linux64.tar.gz
// * NOTE https://github.com/HaxeFoundation/neko/releases/download/v2-3-0/neko-2.3.0-osx64.tar.gz
// * NOTE https://github.com/HaxeFoundation/neko/releases/download/v2-3-0/neko-2.3.0-win64.zip
// * NOTE https://github.com/HaxeFoundation/neko/releases/download/v2-4-0-rc-1/neko-2.3.0-rc.1-linux64.tar.gz
// * NOTE https://github.com/HaxeFoundation/neko/releases/download/v2-4-0-rc-1/neko-2.4.0-rc.1-osx-universal.tar.gz
// * NOTE https://github.com/HaxeFoundation/neko/releases/download/v2-4-0-rc-1/neko-2.3.0-rc.1-win64.zip
class NekoAsset extends Asset {
static resolveFromHaxeVersion(version) {
const nekoVer = version.startsWith('3.') ? '2.1.0' : '2.3.0'; // Haxe 3 only supports neko 2.1
const nekoVer = version.startsWith('3.') ? '2.1.0' : '2.4.0-rc.1'; // Haxe 3 only supports neko 2.1
return new NekoAsset(nekoVer);
}
constructor(version, env = new Env()) {
Expand All @@ -169,6 +169,9 @@ class NekoAsset extends Asset {
if (this.env.platform === 'win' && this.version.startsWith('2.1')) {
return this.env.platform;
}
if (this.env.platform === 'osx' && this.version.startsWith('2.4')) {
return 'osx-universal';
}
return `${this.env.platform}${this.env.arch}`;
}
get fileNameWithoutExt() {
Expand Down Expand Up @@ -249,14 +252,13 @@ class Env {
}
get arch() {
const arch = external_node_os_namespaceObject.arch();
switch (arch) {
case 'x64': {
return '64';
}
default: {
throw new Error(`${arch} not supported`);
}
if (arch === 'x64') {
return '64';
}
if (arch === 'arm64' && this.platform === 'osx') {
return '64';
}
throw new Error(`${arch} not supported`);
}
}

Expand Down
27 changes: 16 additions & 11 deletions src/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ abstract class Asset {
}
}

// * NOTE https://github.com/HaxeFoundation/neko/releases/download/v2-3-0/neko-2.3.0-linux64.tar.gz
// * NOTE https://github.com/HaxeFoundation/neko/releases/download/v2-3-0/neko-2.3.0-osx64.tar.gz
// * NOTE https://github.com/HaxeFoundation/neko/releases/download/v2-3-0/neko-2.3.0-win64.zip
// * NOTE https://github.com/HaxeFoundation/neko/releases/download/v2-4-0-rc-1/neko-2.3.0-rc.1-linux64.tar.gz
// * NOTE https://github.com/HaxeFoundation/neko/releases/download/v2-4-0-rc-1/neko-2.4.0-rc.1-osx-universal.tar.gz
// * NOTE https://github.com/HaxeFoundation/neko/releases/download/v2-4-0-rc-1/neko-2.3.0-rc.1-win64.zip
export class NekoAsset extends Asset {
static resolveFromHaxeVersion(version: string) {
const nekoVer = version.startsWith('3.') ? '2.1.0' : '2.3.0'; // Haxe 3 only supports neko 2.1
const nekoVer = version.startsWith('3.') ? '2.1.0' : '2.4.0-rc.1'; // Haxe 3 only supports neko 2.1
return new NekoAsset(nekoVer);
}

Expand All @@ -126,6 +126,10 @@ export class NekoAsset extends Asset {
return this.env.platform;
}

if (this.env.platform === 'osx' && this.version.startsWith('2.4')) {
return 'osx-universal';
}

return `${this.env.platform}${this.env.arch}`;
}

Expand Down Expand Up @@ -229,14 +233,15 @@ export class Env {

get arch() {
const arch = os.arch();
switch (arch) {
case 'x64': {
return '64';
}

default: {
throw new Error(`${arch} not supported`);
}
if (arch === 'x64') {
return '64';
}

if (arch === 'arm64' && this.platform === 'osx') {
return '64';
}

throw new Error(`${arch} not supported`);
}
}

0 comments on commit 66f10ed

Please sign in to comment.