build(embedded-mpv): streamline macOS native output handling and packaging process

Entire-Checkpoint: c6e522b4276c
This commit is contained in:
4gray committed 2026-04-27 11:33:57 +02:00
1 parent 6aa4f2521b
commit b25fc040b5
5 files changed
+34 -42

No files matched your search

+1 -33
View File
@@ -132,22 +132,6 @@
"frontendProject": "web",
"sourcePath": "dist/apps",
"outputPath": "dist/packages",
"files": [
{
"from": "electron-backend/native",
"to": "electron-backend/native",
"filter": ["**/*"]
}
],
"asarUnpack": [
"**/better-sqlite3/**",
"**/bindings/**",
"**/file-uri-to-path/**",
"electron-backend/native/**",
"**/electron-backend/native/**",
"**/*.node",
"**/*.dylib"
],
"prepackageOnly": true
}
},
@@ -158,23 +142,7 @@
"name": "electron-backend",
"frontendProject": "web",
"sourcePath": "dist/apps",
"outputPath": "dist/executables",
"files": [
{
"from": "electron-backend/native",
"to": "electron-backend/native",
"filter": ["**/*"]
}
],
"asarUnpack": [
"**/better-sqlite3/**",
"**/bindings/**",
"**/file-uri-to-path/**",
"electron-backend/native/**",
"**/electron-backend/native/**",
"**/*.node",
"**/*.dylib"
]
"outputPath": "dist/executables"
}
},
"lint": {
+2 -1
View File
@@ -76,7 +76,8 @@ Current development behavior:
- The staged runtime must contain `include/mpv/client.h`, `lib/*.dylib`, and `runtime-manifest.json`.
- The compiled `.node` addon is copied into `dist/apps/electron-backend/native/embedded_mpv.node`.
- Bundled runtime files are copied into `dist/apps/electron-backend/native/lib/`. Most are `.dylib` files, but some Homebrew-linked runtimes expose non-`.dylib` Mach-O files such as a framework `Python` binary.
- `electron-builder` includes `dist/apps/electron-backend/native/` in the app package and unpacks `electron-backend/native/**` from ASAR so the addon, manifest, dylibs, and non-`.dylib` Mach-O runtime files are filesystem-addressable.
- macOS `afterPack` copies `dist/apps/electron-backend/native/` into `app.asar.unpacked/electron-backend/native/` so the addon, manifest, dylibs, and non-`.dylib` Mach-O runtime files are filesystem-addressable.
- Linux and Windows packaging do not include the Embedded MPV native directory.
Current release caveat:
-7
View File
@@ -12,11 +12,6 @@
"to": "remote-control-web",
"filter": ["**/*"]
},
{
"from": "dist/apps/electron-backend/native",
"to": "electron-backend/native",
"filter": ["**/*"]
},
"electron-backend/**/*",
"web/**/*",
"!**/*.map"
@@ -25,8 +20,6 @@
"**/better-sqlite3/**",
"**/bindings/**",
"**/file-uri-to-path/**",
"electron-backend/native/**",
"**/electron-backend/native/**",
"**/*.node",
"**/*.dylib"
],
+1 -1
View File
@@ -70,7 +70,7 @@ The build manifest records source URLs, downloaded archive SHA-256 values where
`apps/electron-backend/build-embedded-mpv.js` links the native addon against the staged runtime, copies dylibs into `apps/electron-backend/native/build/Release/lib/`, rewrites Mach-O paths to `@loader_path`, and writes `embedded-mpv-runtime.json`.
The Electron builder and Nx package/make targets package `dist/apps/electron-backend/native/` into `electron-backend/native/` and unpack that whole native directory from ASAR so the addon, runtime manifest, dylibs, and non-`.dylib` Mach-O runtime files are available as real files.
The macOS `afterPack` hook copies `dist/apps/electron-backend/native/` into `app.asar.unpacked/electron-backend/native/` so the addon, runtime manifest, dylibs, and non-`.dylib` Mach-O runtime files are available as real files. Linux and Windows artifacts do not include that native directory.
During release packaging, `tools/packaging/electron-after-pack.cjs` verifies that the packaged app uses a `vendored-lgpl` runtime and has no `/opt/homebrew` or `/usr/local` dynamic links for embedded MPV.
+30
View File
@@ -17,6 +17,30 @@ function isTruthy(value) {
);
}
function copyEmbeddedMpvNativeOutput(resourceDir, projectDir) {
const sourceDir = path.join(
projectDir,
'dist',
'apps',
'electron-backend',
'native'
);
if (!fs.existsSync(sourceDir)) {
return;
}
const destinationDir = path.join(
resourceDir,
'app.asar.unpacked',
'electron-backend',
'native'
);
fs.rmSync(destinationDir, { recursive: true, force: true });
fs.cpSync(sourceDir, destinationDir, { recursive: true });
}
async function afterPackHook(params) {
await linuxAfterPack(params);
@@ -46,6 +70,12 @@ async function afterPackHook(params) {
'Resources'
)
: params.appOutDir;
copyEmbeddedMpvNativeOutput(
resourceDir,
params.packager.projectDir ?? process.cwd()
);
const errors = validatePackagedEmbeddedMpv(resourceDir, {
required: requireEmbeddedMpv,
});