-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.jyu
57 lines (45 loc) · 1.81 KB
/
build.jyu
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
#import "Compiler";
#import "Basic";
#import "LibC";
func compile_single_test_file(path: string, as_metaprogram: bool) {
var options: Build_Options;
options.executable_name = strip_path_extension(path);
var compiler = create_compiler_instance(*options);
if compiler_load_file(compiler, path) != true return;
if compiler_typecheck_program(compiler) != true return;
if compiler_generate_llvm_module(compiler) != true return;
if as_metaprogram {
if compiler_run_metaprogram(compiler, 0, null) != true return;
} else {
if compiler_emit_object_file(compiler) != true return;
if compiler_run_default_link_command(compiler) != true return;
}
}
func concatenate(n: string, m: string) -> string {
var builder: String_Builder;
builder.init();
builder.append(n);
builder.append(m);
var result = builder.to_string();
builder.reset();
return result;
}
func @metaprogram main(argc: int32, argv: **uint8) {
var did_cmd_line = false;
for 0..<argc {
var path = concatenate(to_string(argv[it]), "/solution.jyu");
compile_single_test_file(path, true);
did_cmd_line = true;
}
if did_cmd_line return;
var as_metaprogram = true;
compile_single_test_file("day1/solution.jyu", as_metaprogram);
compile_single_test_file("day2/solution.jyu", as_metaprogram);
// Just compile day3, running it can take a long while.
compile_single_test_file("day3/solution.jyu", false);
compile_single_test_file("day4/solution.jyu", as_metaprogram);
// Just compile day5 because it does a scanf, which halts until the user inputs a number.
compile_single_test_file("day5/solution.jyu", false);
compile_single_test_file("day6/solution.jyu", as_metaprogram);
compile_single_test_file("day7/solution.jyu", as_metaprogram);
}