Skip to content

Commit c1a3aea

Browse files
korbinstathis-alexander
authored andcommitted
add musl build target
1 parent 47fb852 commit c1a3aea

File tree

5 files changed

+28
-5
lines changed

5 files changed

+28
-5
lines changed

packages/core-bridge/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
artifacts.json
2-
index.node
32
target/
3+
.npmrc

packages/core-bridge/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ opt-level = 3
1818
debug = false
1919
lto = true
2020
incremental = false
21+
strip = true
2122

2223
[dependencies]
2324
anyhow = "1.0"

packages/core-bridge/common.js

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,20 @@ const targets = [
1414
'aarch64-apple-darwin',
1515
'x86_64-unknown-linux-gnu',
1616
'aarch64-unknown-linux-gnu',
17+
'x86_64-unknown-linux-musl',
18+
'aarch64-unknown-linux-musl',
1719
// TODO: this is not supported on macos
1820
'x86_64-pc-windows-msvc',
1921
'x86_64-pc-windows-gnu',
2022
];
2123

2224
const archAlias = { x64: 'x86_64', arm64: 'aarch64' };
23-
const platformMapping = { darwin: 'apple-darwin', linux: 'unknown-linux-gnu', win32: 'pc-windows-msvc' };
25+
const platformMapping = {
26+
darwin: 'apple-darwin',
27+
linux: 'unknown-linux-gnu',
28+
linux_musl: 'unknown-linux-musl',
29+
win32: 'pc-windows-msvc',
30+
};
2431

2532
class PrebuildError extends Error {
2633
constructor(message) {
@@ -29,12 +36,17 @@ class PrebuildError extends Error {
2936
}
3037
}
3138

39+
function isMuslSystem() {
40+
return process.report.getReport().sharedObjects.some((lib) => lib.includes('musl'));
41+
}
42+
3243
function getPrebuiltTargetName() {
3344
const arch = archAlias[os.arch()];
3445
if (arch === undefined) {
3546
throw new PrebuildError(`No prebuilt module for arch ${os.arch()}`);
3647
}
37-
const platform = platformMapping[os.platform()];
48+
49+
const platform = isMuslSystem() ? platformMapping[`${os.platform()}_musl`] : platformMapping[os.platform()];
3850
if (platform === undefined) {
3951
throw new PrebuildError(`No prebuilt module for platform ${os.platform()}`);
4052
}
@@ -50,4 +62,12 @@ function getPrebuiltPath() {
5062
}
5163
}
5264

53-
module.exports = { targets, archAlias, platformMapping, PrebuildError, getPrebuiltPath, getPrebuiltTargetName };
65+
module.exports = {
66+
targets,
67+
archAlias,
68+
platformMapping,
69+
PrebuildError,
70+
getPrebuiltPath,
71+
getPrebuiltTargetName,
72+
isMuslSystem,
73+
};

packages/core-bridge/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"node": ">= 18.0.0"
4242
},
4343
"files": [
44+
"bridge-macros",
4445
"scripts",
4546
"src",
4647
"releases",
@@ -54,6 +55,6 @@
5455
"lib"
5556
],
5657
"publishConfig": {
57-
"access": "public"
58+
"registry": "https://npm.pkg.github.com"
5859
}
5960
}

packages/core-bridge/scripts/build.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ function compile(requestedTarget) {
9393
if (status !== 0 || error) {
9494
throw new Error(`Failed to build${target ? ' for ' + target : ''}: status code ${status}`, error);
9595
}
96+
try { fs.rmdirSync('target', { recursive: true }); } catch (err) { }
9697
}
9798

9899
if (requestedTargets.length > 0) {

0 commit comments

Comments
 (0)