diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-04-08 13:14:27 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-04-08 13:15:01 +0200 |
| commit | cf534d762754860ed5b714974f99acd282d48b3b (patch) | |
| tree | bf22341cedfb50ee7bcd4e15f85add2329783f31 | |
| parent | 630fcb1846aed16b9ab62bcf700f668883f4521f (diff) | |
Restructure into src/{std,json}/
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
| -rw-r--r-- | CMakeLists.txt | 6 | ||||
| -rw-r--r-- | base_test.c | 2 | ||||
| -rw-r--r-- | generate.fish | 2 | ||||
| -rw-r--r-- | main.c | 12 | ||||
| -rw-r--r-- | mise.toml | 4 | ||||
| -rw-r--r-- | src/json/json.c (renamed from src/json.c) | 8 | ||||
| -rw-r--r-- | src/json/json.h (renamed from include/json.h) | 6 | ||||
| -rw-r--r-- | src/json/test_json.c (renamed from tests/test_json.c) | 10 | ||||
| -rw-r--r-- | src/json/test_json/test_json_backspaces.json (renamed from tests/test_json/test_json_backspaces.json) | 0 | ||||
| -rw-r--r-- | src/json/test_json/test_json_complex_multiline.json (renamed from tests/test_json/test_json_complex_multiline.json) | 0 | ||||
| -rw-r--r-- | src/json/test_json/test_json_multiline.json (renamed from tests/test_json/test_json_multiline.json) | 0 | ||||
| -rw-r--r-- | src/std/assert.h (renamed from include/assert.h) | 0 | ||||
| -rw-r--r-- | src/std/log.c (renamed from src/log.c) | 4 | ||||
| -rw-r--r-- | src/std/log.h (renamed from include/log.h) | 0 | ||||
| -rw-r--r-- | src/std/memory.c (renamed from src/memory.c) | 6 | ||||
| -rw-r--r-- | src/std/memory.h (renamed from include/memory.h) | 0 | ||||
| -rw-r--r-- | src/std/str.c (renamed from src/str.c) | 4 | ||||
| -rw-r--r-- | src/std/str.h (renamed from include/str.h) | 4 | ||||
| -rw-r--r-- | src/std/test_string.c (renamed from tests/test_string.c) | 6 | ||||
| -rw-r--r-- | src/std/test_time.c (renamed from tests/test_time.c) | 6 | ||||
| -rw-r--r-- | src/std/test_vec.c (renamed from tests/test_vec.c) | 4 | ||||
| -rw-r--r-- | src/std/testing.c (renamed from src/testing.c) | 10 | ||||
| -rw-r--r-- | src/std/testing.h (renamed from include/testing.h) | 2 | ||||
| -rw-r--r-- | src/std/time.c (renamed from src/time.c) | 6 | ||||
| -rw-r--r-- | src/std/time.h (renamed from include/time.h) | 0 | ||||
| -rw-r--r-- | src/std/types.h (renamed from include/types.h) | 0 | ||||
| -rw-r--r-- | src/std/vec.c (renamed from src/vec.c) | 6 | ||||
| -rw-r--r-- | src/std/vec.h (renamed from include/vec.h) | 4 |
28 files changed, 56 insertions, 56 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 06cbb74..2b6c97a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,8 +2,8 @@ cmake_minimum_required(VERSION 3.30.5) project(kagamic VERSION 0.1 LANGUAGES C) set(CMAKE_C_STANDARD 23) -file(GLOB SOURCES "src/*.c") -file(GLOB TEST_SOURCES "test/*.c") +file(GLOB_RECURSE SOURCES "src/**/*.c") +list(FILTER SOURCES EXCLUDE REGEX ".*/test_.*\\.c$") add_compile_options(-Wall -pedantic -Wextra -mavx2 -mno-avx512f) @@ -11,6 +11,6 @@ add_executable(main main.c ${SOURCES}) target_link_libraries(main m) target_compile_options(main PRIVATE) -add_executable(test test.c ${SOURCES} ${TEST_SOURCES}) +add_executable(test test.c ${SOURCES}) target_link_libraries(test m) target_compile_options(test PRIVATE) diff --git a/base_test.c b/base_test.c index a06aab4..c4af530 100644 --- a/base_test.c +++ b/base_test.c @@ -1,4 +1,4 @@ -#include "include/types.h" +#include "src/std/types.h" #define test(func) \ switch (func()) { \ diff --git a/generate.fish b/generate.fish index fc84937..460cfff 100644 --- a/generate.fish +++ b/generate.fish @@ -1,5 +1,5 @@ echo "" > test.c; -set fs (ls tests/test_*.c); +set fs (ls src/**/test_*.c); for f in $fs; echo "#include \"$f\"" >> test.c; end; @@ -4,12 +4,12 @@ #include <sys/stat.h> #include <time.h> -#include "include/assert.h" -#include "include/json.h" -#include "include/memory.h" -#include "include/testing.h" -#include "include/types.h" -#include "include/vec.h" +#include "src/std/assert.h" +#include "src/json/json.h" +#include "src/std/memory.h" +#include "src/std/testing.h" +#include "src/std/types.h" +#include "src/std/vec.h" // Get high resolution time in nanoseconds double get_time_ns(void) { @@ -32,12 +32,12 @@ depends = ["debug"] run = "./Debug/test" [tasks.format] -run = "clang-format -i src/*.c include/*.h tests/*.c *.c" +run = "clang-format -i src/**/*.c src/**/*.h *.c" [tasks.check] depends = ["debug"] run = [ - "clang-format --dry-run src/*.c include/*.h tests/*.c *.c --fail-on-incomplete-format", + "clang-format --dry-run src/**/*.c src/**/*.h *.c --fail-on-incomplete-format", "ruff check", "ruff format --check", "mise run test" diff --git a/src/json.c b/src/json/json.c index 67bbf2e..d16415b 100644 --- a/src/json.c +++ b/src/json/json.c @@ -8,10 +8,10 @@ #include <stdlib.h> #include <string.h> -#include "../include/assert.h" -#include "../include/json.h" -#include "../include/str.h" -#include "../include/types.h" +#include "../std/assert.h" +#include "json.h" +#include "../std/str.h" +#include "../std/types.h" JSONObject *JSONObject_new(Arena *a) { JSONObject *object = new(a, JSONObject, 1); diff --git a/include/json.h b/src/json/json.h index 52566ab..15b3fca 100644 --- a/include/json.h +++ b/src/json/json.h @@ -1,7 +1,7 @@ #pragma once -#include "../include/memory.h" -#include "../include/str.h" -#include "../include/vec.h" +#include "../std/memory.h" +#include "../std/str.h" +#include "../std/vec.h" typedef struct { Vec keys; // Vec<Str> diff --git a/tests/test_json.c b/src/json/test_json.c index 921de64..058f191 100644 --- a/tests/test_json.c +++ b/src/json/test_json.c @@ -1,5 +1,5 @@ -#include "../include/json.h" -#include "../include/testing.h" +#include "json.h" +#include "../std/testing.h" #define JSON_parse_raw(a, s) JSON_parse(a, s, lengthof(s)); @@ -152,7 +152,7 @@ i32 test_json_long_spaces() { i32 test_json_multiline() { Arena perm = Arena_new(128e3); MemoryFile file = - load_file(&perm, "tests/test_json/test_json_multiline.json"); + load_file(&perm, "src/json/test_json/test_json_multiline.json"); JSON doc = JSON_parse(&perm, file.content, file.size); JSON target_size_mb = *JSONObject_get(doc.as.object, S("target_size_mb")); t_assert_equal(target_size_mb.as.integer, 1); @@ -188,7 +188,7 @@ i32 test_json_array_in_object() { i32 test_json_complex_multiline() { Arena perm = Arena_new(128e3); MemoryFile file = - load_file(&perm, "tests/test_json/test_json_complex_multiline.json"); + load_file(&perm, "src/json/test_json/test_json_complex_multiline.json"); JSON doc = JSON_parse(&perm, file.content, file.size); JSON id = *JSONObject_get(doc.as.object, S("id")); @@ -216,7 +216,7 @@ i32 test_negative_numbers() { i32 test_json_backspaces() { Arena perm = Arena_new(128e3); MemoryFile file = - load_file(&perm, "tests/test_json/test_json_backspaces.json"); + load_file(&perm, "src/json/test_json/test_json_backspaces.json"); JSON doc = JSON_parse(&perm, file.content, file.size); t_assert_strequal(doc.as.string, S("weird text\\")); diff --git a/tests/test_json/test_json_backspaces.json b/src/json/test_json/test_json_backspaces.json index ceb65d6..ceb65d6 100644 --- a/tests/test_json/test_json_backspaces.json +++ b/src/json/test_json/test_json_backspaces.json diff --git a/tests/test_json/test_json_complex_multiline.json b/src/json/test_json/test_json_complex_multiline.json index a0cfc9b..a0cfc9b 100644 --- a/tests/test_json/test_json_complex_multiline.json +++ b/src/json/test_json/test_json_complex_multiline.json diff --git a/tests/test_json/test_json_multiline.json b/src/json/test_json/test_json_multiline.json index 7cb5f4c..7cb5f4c 100644 --- a/tests/test_json/test_json_multiline.json +++ b/src/json/test_json/test_json_multiline.json diff --git a/include/assert.h b/src/std/assert.h index aa62bd1..aa62bd1 100644 --- a/include/assert.h +++ b/src/std/assert.h diff --git a/src/log.c b/src/std/log.c index c1d1717..980c7e7 100644 --- a/src/log.c +++ b/src/std/log.c @@ -1,7 +1,7 @@ #include <stdio.h> -#include "../include/log.h" -#include "../include/types.h" +#include "log.h" +#include "types.h" void info(Logger l, const byte *name, const byte *str, ...) { if (l.level >= INFO) { diff --git a/include/log.h b/src/std/log.h index 1458f03..1458f03 100644 --- a/include/log.h +++ b/src/std/log.h diff --git a/src/memory.c b/src/std/memory.c index 7072c61..3448819 100644 --- a/src/memory.c +++ b/src/std/memory.c @@ -2,9 +2,9 @@ #include <stdlib.h> #include <string.h> -#include "../include/assert.h" -#include "../include/memory.h" -#include "../include/types.h" +#include "assert.h" +#include "memory.h" +#include "types.h" Arena Arena_new(size cap) { Arena a = {0}; diff --git a/include/memory.h b/src/std/memory.h index d202e97..d202e97 100644 --- a/include/memory.h +++ b/src/std/memory.h diff --git a/src/str.c b/src/std/str.c index 3523d98..714cc59 100644 --- a/src/str.c +++ b/src/std/str.c @@ -2,8 +2,8 @@ #include <stdio.h> #include <string.h> -#include "../include/memory.h" -#include "../include/str.h" +#include "memory.h" +#include "str.h" u64 Str_hash64(Str s) { u64 h = 0x100; diff --git a/include/str.h b/src/std/str.h index 2d2eb93..526db63 100644 --- a/include/str.h +++ b/src/std/str.h @@ -3,8 +3,8 @@ #include <stdint.h> #include <stdio.h> -#include "../include/memory.h" -#include "../include/types.h" +#include "memory.h" +#include "types.h" typedef struct { byte *data; diff --git a/tests/test_string.c b/src/std/test_string.c index 297e294..d6bc716 100644 --- a/tests/test_string.c +++ b/src/std/test_string.c @@ -1,6 +1,6 @@ -#include "../include/string.h" -#include "../include/testing.h" -#include "../include/types.h" +#include "str.h" +#include "testing.h" +#include "types.h" #include <stdio.h> i32 test_string_literal_equality() { diff --git a/tests/test_time.c b/src/std/test_time.c index 3ab4d3e..f948fd0 100644 --- a/tests/test_time.c +++ b/src/std/test_time.c @@ -1,6 +1,6 @@ -#include "../include/testing.h" -#include "../include/time.h" -#include "../include/types.h" +#include "testing.h" +#include "time.h" +#include "types.h" i32 test_time_diff() { Time start = Time_get(); diff --git a/tests/test_vec.c b/src/std/test_vec.c index 502335b..e95a1b6 100644 --- a/tests/test_vec.c +++ b/src/std/test_vec.c @@ -1,5 +1,5 @@ -#include "../include/testing.h" -#include "../include/vec.h" +#include "testing.h" +#include "vec.h" typedef struct { i32 x; diff --git a/src/testing.c b/src/std/testing.c index 937d2dc..af2d1c8 100644 --- a/src/testing.c +++ b/src/std/testing.c @@ -1,10 +1,10 @@ #include <stdio.h> -#include "../include/assert.h" -#include "../include/memory.h" -#include "../include/str.h" -#include "../include/testing.h" -#include "../include/types.h" +#include "assert.h" +#include "memory.h" +#include "str.h" +#include "testing.h" +#include "types.h" MemoryFile load_file(Arena *a, const char *filename) { FILE *file = fopen(filename, "rb"); diff --git a/include/testing.h b/src/std/testing.h index 1ca460b..388c778 100644 --- a/include/testing.h +++ b/src/std/testing.h @@ -2,7 +2,7 @@ #include <stdio.h> #include <string.h> -#include "../include/memory.h" +#include "memory.h" typedef struct { size size; diff --git a/src/time.c b/src/std/time.c index cbabf96..331f1d5 100644 --- a/src/time.c +++ b/src/std/time.c @@ -1,8 +1,8 @@ #include <time.h> -#include "../include/assert.h" -#include "../include/time.h" -#include "../include/types.h" +#include "assert.h" +#include "time.h" +#include "types.h" Time Time_get() { struct timespec system_time; diff --git a/include/time.h b/src/std/time.h index 26bbf20..26bbf20 100644 --- a/include/time.h +++ b/src/std/time.h diff --git a/include/types.h b/src/std/types.h index 6df9510..6df9510 100644 --- a/include/types.h +++ b/src/std/types.h diff --git a/src/vec.c b/src/std/vec.c index 05ed70f..077e64a 100644 --- a/src/vec.c +++ b/src/std/vec.c @@ -1,8 +1,8 @@ #include <string.h> -#include "../include/assert.h" -#include "../include/types.h" -#include "../include/vec.h" +#include "assert.h" +#include "types.h" +#include "vec.h" Vec _Vec_new(Arena *a, size tsize, size cap, size align) { assert(cap > 0, "negative cap"); diff --git a/include/vec.h b/src/std/vec.h index 8ff0332..32734ae 100644 --- a/include/vec.h +++ b/src/std/vec.h @@ -2,8 +2,8 @@ #include <stddef.h> #include <stdint.h> -#include "../include/memory.h" -#include "../include/types.h" +#include "memory.h" +#include "types.h" typedef struct { void *data; |
