diff options
Diffstat (limited to 'source')
| -rw-r--r-- | source/base/base_os.h | 3 | ||||
| -rw-r--r-- | source/base/base_string.h | 12 | ||||
| -rwxr-xr-x | source/scb/scb.c | 5 | ||||
| -rw-r--r-- | source/scb/scb.h | 41 |
4 files changed, 40 insertions, 21 deletions
diff --git a/source/base/base_os.h b/source/base/base_os.h index 4f84d93..4357214 100644 --- a/source/base/base_os.h +++ b/source/base/base_os.h | |||
| @@ -23,7 +23,7 @@ load_file(mem_arena *arena, const char *path) | |||
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | 25 | ||
| 26 | result = PushString(arena, sbuf.st_size); | 26 | result = PushString8(arena, sbuf.st_size); |
| 27 | 27 | ||
| 28 | result.size = (u64)sbuf.st_size; | 28 | result.size = (u64)sbuf.st_size; |
| 29 | if(result.size != 0) | 29 | if(result.size != 0) |
| @@ -38,7 +38,6 @@ load_file(mem_arena *arena, const char *path) | |||
| 38 | internal string8 | 38 | internal string8 |
| 39 | write_file(const char *path, string8 data) | 39 | write_file(const char *path, string8 data) |
| 40 | { | 40 | { |
| 41 | |||
| 42 | string8 result = {0}; | 41 | string8 result = {0}; |
| 43 | s32 file = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644); | 42 | s32 file = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644); |
| 44 | if(file == -1) | 43 | if(file == -1) |
diff --git a/source/base/base_string.h b/source/base/base_string.h index c4b9f94..eb51e65 100644 --- a/source/base/base_string.h +++ b/source/base/base_string.h | |||
| @@ -1,9 +1,15 @@ | |||
| 1 | #ifndef BASE_STRING_H | 1 | #ifndef BASE_STRING_H |
| 2 | #define BASE_STRING_H | 2 | #define BASE_STRING_H |
| 3 | 3 | ||
| 4 | #define PushString(arena, count) (string8){ .data = (PushArrayZero(arena, u8, (count))), .size = (count) } | 4 | #define PushString8(arena, count) (string8){ .data = (PushArrayZero(arena, u8, (count))), .size = (count) } |
| 5 | #define StringCast(data, size) (string8){(u8 *)(data), (u64)(size) } | 5 | #define PushString16(arena, count) (string16){ .data = (PushArrayZero(arena, u16, (count))), .size = (count) } |
| 6 | #define StringPCast(data, size) (string8 *){(u8 *)(data), (u64)(size) } | 6 | #define PushString32(arena, count) (string32){ .data = (PushArrayZero(arena, u32, (count))), .size = (count) } |
| 7 | |||
| 8 | #define String8(data, size) (string8){(u8 *)(data), (u64)(size) } | ||
| 9 | #define String16(data, size) (string16){(u16 *)(data), (u64)(size) } | ||
| 10 | #define String32(data, size) (string32){(u32 *)(data), (u64)(size) } | ||
| 11 | |||
| 12 | |||
| 7 | 13 | ||
| 8 | #define StringFmt "%.*s" | 14 | #define StringFmt "%.*s" |
| 9 | #define ULongFmt "%lu" | 15 | #define ULongFmt "%lu" |
diff --git a/source/scb/scb.c b/source/scb/scb.c index d81f244..2a6cf43 100755 --- a/source/scb/scb.c +++ b/source/scb/scb.c | |||
| @@ -1,8 +1,11 @@ | |||
| 1 | #include "scb.h" | 1 | #include "scb.h" |
| 2 | 2 | ||
| 3 | s32 main(s32 argument_count, char **argument, char **env) | 3 | int main(s32 argument_count, char **argument, char **env) |
| 4 | { | 4 | { |
| 5 | mem_arena *global_arena = arena_create(MiB(10)); | ||
| 5 | assert_msg(argument_count < 2, "no arguments passed to scb"); | 6 | assert_msg(argument_count < 2, "no arguments passed to scb"); |
| 6 | init(argument_count, argument, env); | 7 | init(argument_count, argument, env); |
| 7 | 8 | ||
| 9 | arena_destroy(global_arena); | ||
| 10 | return 0; | ||
| 8 | } | 11 | } |
diff --git a/source/scb/scb.h b/source/scb/scb.h index 39f5e89..09c4852 100644 --- a/source/scb/scb.h +++ b/source/scb/scb.h | |||
| @@ -13,23 +13,30 @@ struct config { | |||
| 13 | string8 flags[]; | 13 | string8 flags[]; |
| 14 | }; | 14 | }; |
| 15 | 15 | ||
| 16 | 16 | typedef struct file_metad file_metad; | |
| 17 | internal void | 17 | struct file_metad |
| 18 | self_rebuild(const char *binary_path) | ||
| 19 | { | 18 | { |
| 19 | string8 name; | ||
| 20 | u32 time; | ||
| 21 | }; | ||
| 20 | 22 | ||
| 21 | struct stat scb_binary_stats; | 23 | internal b32 |
| 22 | assert_msg((lstat(binary_path), &sb == -1),"\nlstat failed to initialize\n"); | 24 | is_file_modified(const char *path) |
| 25 | { | ||
| 26 | struct stat scb_bstats; | ||
| 27 | s8 err = lstat(path, &scb_bstats); | ||
| 28 | assert_msg((err), "lstat failed."); | ||
| 23 | 29 | ||
| 24 | if(ctime(&sb.st_mtime)) | 30 | if(scb_bstats.st_mtime) |
| 25 | { | 31 | { |
| 26 | 32 | ||
| 27 | } | 33 | } |
| 34 | return 0; | ||
| 28 | } | 35 | } |
| 29 | 36 | ||
| 30 | //@documentatie: hebfjlberln | 37 | //@documentatie: hebfjlberln |
| 31 | internal void | 38 | internal void |
| 32 | init(int argument_count, char **argument, char **env) | 39 | init(int argument_count, char **argument, char **env) |
| 33 | { | 40 | { |
| 34 | mem_arena *global_arena = arena_create(KiB(2)); | 41 | mem_arena *global_arena = arena_create(KiB(2)); |
| 35 | assert_msg(argument_count > 2, "no program passed"); | 42 | assert_msg(argument_count > 2, "no program passed"); |
| @@ -41,20 +48,22 @@ init(int argument_count, char **argument, char **env) | |||
| 41 | 48 | ||
| 42 | //- load files into buffer | 49 | //- load files into buffer |
| 43 | { | 50 | { |
| 44 | 51 | if(is_file_modified) | |
| 45 | 52 | { | |
| 53 | self_rebuild(); | ||
| 54 | } | ||
| 46 | 55 | ||
| 47 | //- TODO(nasr): ... | 56 | //- TODO(nasr): ... |
| 48 | } | 57 | } |
| 49 | 58 | ||
| 50 | if(string8_cmp(command, StringCast("doc", 3))) | 59 | if(string8_cmp(command, StringCastUTF8("doc", 3))) |
| 51 | { | 60 | { |
| 52 | //- run meta program that builds tool documentation | 61 | //- run meta program that builds tool documentation |
| 53 | //- hmmm how do i store the documentation | 62 | //- hmmm how do i store the documentation |
| 54 | { | 63 | { |
| 55 | } | 64 | } |
| 56 | } | 65 | } |
| 57 | else if(string8_cmp(command, StringCast("build", 5))) | 66 | else if(string8_cmp(command, StringCast("build", 5))) |
| 58 | { | 67 | { |
| 59 | 68 | ||
| 60 | 69 | ||
| @@ -75,8 +84,10 @@ init(int argument_count, char **argument, char **env) | |||
| 75 | 84 | ||
| 76 | } | 85 | } |
| 77 | } | 86 | } |
| 78 | else if(string8_cmp(command, StringCast("meta", 5))) | 87 | else if(string8_cmp(command, StringCast("meta", 5))) |
| 79 | { | 88 | { |
| 80 | //- run the meta program | 89 | //- run the meta program |
| 81 | } | 90 | } |
| 91 | |||
| 92 | return; | ||
| 82 | } | 93 | } |
