-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBuild.java
61 lines (44 loc) · 1.59 KB
/
Build.java
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
package NogBuild;
import java.util.ArrayList;
class Build {
public static void main(String[] args) throws Exception {
bootstrapBuild(args);
Nog.setPackage("Main");
Module main = Nog.addModule("Main");
main.addFile("src", "Hello.java");
main.addFile("src", "Program.java");
main.build();
if (args.length > 0 && args[0].equals("run")) {
main.run("Program");
}
}
public static void bootstrapBuild(String[] args) throws Exception {
Module build = Nog.addModule("NogBuild");
build.addFile("Nog.java");
build.addFile("Build.java");
ArrayList<String> modifiedFiles = build.getModifiedUnits();
if (modifiedFiles.size() == 0) return;
System.out.println("Build files changed:");
for (String f: modifiedFiles) {
System.out.println("- " + f);
}
// This is a failsafe to prevent the build system from becoming
// a fork bomb when modified files arent detected properly
if (args.length > 0 && args[0].equals("bootstrapped")) {
System.out.println(
Nog.ANSI_RED
+ "Recursion limit reached. Aborting bootstrap..."
+ Nog.ANSI_RESET);
System.exit(1);
}
build.build();
build.makeJar("Build.jar", "Build");
Nog.runJar(
Nog.cachedPath("Build.jar"),
new String[] { "bootstrapped" });
Nog.copyFile(
Nog.cachedPath("Build.jar"),
Nog.projectPath("Build.jar"));
System.exit(0);
}
}