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

Feature/apple m1 support #297

Merged
merged 10 commits into from
Jan 14, 2021
1 change: 1 addition & 0 deletions dl_binaries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ version="$(curl -sS https://update.tabnine.com/bundles/version)"
targets='i686-pc-windows-gnu
i686-unknown-linux-musl
x86_64-apple-darwin
aarch64-apple-darwin
x86_64-pc-windows-gnu
x86_64-unknown-linux-musl'

Expand Down
22 changes: 22 additions & 0 deletions src/binary/paths.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as os from "os";
import { BINARY_ROOT_PATH } from "../consts";

const ARCHITECTURE = getArch();
Expand Down Expand Up @@ -26,7 +27,28 @@ function getSuffix(): string {
}
}

function isAppleM1() : boolean {
try {
if (process.platform !== "darwin") return false;

if (process.arch === 'arm64') return true;

const cpus = os.cpus() || [];
const cpu = cpus[0];
if (cpu && cpu.model === "Apple M1") return true;

} catch(err) {
console.error(err);
}

return false;
}

function getArch(): string {
if (isAppleM1()) {
return "aarch64";
}

if (process.arch === "x32" || process.arch === "ia32") {
return "i686";
}
Expand Down