vg2 port: build script and resource loading
[fishladder.git] / build.c
diff --git a/build.c b/build.c
new file mode 100644 (file)
index 0000000..8827489
--- /dev/null
+++ b/build.c
@@ -0,0 +1,121 @@
+#include "vg/vg.h"
+#include "vg/vg_platform.h"
+#include "vg/vg_log.h"
+#include "vg/vg_opt.h"
+#include "vg/vg_build.h"
+#include "vg/vg_build_utils_shader.h"
+#include "vg/vg_msg.h"
+
+u32 optimize_test_compile = 0;
+
+/*
+ * Compilation specifications
+ * -------------------------------------------------------------------------- */
+
+void build_game_content(void){
+   const char *project_name = vg_build.project_name.buffer;
+   vg_low( "Building game content structure\n" );
+   vg_symlink( "textures", "textures" );
+   vg_syscall( "mkdir -p bin/%s/cfg", project_name );
+}
+
+void build_shaders(void);
+void compile_game( int binaries, int content ){
+   static int meta = 0;
+   if( !meta ){
+      meta = 1;
+      build_shaders();
+      vg_low( "\n\n" );
+   }
+
+   vg_build_new( "marblecomp" );
+
+   if( binaries ){
+      vg_add_source( "marblecomp.c" );
+      vg_add_graphics();
+      vg_add_game_stuff();
+      vg_compile( "marblecomp" );
+   }
+
+   if( content )
+      build_game_content();
+}
+
+/*
+ * Scripts
+ * -------------------------------------------------------------------------- */
+
+void s_release_all(void){
+   vg_info( "running script: s_release_all(void)\n" );
+
+   vg_build.optimization = 3;
+   vg_build.fresh = 1;
+   vg_build.arch = k_architecture_x86_64;
+   vg_build.compiler = k_compiler_zigcc;
+   vg_build.libc = k_libc_version_2_23;
+
+   /* binaries for windows and linux */
+   vg_build.platform = k_platform_windows;
+   compile_game( 1, 0 );
+   vg_tarball_last_project(); 
+   vg_success( "Completed 1/3\n" );
+
+   vg_build.platform = k_platform_linux;
+   compile_game( 1, 0 );
+   vg_tarball_last_project(); 
+   vg_success( "Completed 2/3\n" );
+
+   /* content files for any platform */
+   vg_build.platform = k_platform_anyplatform;
+   vg_build.compiler = k_compiler_blob;
+   vg_build.arch = k_architecture_anyarch;
+   vg_build.libc = k_libc_version_native;
+   compile_game( 0, 1 );
+   vg_tarball_last_project(); 
+   vg_success( "Completed 3/3\n" );
+}
+
+void s_testing_build(void){
+   vg_info( "running script: s_testing_build(void)\n" );
+
+   vg_build.optimization = optimize_test_compile;
+   vg_build.fresh = 0;
+   vg_build.platform = k_platform_linux;
+   vg_build.arch = k_architecture_x86_64;
+   vg_build.compiler = k_compiler_clang;
+   vg_build.libc = k_libc_version_native;
+
+   compile_game( 1, 1 );
+
+   vg_success( "Completed 1/1\n" );
+}
+
+int main( int argc, char *argv[] ){
+   char *arg;
+   while( vg_argp( argc, argv ) ){
+      if( vg_long_opt( "release-all" ) )
+         s_release_all();
+
+      if( vg_long_opt( "testing-build" ) )
+         s_testing_build();
+
+      if( vg_opt('r') )
+         optimize_test_compile = 3;
+   }
+
+   if( vg_build.warnings )
+      vg_warn( "Finished with %u warnings\n", vg_build.warnings );
+   else
+      vg_success( "All scripts ran successfully\n" );
+}
+
+#define _S( NAME, VS, FS ) \
+   vg_build_shader( "shaders/" VS, "shaders/" FS, NULL, "shaders", NAME )
+
+void build_shaders(void){
+   vg_info( "Compiling shader headers\n" );
+   vg_shader_set_include_dir( "shaders" );
+
+   /* Scene */
+   //_S( "scene_standard",            "scene.vs", "scene_standard.fs" );
+}