Skip to content

Commit

Permalink
check is musl when the platform is linux
Browse files Browse the repository at this point in the history
  • Loading branch information
tnyo43 committed May 11, 2024
1 parent 51db3b8 commit 88b79fd
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion scripts/binaryName.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const { execSync } = require("node:child_process");
const { platform, arch } = process;

const BIN_NAME_OF_PLATFORM = {
Expand All @@ -9,8 +10,25 @@ const BIN_NAME_OF_PLATFORM = {
x64: "main-x86_64-unknown-linux-gnu",
arm64: "main-aarch64-unknown-linux-gnu",
},
"linux-musl": {
x64: "main-x86_64-unknown-linux-musl",
arm64: "main-aarch64-unknown-linux-musl",
},
};

const binName = BIN_NAME_OF_PLATFORM[platform]?.[arch];
function isMusl() {
let stderr;
try {
execSync("ldd --version", { stdio: ["pipe", "pipe", "pipe"] });
} catch (err) {
stderr = err;
}
return stderr?.toString()?.indexOf("musl") > -1;
}

const binName =
platform === "linux" && isMusl()
? BIN_NAME_OF_PLATFORM["linux-musl"]?.[arch]
: BIN_NAME_OF_PLATFORM[platform]?.[arch];

exports.binName = binName;

0 comments on commit 88b79fd

Please sign in to comment.