-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcollect-mpv.js
64 lines (58 loc) · 1.73 KB
/
collect-mpv.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
const path = require("path");
const fs = require("fs");
const tar = require("tar");
const { execSync } = require("child_process");
const prebuildsDir = path.join(
path.dirname(require.resolve("mpv.js")),
"prebuilds"
);
const prebuilds = fs.readdirSync(prebuildsDir);
for (const filename of prebuilds) {
const basename = path.basename(filename, ".tar.gz");
const [platform, arch] = basename.split("-").slice(-2);
const os = platform.replace("win32", "win");
const file = path.join(prebuildsDir, filename);
const cwd = `mpv/${os}-${arch}`;
try {
fs.mkdirSync(cwd, { recursive: true });
} catch (e) {
if (e.code !== "EEXIST") {
throw e;
}
}
if (!fs.existsSync(`${cwd}/mpvjs.node`)) {
tar.x({ cwd, file, strip: 2, sync: true });
}
}
if (fs.existsSync("mpv/win-x64")) {
if (fs.existsSync("mpv/libmpv/x64/mpv-1.dll")) {
fs.copyFileSync("mpv/libmpv/x64/mpv-1.dll", "mpv/win-x64/mpv-1.dll");
}
if (fs.existsSync("mpv/libmpv/x64/libmpv-2.dll")) {
fs.copyFileSync("mpv/libmpv/x64/libmpv-2.dll", "mpv/win-x64/libmpv-2.dll");
}
}
if (fs.existsSync("mpv/win-ia32/")) {
if (fs.existsSync("mpv/libmpv/ia32/mpv-1.dll")) {
fs.copyFileSync("mpv/libmpv/ia32/mpv-1.dll", "mpv/win-ia32/mpv-1.dll");
}
if (fs.existsSync("mpv/libmpv/ia32/libmpv-2.dll")) {
fs.copyFileSync(
"mpv/libmpv/ia32/libmpv-2.dll",
"mpv/win-ia32/libmpv-2.dll"
);
}
}
if (process.platform === "win32") {
const src = path.join(__dirname, `mpv/libmpv/${process.arch}/mpv-1.dll`);
const dest = path.join(
__dirname,
"node_modules/mpv.js/build/Release/mpv-1.dll"
);
if (fs.existsSync(src)) {
fs.copyFileSync(src, dest);
}
}
if (process.platform === "darwin") {
execSync("./collect-dylib-deps.sh");
}