build scripts menu2
authorhgn <hgodden00@gmail.com>
Thu, 30 May 2024 20:47:29 +0000 (21:47 +0100)
committerhgn <hgodden00@gmail.com>
Thu, 30 May 2024 20:47:29 +0000 (21:47 +0100)
build.c

diff --git a/build.c b/build.c
index 3cb9299dbe0b4d4cd9d86a7c54137d4fce465751..4bcff959a5743614eed410d6280f33ccdf2601e6 100644 (file)
--- a/build.c
+++ b/build.c
@@ -139,8 +139,6 @@ void build_shaders(void){
 
 void build_game_content( struct vg_project *proj )
 {
-   vg_project_new_target( proj, "Content files", k_obj_type_none );
-
    vg_symlink( proj, "textures_src", "textures" );
    vg_symlink( proj, "models_src", "models" );
    vg_symlink( proj, "boards_src", "boards" );
@@ -153,7 +151,7 @@ void build_game_content( struct vg_project *proj )
    vg_syscall( "cp bin/skaterift_blender.zip bin/%s/tools/", proj->uid.buffer );
 }
 
-void build_game_bin( struct vg_project *proj )
+void build_game_bin( struct vg_project *proj, struct vg_compiler_env *env )
 {
    static int meta = 0;
    if( !meta )
@@ -166,8 +164,14 @@ void build_game_bin( struct vg_project *proj )
    
 #include "control_overlay.h"
 
-   vg_project_new_target( proj, "skaterift", k_obj_type_exe );
-   vg_add_engine( proj, &(struct vg_engine_config ) 
+   struct vg_compiler_conf conf = {0};
+
+   if( env->platform == k_platform_windows )
+   {
+      vg_strcat( &conf.link, "-lws2_32 " );
+   }
+
+   vg_make_app( proj, &(struct vg_engine_config ) 
          {
             .fixed_update_hz = 60,
             .legacy_support_vg_msg1 = 1,
@@ -176,54 +180,55 @@ void build_game_bin( struct vg_project *proj )
             .use_3d = 1,
             .custom_game_settings = 0,
             .custom_shaders = 1
-         });
-
-   if( proj->env->platform == k_platform_windows )
-   {
-      vg_link( proj, "-lws2_32 " );
-   }
+         }, 
+         env, &conf, "skaterift.c", "skaterift" );
 
-   vg_add_source( proj, "skaterift.c " );
    vg_add_controller_database( proj );
-   vg_compile_project( proj );
 }
 
-void build_sqlite_for_env( struct vg_env *env, struct vg_project *out_proj )
+struct compile_result 
+build_sqlite_for_env( struct vg_compiler_env *env )
 {
-   struct vg_env sqlite_env = *env;
+   struct vg_project sqlite_proj;
+   vg_project_init( &sqlite_proj, "bin", ".sqlite3", env, 0 );
+
+   struct vg_compiler_env sqlite_env = *env;
    sqlite_env.optimization = 3; /* force optimization always */
    sqlite_env.debug_asan = 0;
 
-   vg_project_init( out_proj, env, "sqlite3" );
-   vg_project_new_target( out_proj, "sqlite3", k_obj_type_obj );
+   struct vg_compiler_conf conf = {0};
+   vg_strcat( &conf.link, "-ldl " );
 
-   vg_add_source( out_proj, "-c dep/sqlite3/sqlite3.c " );
-   vg_link( out_proj, "-ldl " );
-   vg_compile_project( out_proj );
+   return vg_compiler_run( &sqlite_proj, &sqlite_env, &conf,
+                           "dep/sqlite3/sqlite3.c ", "sqlite3",
+                           k_obj_type_obj );
 }
 
-void compile_server( struct vg_project *proj )
+void compile_server( struct vg_project *proj, struct vg_compiler_env *env )
 {
-   struct vg_project sqlite_project;
-   build_sqlite_for_env( proj->env, &sqlite_project );
-
-   vg_project_new_target( proj, "server", k_obj_type_exe );
-   vg_add_source( proj, "gameserver.c vg/vg_tool.c vg/vg_steam.c \\\n " );
-   vg_add_source( proj, sqlite_project.compiled_objects.buffer );
-   vg_include_dir( proj, "-I./dep " );
-   vg_library_dir( proj, "-L./vg/dep/steam " );
-   vg_link( proj, "-ldl -lpthread -lm -lsdkencryptedappticket -lsteam_api " );
+   struct compile_result sqlite = build_sqlite_for_env( env );
+
+   vg_str sources = {0};
+   vg_strcat( &sources, "gameserver.c vg/vg_tool.c vg/vg_steam.c \\\n " );
+   vg_strcat( &sources, sqlite.path.buffer );
+
+   struct vg_compiler_conf conf = {0};
+   vg_strcat( &conf.include, "-I. -I./dep " );
+   vg_strcat( &conf.library, "-L./vg/dep/steam " );
+   vg_strcat( &conf.link, "-ldl -lpthread -lm -lsdkencryptedappticket -lsteam_api " );
+
    vg_add_blob( proj, "vg/dep/steam/libsteam_api.so", "" );
    vg_add_blob( proj, "vg/dep/steam/libsdkencryptedappticket.so", "" );
 
-   vg_compile_project( proj );
+   vg_compiler_run( proj, env, &conf, sources.buffer, "server", k_obj_type_exe );
 }
 
-void compile_tools( struct vg_project *proj )
+struct compile_result
+compile_tools( struct vg_project *proj, struct vg_compiler_env *env )
 {
-   vg_project_new_target( proj, "skaterift", k_obj_type_shared );
-   vg_add_source( proj, "skaterift_lib.c " );
-   vg_compile_project( proj );
+   struct vg_compiler_conf conf = {0};
+   return vg_compiler_run( proj, env, &conf, "skaterift_lib.c", "skaterift",
+                           k_obj_type_shared );
 }
 
 /*
@@ -233,19 +238,20 @@ void compile_tools( struct vg_project *proj )
 void s_compile_tools(void)
 {
    vg_info( "running script: s_compile_tools(void)\n" );
-   struct vg_env env = vg_release_env;
-   env.platform = k_platform_linux;
 
-   struct vg_project windows_proj, linux_proj;
-   vg_project_init( &linux_proj, &env, "skaterift-tools" );
-   compile_tools( &linux_proj );
+   struct vg_project proj;
+   vg_project_init( &proj, "bin", "skaterift-tools", NULL, 0 );
+
+   struct vg_compiler_env env = vg_release_env;
+
+   env.platform = k_platform_linux;
+   struct compile_result r0 = compile_tools( &proj, &env );
 
    env.platform = k_platform_windows;
-   vg_project_init( &windows_proj, &env, "skaterift-tools" );
-   compile_tools( &windows_proj );
+   struct compile_result r1 = compile_tools( &proj, &env );
 
-   vg_syscall("cp %s skaterift_blender/", linux_proj.compiled_objects.buffer );
-   vg_syscall("cp %s skaterift_blender/", windows_proj.compiled_objects.buffer);
+   vg_syscall("cp %s skaterift_blender/", r0.path );
+   vg_syscall("cp %s skaterift_blender/", r1.path );
    vg_syscall( "zip -r bin/skaterift_blender.zip skaterift_blender/ "
                "-x skaterift_blender/__pycache__/\\*");
 }
@@ -256,22 +262,22 @@ void s_release_all(void)
 
    struct vg_project content_proj, windows_proj, linux_proj;
 
-   struct vg_env env = vg_release_env;
+   struct vg_compiler_env env = vg_release_env;
    env.platform = k_platform_anyplatform;
-   vg_project_init( &content_proj, &env, "skaterift" );
+   vg_project_init( &content_proj, "bin", "skaterift", &env, 1 );
    build_game_content( &content_proj );
 
    /* binaries for windows */
    env = vg_release_env;
    env.platform = k_platform_windows;
-   vg_project_init( &windows_proj, &env, "skaterift" );
-   build_game_bin( &windows_proj );
+   vg_project_init( &windows_proj, "bin", "skaterift", &env, 1 );
+   build_game_bin( &windows_proj, &env );
 
    /* binaries for linux */
    env = vg_release_env;
    env.platform = k_platform_linux;
-   vg_project_init( &linux_proj, &env, "skaterift" );
-   build_game_bin( &linux_proj );
+   vg_project_init( &linux_proj, "bin", "skaterift", &env, 1 );
+   build_game_bin( &linux_proj, &env );
 
    /* package them up for storage */
    vg_tarball_project( &content_proj );
@@ -289,9 +295,9 @@ void s_testing_build(void)
    vg_info( "running script: s_testing_build(void)\n" );
 
    struct vg_project test_proj;
-   vg_project_init( &test_proj, &vg_test_env, "skaterift-test" );
+   vg_project_init( &test_proj, "bin", "skaterift-test", NULL, 0 );
 
-   build_game_bin( &test_proj );
+   build_game_bin( &test_proj, &vg_test_env );
    build_game_content( &test_proj );
    vg_add_blob( &test_proj, "steam_appid.txt", "" );
 }
@@ -301,8 +307,8 @@ void s_testing_server(void)
    vg_info( "running script: s_testing_server(void)\n" );
 
    struct vg_project test_proj;
-   vg_project_init( &test_proj, &vg_test_env, "skaterift-test-server" );
-   compile_server( &test_proj );
+   vg_project_init( &test_proj, "bin", "skaterift-test-server", &vg_test_env, 0 );
+   compile_server( &test_proj, &vg_test_env );
 }
 
 int main( int argc, char *argv[] )