added sw_win32_error

This commit is contained in:
DaniTheSkunk 2023-02-26 22:29:44 +00:00
parent c3e8c508ae
commit 4cb2893b85
4 changed files with 39 additions and 7 deletions

View File

@ -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

18
build.c
View File

@ -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) {

View File

@ -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 */

View File

@ -4,6 +4,10 @@
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#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);
}