-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathkhafile.js
68 lines (51 loc) · 1.78 KB
/
khafile.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
65
66
67
68
const fs = require("fs");
const optickPathKey = "AURA_OPTICK_PATH";
// See https://github.com/Kode/Kha/wiki/Hashlink
const targetsHL = ["windows-hl", "linux-hl", "osx-hl", "android-hl", "ios-hl"];
const targetsCPP = ["windows", "linux", "osx"];
const targetsHTML5 = ["html5", "debug-html5"];
function addBackends(project) {
project.localLibraryPath = "Backends";
const isHL = targetsHL.indexOf(Project.platform) >= 0;
if (isHL) {
project.addLibrary("hl");
project.addDefine("AURA_BACKEND_HL");
console.log("[Aura] Using HL/C backend");
}
const isHTML5 = targetsHTML5.indexOf(Project.platform) >= 0;
if (isHTML5) {
// project.addSources("backends/html5");
}
project.localLibraryPath = "Libraries";
}
async function main() {
const project = new Project('aura');
project.addSources('Sources');
if (process.argv.indexOf("--aura-no-backend") == -1) {
addBackends(project);
}
else {
project.addDefine("AURA_NO_BACKEND");
}
const isCPP = targetsCPP.indexOf(Project.platform) >= 0;
if (isCPP && process.argv.indexOf("--aura-no-simd") == -1) {
project.addDefine("AURA_SIMD");
}
const withOptick = optickPathKey in process.env && isCPP;
if (withOptick) {
const optickPath = process.env[optickPathKey];
if (fs.existsSync(optickPath)) {
project.addDefine("AURA_WITH_OPTICK");
await project.addProject(optickPath);
// Unfortunately there is no metadata to include a specified header
// in the cpp file that calls a certain _inlined_ Haxe function, so
// instead we need to add it everywhere for now (bad workaround)...
project.addParameter("--macro addGlobalMetadata('aura', '@:headerCode(\"#include <optick.h>\")')");
}
else {
console.warn(`Aura: Path ${optickPath} does not exist, building without Optick support.`);
}
}
resolve(project);
}
await main();