From a03172f667b048175ee19808363ff3d634124067 Mon Sep 17 00:00:00 2001 From: Judah Caruso Date: Wed, 21 May 2025 15:38:57 -0600 Subject: [PATCH] remove relative imports because that causes way more issues --- README | 10 +++++++++- _run_all_tests.jai | 7 +++++-- array/module.jai | 2 +- array/static_array.jai | 13 +++++++++---- encoding/base64.jai | 8 ++++++-- encoding/json.jai | 5 +++-- encoding/module.jai | 2 +- math/module.jai | 5 +++-- math/vec.jai | 5 +++-- memory/module.jai | 13 +++++++------ meta/module.jai | 9 +++++++-- reload/examples/everything-you-need.jai | 4 +--- reload/examples/quickstart.jai | 3 +-- reload/module.jai | 13 ++++++++----- reload/reload_main.jai | 12 +++++------- 15 files changed, 69 insertions(+), 42 deletions(-) diff --git a/README b/README index a950a64..0151a50 100644 --- a/README +++ b/README @@ -2,10 +2,18 @@ jc.jai ------ - cd [jai install directory]/modules + # Direct installation + cd [jai install dir]/modules git clone https://git.brut.systems/judah/jc.jai.git jc + # Indirect installation + git clone https://git.brut.systems/judah/jc.jai.git + + ln -s "/path/to/jc.jai" [jai install dir]/modules/jc # POSIX install + mklink /D "C:\path\to\jc.jai" [jai install dir]\jc # Windows install + #import "jc"; + #import "jc/[module]"; What ---- diff --git a/_run_all_tests.jai b/_run_all_tests.jai index 5385af0..10dbeb4 100644 --- a/_run_all_tests.jai +++ b/_run_all_tests.jai @@ -2,6 +2,9 @@ compiler :: #import "Compiler"; compiler.set_build_options_dc(.{ do_output = false }); + // @note(judah): we use relative imports here because that'll + // print cleaner file locations. + #import,file "./array/module.jai"(true); #import,file "./encoding/module.jai"(true); #import,file "./hash/module.jai"(true); @@ -9,8 +12,8 @@ #import,file "./meta/module.jai"(true); rmath :: #import,file "./math/module.jai"(.radians, true); - // dmath :: #import,file "./math/module.jai"(.degrees, true); - // tmath :: #import,file "./math/module.jai"(.turns, true); + dmath :: #import,file "./math/module.jai"(.degrees, true); + tmath :: #import,file "./math/module.jai"(.turns, true); } diff --git a/array/module.jai b/array/module.jai index acaa857..5887016 100644 --- a/array/module.jai +++ b/array/module.jai @@ -5,5 +5,5 @@ #scope_module; #if RUN_TESTS { - test :: #import,file "../test/module.jai"; + test :: #import "jc/test"; } diff --git a/array/static_array.jai b/array/static_array.jai index 37f45b0..875092b 100644 --- a/array/static_array.jai +++ b/array/static_array.jai @@ -77,15 +77,20 @@ make_dynamic :: (a: *Static_Array) -> [..]a.T { #scope_file; -mem :: #import,file "../memory/module.jai"; -basic :: #import "Basic"; // @future - ensure_array_has_room :: (array: *Static_Array, count: int, loc := #caller_location) #expand { basic.assert(array.count + count <= array.capacity, "attempt to add too many elements! want: %, Max: %", array.count + count, array.capacity, loc = loc); } +mem :: #import "jc/memory"; +basic :: #import "Basic"; // @future + + +// ---------------------------------------------------------- +// TESTS +// ---------------------------------------------------------- + #if RUN_TESTS #run { - test :: #import,file "../test/module.jai"; + test :: #import "jc/test"; test.run("basic operations", (t) => { a: Static_Array(10, int); diff --git a/encoding/base64.jai b/encoding/base64.jai index e5e25d4..4d9b2e4 100644 --- a/encoding/base64.jai +++ b/encoding/base64.jai @@ -156,10 +156,14 @@ encoded_length :: (count: int, with_padding := false) -> int { #scope_file; -basic :: #import "Basic"; -strings :: #import "String"; +basic :: #import "Basic"; // @future +strings :: #import "String"; // @future +// ---------------------------------------------------------- +// TESTS +// ---------------------------------------------------------- + #if RUN_TESTS #run { test.run("encodes", (t) => { str :: "Hello, World"; diff --git a/encoding/json.jai b/encoding/json.jai index c10b28c..1870649 100644 --- a/encoding/json.jai +++ b/encoding/json.jai @@ -603,7 +603,8 @@ at_end :: inline (p: *Parser) -> bool { return p.offset >= p.data.count.(u64); } -basic :: #import "Basic"; -strings :: #import "String"; + +basic :: #import "Basic"; // @future +strings :: #import "String"; // @future diff --git a/encoding/module.jai b/encoding/module.jai index cf22d9f..d8c7ed6 100644 --- a/encoding/module.jai +++ b/encoding/module.jai @@ -7,5 +7,5 @@ #scope_module; #if RUN_TESTS { - test :: #import,file "../test/module.jai"; + test :: #import "jc/test"; } diff --git a/math/module.jai b/math/module.jai index 00d0bbf..799f6b5 100644 --- a/math/module.jai +++ b/math/module.jai @@ -6,6 +6,7 @@ #load "vec.jai"; #load "mat.jai"; + #scope_module; bounds_check_index :: ($$idx: int, $count: int, loc := #caller_location) #expand { @@ -18,8 +19,8 @@ bounds_check_index :: ($$idx: int, $count: int, loc := #caller_location) #expand } -basic :: #import "Basic"; +basic :: #import "Basic"; // @future #if RUN_TESTS { - test :: #import,file "../test/module.jai"; + test :: #import "jc/test"; } diff --git a/math/vec.jai b/math/vec.jai index 16ee897..7430b34 100644 --- a/math/vec.jai +++ b/math/vec.jai @@ -349,7 +349,8 @@ quat :: (x: float = 0, y: float = 0, z: float = 0, w: float = 0) -> Quat #expand return .{ x = x, y = y, z = z, w = w }; } -#scope_file -meta :: #import,file "../meta/module.jai"; +#scope_file; + +meta :: #import "jc/meta"; math :: #import "Math"; // @future diff --git a/memory/module.jai b/memory/module.jai index a5a059f..4380111 100644 --- a/memory/module.jai +++ b/memory/module.jai @@ -164,19 +164,20 @@ arena_alloc :: (a: *Arena, count: int, alignment := Default_Align, loc := #calle } - #scope_file; -// @note(judah): this will cause a cyclic import cycle if we import meta's module.jai -// @todo(judah): switch to abslote imports everywhere (ie. "jc/meta") -meta :: #import,file "../meta/type_info.jai"; - +meta :: #import "jc/meta"; basic :: #import "Basic"; // @future compiler :: #import "Compiler"; // @future + +// ---------------------------------------------------------- +// TESTS +// ---------------------------------------------------------- + #if RUN_TESTS #run { - test :: #import,file "../test/module.jai"; + test :: #import "jc/test"; test.run("make:dynamic arrays", (t) => { a1 := make([..]int); diff --git a/meta/module.jai b/meta/module.jai index e97a214..94230bb 100644 --- a/meta/module.jai +++ b/meta/module.jai @@ -36,10 +36,15 @@ snake_to_pascal :: (name: string) -> string { #scope_module; -mem :: #import,file "../memory/module.jai"; +mem :: #import "jc/memory"; + + +// ---------------------------------------------------------- +// TESTS +// ---------------------------------------------------------- #if RUN_TESTS { - test :: #import,file "../test/module.jai"; + test :: #import "jc/test"; #run test.run("snake_to_pascal", t => { test.expect(t, snake_to_pascal("some_name") == "SomeName"); diff --git a/reload/examples/everything-you-need.jai b/reload/examples/everything-you-need.jai index e836841..0de5065 100644 --- a/reload/examples/everything-you-need.jai +++ b/reload/examples/everything-you-need.jai @@ -81,8 +81,6 @@ G: *struct { print("in: teardown\n"); } -#import "jx"; - #poke_name reload frame; #poke_name reload init; #poke_name reload setup; @@ -92,6 +90,6 @@ G: *struct { // Use the default build options build_options :: () => reload.Simple_Build_Options.{}; -reload :: #import "jx/reload"; +reload :: #import "jc/reload"; #import "Basic"; diff --git a/reload/examples/quickstart.jai b/reload/examples/quickstart.jai index 2f59685..2d07938 100644 --- a/reload/examples/quickstart.jai +++ b/reload/examples/quickstart.jai @@ -24,7 +24,6 @@ G: *struct { } -#import "jx"; #import "Basic"; DISABLE_HOT_RELOADING :: false; @@ -50,7 +49,7 @@ DISABLE_HOT_RELOADING :: false; } } else { - reload :: #import "jx/reload"; + reload :: #import "jc/reload"; #poke_name reload frame; #poke_name reload init; #poke_name reload setup; diff --git a/reload/module.jai b/reload/module.jai index 390b332..777a55a 100644 --- a/reload/module.jai +++ b/reload/module.jai @@ -154,8 +154,11 @@ user_options :: #run -> Simple_Build_Options { file_delete(temp_path); } -#import "Basic"; -#import "File"; -#import "File_Utilities"; -#import "String"; -#import "Compiler"; + +#scope_file; + +#import "Basic"; // @future +#import "File"; // @future +#import "File_Utilities"; // @future +#import "String"; // @future +#import "Compiler"; // @future diff --git a/reload/reload_main.jai b/reload/reload_main.jai index 7925dcf..f184ad4 100644 --- a/reload/reload_main.jai +++ b/reload/reload_main.jai @@ -230,10 +230,8 @@ else { #assert(false, "only windows, mac, and linux are supported for now"); } -#import "jx"; - -basic :: #import "Basic"; -system :: #import "System"; -file :: #import "File"; -futils :: #import "File_Utilities"; -strings :: #import "String"; +basic :: #import "Basic"; // @future +system :: #import "System"; // @future +file :: #import "File"; // @future +futils :: #import "File_Utilities"; // @future +strings :: #import "String"; // @future