X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=vg_build.h;h=f7a641ec2d13a5f573a5735b5e77ed31058c2bf0;hb=79bf1e02c9af40922b184ccd42533b3608d20364;hp=fbfbf95062e56f5c744f36f58685abd4ecfb4895;hpb=0aea2ef68a5ed32fc940673402a1b4b67f38d4d3;p=vg.git diff --git a/vg_build.h b/vg_build.h index fbfbf95..f7a641e 100644 --- a/vg_build.h +++ b/vg_build.h @@ -32,9 +32,12 @@ struct compiler_info { k_compiler_clang, k_compiler_gcc, - k_compiler_mingw + k_compiler_mingw, + k_compiler_none } compiler; + + int clean; } static vg_compiler; @@ -77,7 +80,7 @@ void vg_build_include( const char *inc ) const char *vg_compiler_str(void) { - return (const char *[]){ "clang", "gcc", "i686-w64-mingw32-gcc" } + return (const char *[]){ "clang", "gcc", "i686-w64-mingw32-gcc", "none" } [vg_compiler.compiler]; } @@ -88,7 +91,6 @@ void vg_build_start( const char *name, enum compiler compiler ) vg_compiler.include[0] = '\0'; vg_compiler.library[0] = '\0'; vg_compiler.compiler = compiler; - strcpy( vg_compiler.name, name ); snprintf( vg_compiler.build_dir, 512, @@ -96,6 +98,10 @@ void vg_build_start( const char *name, enum compiler compiler ) name, vg_compiler_str() ); + if( vg_compiler.clean ){ + vg_build_syscall( "rm -rf %s", vg_compiler.build_dir ); + } + vg_build_syscall( "mkdir -p %s", vg_compiler.build_dir ); vg_build_include( "-I. -I./vg " ); vg_build_library_dir( "-L. " ); @@ -110,11 +116,26 @@ void vg_build_add_link_for_graphics(void) } else { - vg_build_link( "-lmingw32 -lSDL2main -lSDL2 -lopengl32 -mwindows " ); + vg_build_link( "-lmingw32 -lSDL2main -lSDL2 -lopengl32 -mwindows \\\n" ); + vg_build_link( " -Wl,--dynamicbase -Wl,--nxcompat \\\n" ); + + /* + 26.05.23: Suddenly something is pulling in winpthread. + * cant work out whats doing it or why. */ + vg_build_link( " -Wl,-Bstatic,--whole-archive \\\n" ); + vg_build_link( " -lwinpthread \\\n" ); + vg_build_link( " -Wl,--no-whole-archive " ); } vg_build_object( "vg/dep/glad/glad.c " ); - vg_build_link( "-lm -pthread " ); + + vg_build_link( "-lm " ); + if( vg_compiler.compiler == k_compiler_mingw ){ + //vg_build_link( "-mthreads " ); + //vg_build_link( "-static-libgcc " ); + } + else{ + vg_build_link( "-pthread " ); + } } void vg_build_add_link_for_game(void) @@ -184,9 +205,13 @@ void vg_build_mode_debug(void) vg_compiler.optimization_profile = k_optimization_profile_debug; } +void vg_build_clean(void){ + vg_compiler.clean = 1; +} + void vg_build(void) { - char cmd[4096]; + char cmd[8192]; cmd[0] = '\0'; /* Compiler */ @@ -202,7 +227,8 @@ void vg_build(void) if( (vg_compiler.compiler == k_compiler_gcc) || (vg_compiler.compiler == k_compiler_clang ) ) { - strcat( cmd, "-rdynamic -fsanitize=address " ); + strcat( cmd, "-rdynamic -fsanitize=address " + "-fPIE -fstack-protector-strong " ); } strcat( cmd, "\\\n" ); @@ -215,10 +241,15 @@ void vg_build(void) /* Warnings */ strcat( cmd, " -Wall\\\n" - " -Wno-unused-function -Wno-unused-variable\\\n" - " -Wno-unused-command-line-argument -Wno-unused-but-set-variable\\\n" + " -Wno-unused-function -Wno-unused-variable -Wno-format-truncation\\\n" + " -Wno-unused-command-line-argument -Wno-unused-but-set-variable\\\n" ); + if( vg_compiler.compiler == k_compiler_clang ){ + strcat( cmd, + " -ferror-limit=5\\\n" ); + } + /* Include */ strcat( cmd, " " ); strcat( cmd, vg_compiler.include );