Author:ptrace
Comitter:ptrace
Date:2025-12-23 23:59:14 UTC
diff --git a/templates/lib/rules_lib.jai b/templates/lib/rules_lib.jai
index 32b3e8d..1923ae9 100644
--- a/templates/lib/rules_lib.jai
+++ b/templates/lib/rules_lib.jai
@@ -28,16 +28,13 @@ replaced with the template at compile time.
main_jai :: #string STR_END
#import "Basic"()(
MEMORY_DEBUGGER = MEMORY_DEBUGGER
MEMORY_DEBUGGER = MEMORY_DEBUGGER_ENABLED
);
#import "__RENAME_PLACEHOLDER__";
MEMORY_DEBUGGER :: false;
main :: () {
#if MEMORY_DEBUGGER defer report_memory_leaks();
#if MEMORY_DEBUGGER_ENABLED defer report_memory_leaks();
log("Hello from test.jai");
diff --git a/templates/lib/template.jai b/templates/lib/template.jai
index 8ca3137..7753969 100644
--- a/templates/lib/template.jai
+++ b/templates/lib/template.jai
@@ -12,6 +12,8 @@ build :: () {
args_compiler_silent := array_find(args, "silent");
args_program_run := array_find(args, "run");
args_build_release := array_find(args, "release");
args_memory_debug := array_find(args, "memory");
// program args
program_args := program_args_collect(args);
@@ -59,6 +61,8 @@ build :: () {
compiler_begin_intercept(w);
add_build_file(tprint("%test/test.jai", #filepath), w);
add_build_string(tprint("MEMORY_DEBUGGER_ENABLED :: %;", args_memory_debug), w);
compiler_response := message_loop();
compiler_end_intercept(w);
@@ -94,6 +98,7 @@ Options:
silent Disables compiler/linker statistics
run Runs your program afterwards
release Builds with release options. If omitted, it builds a debug build.
memory Enables the memory leak detector
Passing Args to your Program:
If you want to supply args to your program, pass it like that:
@@ -128,6 +133,9 @@ message_loop :: () -> success: bool {
return false;
}
#placeholder MEMORY_DEBUGGER_ENABLED;
main :: () {}
#run build();
diff --git a/templates/with_args/rules_with_args.jai b/templates/with_args/rules_with_args.jai
index 42a52a4..b527a56 100644
--- a/templates/with_args/rules_with_args.jai
+++ b/templates/with_args/rules_with_args.jai
@@ -6,10 +6,14 @@
STR_END;
main_jai :: #string STR_END
#import "Basic";
#import "Basic"()(
MEMORY_DEBUGGER = MEMORY_DEBUGGER_ENABLED
);
main :: () {
#if MEMORY_DEBUGGER_ENABLED defer report_memory_leaks();
log("Hello, Sailor!");
}
diff --git a/templates/with_args/template.jai b/templates/with_args/template.jai
index 76f04ad..e231fc4 100644
--- a/templates/with_args/template.jai
+++ b/templates/with_args/template.jai
@@ -12,6 +12,8 @@ build :: () {
args_compiler_silent := array_find(args, "silent");
args_program_run := array_find(args, "run");
args_build_release := array_find(args, "release");
args_memory_debug := array_find(args, "memory");
// program args
program_args := program_args_collect(args);
@@ -54,6 +56,8 @@ build :: () {
compiler_begin_intercept(w);
add_build_file(tprint("%src/main.jai", #filepath), w);
add_build_string(tprint("MEMORY_DEBUGGER_ENABLED :: %;", args_memory_debug), w);
compiler_response := message_loop();
compiler_end_intercept(w);
@@ -123,6 +127,9 @@ message_loop :: () -> success: bool {
return false;
}
#placeholder MEMORY_DEBUGGER_ENABLED;
main :: () {}
#run build();