-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_emsdk.js
More file actions
executable file
·52 lines (45 loc) · 1.96 KB
/
update_emsdk.js
File metadata and controls
executable file
·52 lines (45 loc) · 1.96 KB
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
const fs = require('fs');
const path = require('path');
const EMSDK_COMMIT = "c69d433d8509c5c64564c2f0d054bf102a5cf67e";
const EMSDK_VERSION = "latest";
const ROOT_PATH = process.cwd();
const EMSDK_COMMIT_LINE = `"third_party/externals/emsdk" : "https://github.com/emscripten-core/emsdk.git@${EMSDK_COMMIT}",`;
const EMSDK_VERSION_LINE = `EMSDK_VERSION = '${EMSDK_VERSION}'`;
const DEPS_PATH = path.join(ROOT_PATH, 'DEPS');
const ACTIVATE_EMSDK_PATH = path.join(ROOT_PATH, 'bin', 'activate-emsdk');
function updateFile(filePath, regex, newLine) {
try {
let content = fs.readFileSync(filePath, 'utf8');
if (regex.test(content)) {
content = content.replace(regex, newLine);
} else {
content += `\n${newLine}\n`;
}
fs.writeFileSync(filePath, content, 'utf8');
} catch (err) {
console.error(`Error updating file ${filePath}:`, err);
}
}
updateFile(DEPS_PATH, /"third_party\/externals\/emsdk".*/, EMSDK_COMMIT_LINE);
updateFile(ACTIVATE_EMSDK_PATH, /^EMSDK_VERSION =.*/m, EMSDK_VERSION_LINE);
/**
* When compiling the wasm version on the Windows platform, the following modifications are
* required. For details, refer to https://issues.skia.org/issues/40045374.
*/
if (process.platform === 'win32') {
const BUILD_GN_PATH = path.join(ROOT_PATH, 'third_party', 'freetype2', 'BUILD.gn');
try {
let content = fs.readFileSync(BUILD_GN_PATH, 'utf8');
content = content.replace(
/<freetype-no-type1\/freetype\/config\/ftmodule.h>/g,
'\\"freetype-no-type1/freetype/config/ftmodule.h\\"'
).replace(
/<freetype-no-type1\/freetype\/config\/ftoption.h>/g,
'\\"freetype-no-type1/freetype/config/ftoption.h\\"'
);
fs.writeFileSync(BUILD_GN_PATH, content, 'utf8');
console.log('BUILD.gn file updated successfully!');
} catch (err) {
console.error(`Error updating BUILD.gn file: ${err.message}`);
}
}