Skip to content

Commit

Permalink
Add macos arm binary
Browse files Browse the repository at this point in the history
  • Loading branch information
cknitt committed Feb 7, 2024
1 parent aeb3019 commit 0374212
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 22 deletions.
17 changes: 14 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,26 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
os: [
macos-13, # x64
macos-14, # ARM
ubuntu-latest,
windows-latest,
]
target: [rescript]
# syntax explanation:
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#example-including-additional-values-into-combinations
include:
- os: macos-latest
- os: macos-13
ocaml-compiler: 4.14.x
build: opam exec -- npm run build406
test: npm test
artifact-folder: darwin
- os: macos-14
ocaml-compiler: 4.14.x
build: opam exec -- npm run build406
test: npm test
artifact-folder: darwinarm64
- os: ubuntu-latest
ocaml-compiler: 4.14.x
build: opam exec -- npm run build406
Expand Down Expand Up @@ -110,7 +120,8 @@ jobs:
- name: Pack reanalyze
run: |
# Put the built artifacts in the appropriate package folder
tar xf macos-latest/binary.tar -C dist/vendor-darwin
tar xf macos-13/binary.tar -C dist/vendor-darwin
tar xf macos-14/binary.tar -C dist/vendor-darwinarm64
tar xf ubuntu-latest/binary.tar -C dist/vendor-linux
tar xf windows-latest/binary.tar -C dist/vendor-win32
Expand Down
35 changes: 18 additions & 17 deletions dist/postinstall.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
var path = require("path");
var fs = require("fs");
var platform = process.platform;
const path = require("path");
const fs = require("fs");

/* We always use the .exe extension, no matter if unix / win32 */
const targetPath = path.join(__dirname, "reanalyze.exe");
const platformAndArch =
process.arch === "x64" ? process.platform : process.platform + process.arch;

function fail(msg) {
console.warn(msg);
process.exit(1);
console.warn(msg);
process.exit(1);
}

function getPlatformBinaryPath(platform) {
return path.join(__dirname, "vendor-" + platform, "reanalyze.exe");
}

function movePlatformBinary(platform) {
const sourcePath = getPlatformBinaryPath(platform);
function movePlatformBinary() {
const binDirName = "vendor-" + platformAndArch;
const sourcePath = path.join(__dirname, binDirName, "reanalyze.exe");

if(!fs.existsSync(sourcePath)) {
return fail("error: executable not found: " + sourcePath);
if (!fs.existsSync(sourcePath)) {
return fail("error: executable not found: " + sourcePath);
}

// We always use the .exe extension, no matter if unix / win32
const targetPath = path.join(__dirname, "reanalyze.exe");

fs.renameSync(sourcePath, targetPath);
fs.chmodSync(targetPath, 0777);
}

switch (platform) {
switch (platformAndArch) {
case "win32":
case "linux":
case "darwin":
movePlatformBinary(platform);
case "darwinarm64":
movePlatformBinary();
break;
default:
fail("error: no release built for the " + platform + " platform");
Expand Down
Empty file added dist/vendor-darwinarm64/.keep
Empty file.
5 changes: 3 additions & 2 deletions scripts/prepare_release.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ const packageJson = JSON.stringify(
"postinstall.js",
"vendor-linux/",
"vendor-darwin/",
"vendor-win32/"
]
"vendor-darwinarm64/",
"vendor-win32/",
],
},
null,
2
Expand Down

0 comments on commit 0374212

Please sign in to comment.