-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMake.hx
103 lines (100 loc) · 3.17 KB
/
Make.hx
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
function main() {
final args = Sys.args();
trace("run command: " + args[0]);
switch args[0] {
case "testsetup":
if (sys.FileSystem.exists("golibstest"))
Sys.command("rm -r -d golibstest");
Sys.exit(Sys.command("haxelib run go2hx --rebuild https://github.com/charmbracelet/harmonica --test --out golibstest --norun -compiler_nodejs --hxml test.hxml"));
case "test":
final excludes = "";
//Sys.setCwd("harmonica");
final target = args[1];
trace("target", target);
final out = 'test.$target';
var buildCmd = buildTarget(target, out, "_internal.github_dot_com.charmbracelet.harmonica_dot_test.Harmonica_dot_test");
buildCmd = "haxe test.hxml " + buildCmd;
if (target == "interp")
buildCmd += " " + excludes;
Sys.println(buildCmd);
final code = Sys.command(buildCmd);
if (code != 0)
Sys.exit(code);
final runCmd = runTarget(target, out, [], "") + " " + excludes;
if (target != "interp") {
Sys.exit(Sys.command(runCmd));
}
case "buildexample":
final target = args[1];
final out = 'test.$target';
var code = Sys.command("haxe example.hxml --no-output " + buildTarget(target,out, "Example"));
if (code != 0)
Sys.exit(code);
case "example": // TODO proper testing
final target = args[1];
final out = 'test.$target';
var code = Sys.command("haxe example.hxml " + buildTarget(target,out, "Example"));
if (code != 0)
Sys.exit(code);
final runCmd = runTarget(target, out, [], "");
if (runCmd != "") {
Sys.exit(Sys.command(runCmd));
}else{
Sys.println(runCmd);
}
case "actions", "action":
Sys.exit(Sys.command("haxe scripts/github-actions/build.hxml"));
case "build":
Sys.command("rm -r -d golibs");
// -nodeps
Sys.command("haxelib run go2hx extraParams");
Sys.exit(Sys.command("haxelib run go2hx --rebuild --nodeps https://github.com/charmbracelet/harmonica -compiler_nodejs"));
case "version":
// TODO set version
case "dev":
Sys.exit(Sys.command("haxelib dev go2hx_harmonica ."));
}
}
function buildTarget(target:String, out:String, main:String):String {
return switch target {
case "hl":
'--hl $out';
case "js":
'--$target $out -lib hxnodejs';
case "jvm", "cpp", "cs", "lua", "python", "php", "neko":
'--$target $out';
case "interp":
'--run $main';
default:
throw "unknown target: " + target;
}
}
function runTarget(target:String, out:String, args:Array<String>, main:String):String {
final index = main.lastIndexOf(".");
if (index != -1)
main = main.substr(index + 1);
var s = switch target {
case "interp":
"";
case "cpp", "cs":
"./" + out + "/" + main;
case "jvm":
'java -jar $out';
case "python":
if (Sys.systemName() == "Mac") {
'python3 $out';
} else {
'python $out';
}
case "hl", "neko", "lua", "php":
'$target $out';
case "js":
// --stack-size set because bytes.growSize Maximum call stack size exceeded
'node --stack-size=65500 $out';
default:
throw "unknown target: " + target;
};
if (args.length > 0)
s += " " + args.join(" ");
return s;
}