forked from Aidan63/hxcpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRun.hx
More file actions
74 lines (62 loc) · 1.52 KB
/
Run.hx
File metadata and controls
74 lines (62 loc) · 1.52 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import haxe.io.Path;
import sys.FileSystem;
function log(s)
{
Sys.println(s);
}
function isNonInteractive()
{
final varName = "HXCPP_NONINTERACTIVE";
return switch Sys.getEnv(varName)
{
case null:
Lambda.exists(Sys.args(), arg -> arg.indexOf('-D$varName') == 0);
case _:
true;
}
}
function run(_dir, _command)
{
final oldDir = Sys.getCwd();
Sys.setCwd(_dir);
Sys.command(_command);
Sys.setCwd(oldDir);
}
function setup(_absOutDir)
{
log("Compiling hxcpp tool...");
run("tools/hxcpp", 'haxe -m BuildTool -D HXCPP_STACK_TRACE -D HXCPP_STACK_LINE -D analyzer-optimise --cpp $_absOutDir --dce full');
log("Initial setup complete.");
}
function compileHxcppTool(_absOutDir)
{
if (isNonInteractive())
{
setup(_absOutDir);
}
else
{
log('This version of hxcpp (${ Sys.getCwd() }) has not yet been built for this platform');
log("");
log("Would you like to do this now [y/n]");
switch Sys.getChar(true)
{
case 'y'.code, 'Y'.code:
log("");
setup(_absOutDir);
return;
case _:
Sys.exit(-1);
}
}
}
function main()
{
final absOutputDir = Path.join([ Sys.getCwd(), 'bin', Sys.systemName() ]);
final absOutputExe = Path.join([ absOutputDir, if (Sys.systemName() == 'Windows') 'BuildTool.exe' else 'BuildTool' ]);
if (!FileSystem.exists(absOutputExe))
{
compileHxcppTool(absOutputDir);
}
Sys.exit( Sys.command( absOutputExe, Sys.args() ) );
}