Compare commits

..

No commits in common. "4cb2893b85024c751369cc0143a7ae9e036636af" and "8d6775a480dd904745be9b19a83ee840c7a3aadd" have entirely different histories.

8 changed files with 21 additions and 54 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 && 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 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 && build\gsa_simple.exe clang build.c src/str.c -Iinclude -Wno-everything -obuild.exe && build.exe && del build.exe
EXIT /B %ERRORLEVEL% EXIT /B %ERRORLEVEL%
REM build\skip.exe c src && exit /b 1 REM build\skip.exe c src && exit /b 1
REM build\gsa.exe REM build\gsa.exe

18
build.c
View File

@ -33,9 +33,8 @@ int main(int argc, char *argv[]) {
"" ""
); );
sys("cl /c /MD /O2 " sys("cl /c /MD /O2 /Za "
"../src/*.c " "../src/*.c "
"../src/net/*.c "
"/I../include " "/I../include "
"/I../subprojects/glew-2.1.0/include " "/I../subprojects/glew-2.1.0/include "
"/I../subprojects/glfw-3.3.8/include " "/I../subprojects/glfw-3.3.8/include "
@ -67,26 +66,21 @@ int main(int argc, char *argv[]) {
} }
void cmake(char *dep, char *libpath, char *lib, char *cmake_dir, char *params) { void cmake(char *dep, char *libpath, char *lib, char *cmake_dir, char *params) {
if(file_exists(sw_str_concat("deps\\", lib))) { if(file_exists(sw_concat("deps\\", lib))) {
printf("%s already exists, not compiling dependency\n", lib); printf("%s already exists, not compiling dependency\n", lib);
return; return;
} }
printf("compiling %s", lib); printf("compiling %s", lib);
sys(sw_str_concat("md ", dep)); sys(sw_concat("md ", dep));
chdir(dep); chdir(dep);
sys(sw_str_concat4( sys(sw_concat4(
"cmake ", "cmake ", params, " ../../subprojects/", sw_concat3(dep, "/", cmake_dir)
params,
" ../../subprojects/",
sw_str_concat3(dep, "/", cmake_dir)
)); ));
sys("cmake --build . --config Release"); sys("cmake --build . --config Release");
chdir(".."); chdir("..");
sys(sw_str_concat4( sys(sw_concat4(sw_concat3("copy ", dep, "\\"), libpath, " deps\\", lib));
sw_str_concat3("copy ", dep, "\\"), libpath, " deps\\", lib
));
} }
bool file_exists(char *dir) { bool file_exists(char *dir) {

View File

@ -5,6 +5,4 @@ void sw_debug(char *fmt, ...);
void sw_error(char *fmt, ...); void sw_error(char *fmt, ...);
void sw_log(char *fmt, ...); void sw_log(char *fmt, ...);
void sw_win32_error();
#endif /* GUARD_F07765349E6C37FAA98BC158D7119E65 */ #endif /* GUARD_F07765349E6C37FAA98BC158D7119E65 */

View File

@ -1,9 +1,9 @@
#ifndef GUARD_0941C997CB4D2297C8FEA1374912B5D1 #ifndef GUARD_0941C997CB4D2297C8FEA1374912B5D1
#define GUARD_0941C997CB4D2297C8FEA1374912B5D1 #define GUARD_0941C997CB4D2297C8FEA1374912B5D1
char *sw_str_concat(char *a, char *b); char *sw_concat(char *a, char *b);
char *sw_str_concat3(char *a, char *b, char *c); char *sw_concat3(char *a, char *b, char *c);
char *sw_str_concat4(char *a, char *b, char *c, char *d); char *sw_concat4(char *a, char *b, char *c, char *d);
char *sw_str_dup(char *str); char *sw_strdup(char *str);
#endif /* GUARD_0941C997CB4D2297C8FEA1374912B5D1 */ #endif /* GUARD_0941C997CB4D2297C8FEA1374912B5D1 */

View File

@ -4,10 +4,6 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <windows.h>
#include "types.h"
void sw_debug(char *fmt, ...) { void sw_debug(char *fmt, ...) {
va_list argp; va_list argp;
@ -41,23 +37,3 @@ void sw_log(char *fmt, ...) {
printf("\n"); printf("\n");
fflush(stdout); 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);
}

View File

@ -96,7 +96,7 @@ void sw_skip_add(struct sw_skip *skip, u8 *data, u32 data_size, char *name) {
skip->file_count += 1; skip->file_count += 1;
skip->files = skip->files =
realloc(skip->files, sizeof(skip->files[0]) * skip->file_count); realloc(skip->files, sizeof(skip->files[0]) * skip->file_count);
skip->files[skip->file_count - 1].name = sw_str_dup(name); skip->files[skip->file_count - 1].name = sw_strdup(name);
skip->files[skip->file_count - 1].offset = off; skip->files[skip->file_count - 1].offset = off;
skip->files[skip->file_count - 1].size = data_size; skip->files[skip->file_count - 1].size = data_size;
} }

View File

@ -3,7 +3,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
char *sw_str_concat(char *a, char *b) { char *sw_concat(char *a, char *b) {
char *str; char *str;
u32 len_a, len_b; u32 len_a, len_b;
@ -18,7 +18,7 @@ char *sw_str_concat(char *a, char *b) {
return str; return str;
} }
char *sw_str_concat3(char *a, char *b, char *c) { char *sw_concat3(char *a, char *b, char *c) {
char *str; char *str;
u32 len_a, len_b, len_c; u32 len_a, len_b, len_c;
@ -35,7 +35,7 @@ char *sw_str_concat3(char *a, char *b, char *c) {
return str; return str;
} }
char *sw_str_concat4(char *a, char *b, char *c, char *d) { char *sw_concat4(char *a, char *b, char *c, char *d) {
char *str; char *str;
u32 len_a, len_b, len_c, len_d; u32 len_a, len_b, len_c, len_d;
@ -54,7 +54,7 @@ char *sw_str_concat4(char *a, char *b, char *c, char *d) {
return str; return str;
} }
char *sw_str_dup(char *str) { char *sw_strdup(char *str) {
char *out; char *out;
u32 len; u32 len;

View File

@ -80,17 +80,16 @@ void crawl(char *dst, char *part_path) {
char *path; char *path;
char *new_part_path; char *new_part_path;
dir = sw_str_concat(dst, "/*.*"); dir = sw_concat(dst, "/*.*");
find = FindFirstFile(dir, &data); find = FindFirstFile(dir, &data);
do { do {
if(strcmp(data.cFileName, ".") != 0 && if(strcmp(data.cFileName, ".") != 0 &&
strcmp(data.cFileName, "..") != 0) { strcmp(data.cFileName, "..") != 0) {
path = sw_str_concat3(dst, "/", data.cFileName); path = sw_concat3(dst, "/", data.cFileName);
if(part_path) { if(part_path) {
new_part_path = new_part_path = sw_concat3(part_path, "/", data.cFileName);
sw_str_concat3(part_path, "/", data.cFileName);
} else { } else {
new_part_path = sw_str_dup(data.cFileName); new_part_path = sw_strdup(data.cFileName);
} }
crawl(path, new_part_path); crawl(path, new_part_path);
free(path); free(path);
@ -133,7 +132,7 @@ int main(int argc, char *argv[]) {
sw_error("argument not a directory"); sw_error("argument not a directory");
} }
crawl(argv[2], 0); crawl(argv[2], 0);
filename = sw_str_concat(argv[2], ".skip"); filename = sw_concat(argv[2], ".skip");
sw_skip_save(skip, filename); sw_skip_save(skip, filename);
printf("%s created\n", filename); printf("%s created\n", filename);
free(filename); free(filename);