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

Support musl-libc and android #265

Merged
merged 3 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,7 @@ jobs:
env:
NODE_AUTH_TOKEN: '${{ secrets.NPM_TOKEN }}'
run: |
for pkg in linux-arm linux-arm64 linux-ia32 linux-x64 darwin-arm64 darwin-x64 win32-ia32 win32-x64; do
npx ts-node ./tool/prepare-optional-release.ts --package=$pkg && npm publish ./npm/$pkg
done
find ./npm -mindepth 1 -maxdepth 1 -print0 | xargs -0 -n 1 -- sh -xc 'npx ts-node ./tool/prepare-optional-release.ts --package=$(basename $1) && npm publish $1' --

- run: npm publish
env:
Expand Down
38 changes: 28 additions & 10 deletions lib/src/compiler-path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,35 @@ import * as fs from 'fs';
import * as p from 'path';
import {isErrnoException} from './utils';

/**
* Detect if the current running node binary is linked with musl libc by
* checking if the binary contains a string like "/.../ld-musl-$ARCH.so"
*/
const isLinuxMusl = function () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: document this (in particular why it works consistently)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a comment

return fs.readFileSync(process.execPath).includes('/ld-musl-');
};

/** The full command for the embedded compiler executable. */
export const compilerCommand = (() => {
const platform =
process.platform === 'linux' && isLinuxMusl()
? 'linux-musl'
: (process.platform as string);

// https://github.com/sass/embedded-host-node/issues/263
// Use windows-x64 emulation on windows-arm64
//
// TODO: Make sure to remove "arm64" from "npm/win32-x64/package.json" when
// this logic is removed once we have true windows-arm64 support.
const arch =
platform === 'win32' && process.arch === 'arm64' ? 'x86' : process.arch;

// find for development
for (const path of ['vendor', '../../../lib/src/vendor']) {
const executable = p.resolve(
__dirname,
path,
`dart-sass/sass${process.platform === 'win32' ? '.bat' : ''}`
`dart-sass/sass${platform === 'win32' ? '.bat' : ''}`
);

if (fs.existsSync(executable)) return [executable];
Expand All @@ -22,13 +43,11 @@ export const compilerCommand = (() => {
try {
return [
require.resolve(
`sass-embedded-${process.platform}-${process.arch}/` +
'dart-sass/src/dart' +
(process.platform === 'win32' ? '.exe' : '')
`sass-embedded-${platform}-${arch}/dart-sass/src/dart` +
(platform === 'win32' ? '.exe' : '')
),
require.resolve(
`sass-embedded-${process.platform}-${process.arch}/` +
'dart-sass/src/sass.snapshot'
`sass-embedded-${platform}-${arch}/dart-sass/src/sass.snapshot`
),
];
} catch (ignored) {
Expand All @@ -38,9 +57,8 @@ export const compilerCommand = (() => {
try {
return [
require.resolve(
`sass-embedded-${process.platform}-${process.arch}/` +
'dart-sass/sass' +
(process.platform === 'win32' ? '.bat' : '')
`sass-embedded-${platform}-${arch}/dart-sass/sass` +
(platform === 'win32' ? '.bat' : '')
),
];
} catch (e: unknown) {
Expand All @@ -52,7 +70,7 @@ export const compilerCommand = (() => {
throw new Error(
"Embedded Dart Sass couldn't find the embedded compiler executable. " +
'Please make sure the optional dependency ' +
`sass-embedded-${process.platform}-${process.arch} is installed in ` +
`sass-embedded-${platform}-${arch} is installed in ` +
'node_modules.'
);
})();
3 changes: 3 additions & 0 deletions npm/android-arm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# `sass-embedded-android-arm`

This is the **android-arm** binary for [`sass-embedded`](https://www.npmjs.com/package/sass-embedded)
23 changes: 23 additions & 0 deletions npm/android-arm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "sass-embedded-android-arm",
"version": "1.69.5",
"description": "The android-arm binary for sass-embedded",
"repository": "sass/embedded-host-node",
"author": "Google Inc.",
"license": "MIT",
"files": [
"dart-sass/**/*"
],
"engines": {
"node": ">=14.0.0"
},
"bin": {
"sass": "./dart-sass/sass"
},
"os": [
"android"
],
"cpu": [
"arm"
]
}
3 changes: 3 additions & 0 deletions npm/android-arm64/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# `sass-embedded-android-arm64`

This is the **android-arm64** binary for [`sass-embedded`](https://www.npmjs.com/package/sass-embedded)
23 changes: 23 additions & 0 deletions npm/android-arm64/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "sass-embedded-android-arm64",
"version": "1.69.5",
"description": "The android-arm64 binary for sass-embedded",
"repository": "sass/embedded-host-node",
"author": "Google Inc.",
"license": "MIT",
"files": [
"dart-sass/**/*"
],
"engines": {
"node": ">=14.0.0"
},
"bin": {
"sass": "./dart-sass/sass"
},
"os": [
"android"
],
"cpu": [
"arm64"
]
}
3 changes: 3 additions & 0 deletions npm/android-ia32/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# `sass-embedded-android-ia32`

This is the **android-ia32** binary for [`sass-embedded`](https://www.npmjs.com/package/sass-embedded)
23 changes: 23 additions & 0 deletions npm/android-ia32/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "sass-embedded-android-ia32",
"version": "1.69.5",
"description": "The android-ia32 binary for sass-embedded",
"repository": "sass/embedded-host-node",
"author": "Google Inc.",
"license": "MIT",
"files": [
"dart-sass/**/*"
],
"engines": {
"node": ">=14.0.0"
},
"bin": {
"sass": "./dart-sass/sass"
},
"os": [
"android"
],
"cpu": [
"ia32"
]
}
3 changes: 3 additions & 0 deletions npm/android-x64/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# `sass-embedded-android-x64`

This is the **android-x64** binary for [`sass-embedded`](https://www.npmjs.com/package/sass-embedded)
23 changes: 23 additions & 0 deletions npm/android-x64/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "sass-embedded-android-x64",
"version": "1.69.5",
"description": "The android-x64 binary for sass-embedded",
"repository": "sass/embedded-host-node",
"author": "Google Inc.",
"license": "MIT",
"files": [
"dart-sass/**/*"
],
"engines": {
"node": ">=14.0.0"
},
"bin": {
"sass": "./dart-sass/sass"
},
"os": [
"android"
],
"cpu": [
"x64"
]
}
3 changes: 3 additions & 0 deletions npm/linux-musl-arm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# `sass-embedded-linux-musl-arm`

This is the **linux-musl-arm** binary for [`sass-embedded`](https://www.npmjs.com/package/sass-embedded)
20 changes: 20 additions & 0 deletions npm/linux-musl-arm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "sass-embedded-linux-musl-arm",
"version": "1.69.5",
"description": "The linux-musl-arm binary for sass-embedded",
"repository": "sass/embedded-host-node",
"author": "Google Inc.",
"license": "MIT",
"files": [
"dart-sass/**/*"
],
"engines": {
"node": ">=14.0.0"
},
"os": [
"linux"
],
"cpu": [
"arm"
]
}
3 changes: 3 additions & 0 deletions npm/linux-musl-arm64/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# `sass-embedded-linux-musl-arm64`

This is the **linux-musl-arm64** binary for [`sass-embedded`](https://www.npmjs.com/package/sass-embedded)
20 changes: 20 additions & 0 deletions npm/linux-musl-arm64/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "sass-embedded-linux-musl-arm64",
"version": "1.69.5",
"description": "The linux-musl-arm64 binary for sass-embedded",
"repository": "sass/embedded-host-node",
"author": "Google Inc.",
"license": "MIT",
"files": [
"dart-sass/**/*"
],
"engines": {
"node": ">=14.0.0"
},
"os": [
"linux"
],
"cpu": [
"arm64"
]
}
3 changes: 3 additions & 0 deletions npm/linux-musl-ia32/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# `sass-embedded-linux-musl-ia32`

This is the **linux-musl-ia32** binary for [`sass-embedded`](https://www.npmjs.com/package/sass-embedded)
20 changes: 20 additions & 0 deletions npm/linux-musl-ia32/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "sass-embedded-linux-musl-ia32",
"version": "1.69.5",
"description": "The linux-musl-ia32 binary for sass-embedded",
"repository": "sass/embedded-host-node",
"author": "Google Inc.",
"license": "MIT",
"files": [
"dart-sass/**/*"
],
"engines": {
"node": ">=14.0.0"
},
"os": [
"linux"
],
"cpu": [
"ia32"
]
}
3 changes: 3 additions & 0 deletions npm/linux-musl-x64/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# `sass-embedded-linux-musl-x64`

This is the **linux-musl-x64** binary for [`sass-embedded`](https://www.npmjs.com/package/sass-embedded)
20 changes: 20 additions & 0 deletions npm/linux-musl-x64/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "sass-embedded-linux-musl-x64",
"version": "1.69.5",
"description": "The linux-musl-x64 binary for sass-embedded",
"repository": "sass/embedded-host-node",
"author": "Google Inc.",
"license": "MIT",
"files": [
"dart-sass/**/*"
],
"engines": {
"node": ">=14.0.0"
},
"os": [
"linux"
],
"cpu": [
"x64"
]
}
1 change: 1 addition & 0 deletions npm/win32-x64/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"win32"
],
"cpu": [
"arm64",
"x64"
]
}
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,20 @@
"test": "jest"
},
"optionalDependencies": {
"sass-embedded-android-arm": "1.69.5",
"sass-embedded-android-arm64": "1.69.5",
"sass-embedded-android-ia32": "1.69.5",
"sass-embedded-android-x64": "1.69.5",
"sass-embedded-darwin-arm64": "1.69.5",
"sass-embedded-darwin-x64": "1.69.5",
"sass-embedded-linux-arm": "1.69.5",
"sass-embedded-linux-arm64": "1.69.5",
"sass-embedded-linux-ia32": "1.69.5",
"sass-embedded-linux-x64": "1.69.5",
"sass-embedded-linux-musl-arm": "1.69.5",
"sass-embedded-linux-musl-arm64": "1.69.5",
"sass-embedded-linux-musl-ia32": "1.69.5",
"sass-embedded-linux-musl-x64": "1.69.5",
"sass-embedded-win32-ia32": "1.69.5",
"sass-embedded-win32-x64": "1.69.5"
},
Expand Down
Loading