-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmetaprogram.jai
56 lines (36 loc) · 1.3 KB
/
metaprogram.jai
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
/*
You can use this metaprogram like this:
jai metaprogram.jai
But also like this:
jai -- import_dir . meta metaprogram
With the first option you can see how this metaprogram is itself being built by the Default_Metaprogram, because the value of this workspace is 2.
Only with the second option are we truly ONLY running this metaprogram.
*/
#run {
set_build_options_dc(.{
do_output = false,
write_added_strings = false, // this stops generation of added_strings_w*.jai for this workspace.
});
set_print_style_verbose();
this_workspace := get_current_workspace();
name_of_this_workspace := get_name(this_workspace);
options := get_build_options();
printex( this_workspace );
printex(type_of(this_workspace));
printex(name_of_this_workspace );
w := compiler_create_workspace("Target Program");
target_options := get_build_options(w);
target_options.output_executable_name = "target";
set_build_options(target_options, w);
compiler_begin_intercept(w);
add_build_file(tprint("%/scratch.jai", #filepath), w); // @Cleanup: Fix this to not require #filepath.
while 1 {
msg := compiler_wait_for_message();
if msg.kind == .COMPLETE break;
}
compiler_end_intercept(w);
print("\nend of build program\n");
return;
}
#import "Compiler";
#load "sandbox.jai";