Fix cache, misc changes
This commit is contained in:
4
.github/workflows/run-tests.yml
vendored
4
.github/workflows/run-tests.yml
vendored
@@ -5,13 +5,13 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- run: sudo apt install g++
|
||||
- run: g++ build_tool/build_main.cpp -o bld && ./bld
|
||||
- run: g++ build_tool/main.cpp -o bld && ./bld
|
||||
run-and-compile-mac:
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- run: brew install llvm
|
||||
- run: clang++ build_tool/build_main.cpp -std=c++11 -o bld && ./bld
|
||||
- run: clang++ build_tool/main.cpp -std=c++11 -o bld && ./bld
|
||||
run-and-compile-windows:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
|
||||
@@ -3,6 +3,6 @@ call ../misc/compile_setup.bat
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
cl -Fe:bld.exe ../build_tool/build_main.cpp -FC -WX -W3 -wd4200 -diagnostics:column -nologo -Zi -D_CRT_SECURE_NO_WARNINGS
|
||||
cl -Fe:bld.exe ../build_tool/main.cpp -FC -WX -W3 -wd4200 -diagnostics:column -nologo -Zi -D_CRT_SECURE_NO_WARNINGS
|
||||
cd ..
|
||||
build\bld.exe
|
||||
|
||||
2
build.sh
2
build.sh
@@ -1,3 +1,3 @@
|
||||
#!/usr/bin/env bash
|
||||
gcc -o bld build_tool/build_main.cpp -g
|
||||
gcc -o bld build_tool/main.cpp -g
|
||||
./bld
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "build_tool/build_lib.cpp"
|
||||
#include "build_tool/library.cpp"
|
||||
|
||||
void CompileFiles(Strs cc, Strs files);
|
||||
int ReturnValue = 0;
|
||||
|
||||
@@ -80,10 +80,10 @@ SRC_CacheEntry *SRC_HashFile(S8_String file, char *parent_file) {
|
||||
for (CL_Token token = CL_Next(&lexer); token.kind != CL_EOF; token = CL_Next(&lexer)) {
|
||||
if (token.is_system_include) continue;
|
||||
|
||||
S8_String file_it = S8_Make(token.str, token.len);
|
||||
S8_String file_it = S8_MakeFromChar(token.string_literal);
|
||||
SRC_CacheEntry *cache = SRC_HashFile(file_it, resolved_file);
|
||||
if (!cache) {
|
||||
IO_Printf("Missing cache for: %.*s\n", S8_Expand(file_it));
|
||||
// error was reported already IO_Printf("Missing cache for: %.*s\n", S8_Expand(file_it));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ MA_Arena PernamentArena;
|
||||
MA_Arena *Perm = &PernamentArena;
|
||||
Table<S8_String> CMDLine;
|
||||
|
||||
#include "cache.c"
|
||||
#include "cache.cpp"
|
||||
|
||||
//
|
||||
//
|
||||
@@ -1,5 +1,5 @@
|
||||
#define BUILD_MAIN
|
||||
#include "build_lib.cpp"
|
||||
#include "library.cpp"
|
||||
|
||||
int main(int argument_count, char **arguments) {
|
||||
OS_MakeDir(S8_Lit("build"));
|
||||
@@ -3,12 +3,8 @@
|
||||
leeway for big buffers and other such things. Just make sure to not relay on it because it's easier unless specified.
|
||||
- Not sure if we should assume that strings should use allocators or arenas, for now it's arenas because I don't have other use cases
|
||||
@todo
|
||||
- Maybe create a nice C++ binding for strings,
|
||||
- Add proper string arrays and utilities for build files
|
||||
- also add String Arrays and String Builder, temp allocators hook ins for nicer api
|
||||
- Iterating over unicode codepoints using For
|
||||
- Redesign clexer because the Arena Tuple is hella weird
|
||||
- Maybe remove token array stuff, do standard stream thing, then you need one arena ...
|
||||
- Add filter stuff so we can get includes / comments / normal tokens etc.
|
||||
*/
|
||||
|
||||
#include "core.h"
|
||||
|
||||
@@ -495,10 +495,11 @@ OS_API void OS_Advance(OS_FileIter *it) {
|
||||
it->is_directory = file->d_type == DT_DIR;
|
||||
it->filename = S8_CopyChar(it->arena, file->d_name);
|
||||
|
||||
const char *is_dir = it->is_directory ? "/" : "";
|
||||
const char *dir_char_ending = it->is_directory ? "/" : "";
|
||||
const char *separator = it->path.str[it->path.len - 1] == '/' ? "" : "/";
|
||||
it->relative_path = S8_Format(it->arena, "%.*s%s%s%s", S8_Expand(it->path), separator, file->d_name, is_dir);
|
||||
it->relative_path = S8_Format(it->arena, "%.*s%s%s%s", S8_Expand(it->path), separator, file->d_name, dir_char_ending);
|
||||
it->absolute_path = OS_GetAbsolutePath(it->arena, it->relative_path);
|
||||
if (it->is_directory) it->absolute_path = S8_Format(it->arena, "%.*s/", S8_Expand(it->absolute_path));
|
||||
it->is_valid = true;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -60,6 +60,13 @@ CL_PRIVATE_FUNCTION bool CL_FileExists(char *name) {
|
||||
|
||||
CL_PRIVATE_FUNCTION void CL_ReportError(CL_Lexer *T, CL_Token *token, const char *string, ...);
|
||||
|
||||
CL_PRIVATE_FUNCTION char *CL_PushStringCopy(CL_Allocator arena, char *p, int size) {
|
||||
char *copy_buffer = (char *)CL_Allocate(arena, size + 1);
|
||||
CL__MemoryCopy(copy_buffer, p, size);
|
||||
copy_buffer[size] = 0;
|
||||
return copy_buffer;
|
||||
}
|
||||
|
||||
CL_INLINE void CL_Advance(CL_Lexer *T) {
|
||||
if (*T->stream == '\n') {
|
||||
T->line += 1;
|
||||
@@ -274,6 +281,8 @@ skip_utf_encode:
|
||||
// so the final string actually needs additional transformation pass. A pass
|
||||
// that will combine the string snippets, replace escape sequences with actual values etc.
|
||||
//
|
||||
// @warning: @not_sure: we are not setting token->string_literal
|
||||
//
|
||||
// "String 1" "String 2" - those strings snippets are combined
|
||||
// @todo: look at this again
|
||||
// @todo: make a manual correct version that user can execute if he needs to
|
||||
@@ -635,6 +644,9 @@ CL_PRIVATE_FUNCTION void CL_LexMacroInclude(CL_Lexer *T, CL_Token *token) {
|
||||
}
|
||||
CL_SetTokenLength(T, token);
|
||||
CL_Advance(T);
|
||||
|
||||
// @not_sure: this is because we want null terminated input into path resolution stuff
|
||||
token->string_literal = CL_PushStringCopy(T->arena, token->str, token->len);
|
||||
}
|
||||
|
||||
CL_PRIVATE_FUNCTION bool CL_LexMacro(CL_Lexer *T, CL_Token *token) {
|
||||
@@ -1227,13 +1239,6 @@ CL_API_FUNCTION CL_Lexer CL_Begin(CL_Allocator arena, char *stream, char *filena
|
||||
//
|
||||
//
|
||||
|
||||
CL_PRIVATE_FUNCTION char *CL_PushStringCopy(CL_Allocator arena, char *p, int size) {
|
||||
char *copy_buffer = (char *)CL_Allocate(arena, size + 1);
|
||||
CL__MemoryCopy(copy_buffer, p, size);
|
||||
copy_buffer[size] = 0;
|
||||
return copy_buffer;
|
||||
}
|
||||
|
||||
CL_PRIVATE_FUNCTION char *CL_ChopLastSlash(CL_Allocator arena, char *str) {
|
||||
int i = 0;
|
||||
int slash_pos = -1;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "../core_library/core.c"
|
||||
|
||||
#define CL_Arena MA_Arena
|
||||
#define CL_PushSize MA_PushSizeNonZeroed
|
||||
#define CL_Allocator MA_Arena *
|
||||
#define CL_Allocate(a, s) MA_PushSizeNonZeroed(a, s)
|
||||
#define CL_ASSERT IO_Assert
|
||||
#define CL_VSNPRINTF stbsp_vsnprintf
|
||||
#define CL_SNPRINTF stbsp_snprintf
|
||||
|
||||
@@ -78,7 +78,7 @@ int main() {
|
||||
{
|
||||
for (OS_FileIter it = OS_IterateFiles(&arena, S8_Lit("..")); OS_IsValid(it); OS_Advance(&it)) {
|
||||
if (it.is_directory) {
|
||||
IO_Assert(it.absolute_path.str[it.absolute_path.len - 1] == '/');
|
||||
IO_Assertf(it.absolute_path.str[it.absolute_path.len - 1] == '/', "%.*s", S8_Expand(it.absolute_path));
|
||||
}
|
||||
IO_Assert(!S8_Seek(it.absolute_path, S8_Lit(".."), 0, 0));
|
||||
IO_Assert(S8_Seek(it.relative_path, S8_Lit(".."), 0, 0));
|
||||
|
||||
Reference in New Issue
Block a user