-
Notifications
You must be signed in to change notification settings - Fork 3
/
compile-x264.mjs
60 lines (54 loc) · 1.44 KB
/
compile-x264.mjs
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
import fs from "fs";
import { execSync } from "child_process";
import { PREFIX } from "./const.mjs";
import path from "path";
export const enableX264 = (isMusl, isWindows) => {
const extraCFlags = [
// TODO: should it always be static libgcc?
isMusl ? "-static-libgcc" : null,
].filter(Boolean);
if (!fs.existsSync("x264")) {
execSync("git clone https://code.videolan.org/videolan/x264.git x264", {
stdio: "inherit",
});
}
execSync("git checkout stable", {
cwd: "x264",
stdio: "inherit",
});
execSync("git pull", {
cwd: "x264",
stdio: "inherit",
});
execSync(
[
path.posix.join(process.cwd().replace(/\\/g, "/"), "x264", "configure"),
`--prefix=${path.join(PREFIX)}`,
"--enable-static",
"--disable-cli",
"--disable-opencl",
"--enable-pic",
isWindows
? "--host=x86_64-w64-mingw32 --cross-prefix=x86_64-w64-mingw32-"
: null,
'--extra-cflags="' + extraCFlags.join(" ") + '"',
isMusl ? '--extra-cxxflags="-static-libgcc -static-libstdc++"' : null,
isMusl ? '--extra-ldexeflags="-static-libgcc -static-libstdc++"' : null,
]
.filter(Boolean)
.join(" "),
{
cwd: "x264",
stdio: "inherit",
}
);
execSync("make", {
cwd: "x264",
stdio: "inherit",
});
execSync("make install", {
cwd: "x264",
stdio: "inherit",
});
execSync(`cp -r ${PREFIX} ../`, { cwd: "x264", stdio: "inherit" });
};