From 4cb2893b85024c751369cc0143a7ae9e036636af Mon Sep 17 00:00:00 2001 From: DaniTheSkunk <> Date: Sun, 26 Feb 2023 22:29:44 +0000 Subject: [PATCH] added sw_win32_error --- build.bat | 2 +- build.c | 18 ++++++++++++------ include/error.h | 2 ++ src/error.c | 24 ++++++++++++++++++++++++ 4 files changed, 39 insertions(+), 7 deletions(-) diff --git a/build.bat b/build.bat index 5acacf3..afae0d5 100644 --- a/build.bat +++ b/build.bat @@ -3,7 +3,7 @@ REM cd build && cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -GNinja .. && ninja && copy compile_commands.json .. && skunkworks.exe REM cd build && meson compile && copy compile_commands.json .. && cd .. && build\gsa.exe -clang build.c src/str.c -Iinclude -Wno-everything -obuild.exe && build.exe && del build.exe +clang build.c src/str.c -Iinclude -Wno-everything -obuild.exe && build.exe && del build.exe && build\gsa_simple.exe EXIT /B %ERRORLEVEL% REM build\skip.exe c src && exit /b 1 REM build\gsa.exe diff --git a/build.c b/build.c index 0ea5ede..a3d91f8 100644 --- a/build.c +++ b/build.c @@ -33,8 +33,9 @@ int main(int argc, char *argv[]) { "" ); - sys("cl /c /MD /O2 /Za " + sys("cl /c /MD /O2 " "../src/*.c " + "../src/net/*.c " "/I../include " "/I../subprojects/glew-2.1.0/include " "/I../subprojects/glfw-3.3.8/include " @@ -66,21 +67,26 @@ int main(int argc, char *argv[]) { } void cmake(char *dep, char *libpath, char *lib, char *cmake_dir, char *params) { - if(file_exists(sw_concat("deps\\", lib))) { + if(file_exists(sw_str_concat("deps\\", lib))) { printf("%s already exists, not compiling dependency\n", lib); return; } printf("compiling %s", lib); - sys(sw_concat("md ", dep)); + sys(sw_str_concat("md ", dep)); chdir(dep); - sys(sw_concat4( - "cmake ", params, " ../../subprojects/", sw_concat3(dep, "/", cmake_dir) + sys(sw_str_concat4( + "cmake ", + params, + " ../../subprojects/", + sw_str_concat3(dep, "/", cmake_dir) )); sys("cmake --build . --config Release"); chdir(".."); - sys(sw_concat4(sw_concat3("copy ", dep, "\\"), libpath, " deps\\", lib)); + sys(sw_str_concat4( + sw_str_concat3("copy ", dep, "\\"), libpath, " deps\\", lib + )); } bool file_exists(char *dir) { diff --git a/include/error.h b/include/error.h index 516223e..0561540 100644 --- a/include/error.h +++ b/include/error.h @@ -5,4 +5,6 @@ void sw_debug(char *fmt, ...); void sw_error(char *fmt, ...); void sw_log(char *fmt, ...); +void sw_win32_error(); + #endif /* GUARD_F07765349E6C37FAA98BC158D7119E65 */ diff --git a/src/error.c b/src/error.c index 29ba40b..9acd01a 100644 --- a/src/error.c +++ b/src/error.c @@ -4,6 +4,10 @@ #include #include +#include + +#include "types.h" + void sw_debug(char *fmt, ...) { va_list argp; @@ -37,3 +41,23 @@ void sw_log(char *fmt, ...) { printf("\n"); fflush(stdout); } + +void sw_win32_error() { + u32 error; + char *str; + + error = GetLastError(); + + FormatMessage( + FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + 0, + error, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (char *)&str, + 0, + 0 + ); + + sw_error("[win32] %s", str); +}