Fix cache saving on error in build system

This commit is contained in:
Krzosa Karol
2024-02-16 07:39:33 +01:00
parent c3c5922017
commit 2abd8870cb
3 changed files with 4 additions and 10 deletions

View File

@@ -19,11 +19,6 @@ SRC_Cache *SRC_FromFileCache;
S8_String SRC_CacheFilename;
CL_SearchPaths SRC_SearchPaths = {}; // @todo;
#define SRC_CacheScope(cache_filename) \
SRC_InitCache(Perm, cache_filename); \
defer { SRC_SaveCache(); };
void SRC_InitCache(MA_Arena *arena, S8_String cachefilename) {
SRC_CacheFilename = cachefilename;

View File

@@ -78,7 +78,7 @@ S8_String Fmt(const char *str, ...) {
}
Array<S8_String> ListDir(char *dir) {
Array<S8_String> result = {};
Array<S8_String> result = {Perm};
for (OS_FileIter it = OS_IterateFiles(Perm, S8_MakeFromChar(dir)); OS_IsValid(it); OS_Advance(&it)) {
result.add(S8_Copy(Perm, it.absolute_path));
}
@@ -87,12 +87,9 @@ Array<S8_String> ListDir(char *dir) {
Array<S8_String> CMD_Make(char **argv, int argc) {
Array<S8_String> result = {Perm};
if (argc > 1) IO_Printf("Command line arguments:\n");
for (int i = 1; i < argc; i += 1) {
S8_String it = S8_MakeFromChar(argv[i]);
result.add(it);
IO_Printf("[%d] %.*s\n", i, S8_Expand(it));
}
return result;
}

View File

@@ -36,7 +36,7 @@ int main(int argument_count, char **arguments) {
}
}
SRC_CacheScope("build_tool.cache");
SRC_InitCache(Perm, "build_tool.cache");
S8_String name_no_ext = S8_GetNameNoExt(build_file);
S8_String exe_name = S8_Format(Perm, "%.*s.exe", S8_Expand(name_no_ext));
@@ -93,6 +93,8 @@ int main(int argument_count, char **arguments) {
return 1;
}
}
SRC_SaveCache();
time = OS_GetTime() - time;
IO_Printf("TIME total build file execution: %f\n", time);
}