-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.w32
More file actions
44 lines (36 loc) · 1.65 KB
/
Copy pathconfig.w32
File metadata and controls
44 lines (36 loc) · 1.65 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
// vim:ft=javascript
var cargo = execute("cmd /c cargo --version 2>NUL");
if (!cargo) {
ERROR("cargo is required to build ext-highlighter");
}
var highlighterDir = configure_module_dirname;
var highlighterVersion = WshShell.Environment("Process").Item("HIGHLIGHTER_VERSION");
var cargoArgs = "build --release";
var cargoTarget = WshShell.Environment("Process").Item("CARGO_BUILD_TARGET");
var highlighterTargetDir = highlighterDir + "\\target\\release";
if (!highlighterVersion) {
highlighterVersion = execute("cmd /c cd /d \"" + highlighterDir + "\" && git describe --tags --dirty --always 2>NUL");
}
if (!highlighterVersion) {
highlighterVersion = highlighterDir.replace(/^.*-([0-9a-fA-F]{7,40})$/, "$1");
if (highlighterVersion == highlighterDir) {
highlighterVersion = "";
}
}
if (!highlighterVersion) {
highlighterVersion = "unknown";
}
highlighterVersion = highlighterVersion.replace(/^\s+|\s+$/g, "").replace(/[^A-Za-z0-9._+:-]/g, "_");
if (cargoTarget) {
cargoArgs += " --target " + cargoTarget;
highlighterTargetDir = highlighterDir + "\\target\\" + cargoTarget + "\\release";
}
STDOUT.WriteLine("building Rust highlighter static library");
if (WshShell.Run("cmd /c cd /d \"" + highlighterDir + "\" && cargo " + cargoArgs, 1, true) != 0) {
ERROR("failed to build Rust highlighter static library");
}
ADD_FLAG("CFLAGS_HIGHLIGHTER", "/I\"" + highlighterDir + "\"");
ADD_FLAG("CFLAGS_HIGHLIGHTER", "/DPHP_HIGHLIGHTER_VERSION=\\\"" + highlighterVersion + "\\\"");
ADD_FLAG("LDFLAGS_HIGHLIGHTER", "/libpath:\"" + highlighterTargetDir + "\"");
ADD_FLAG("LIBS_HIGHLIGHTER", "highlighter.lib userenv.lib ntdll.lib");
EXTENSION("highlighter", "highlighter.c", true);