+#include "control_overlay.h"
+
+ struct vg_compiler_conf conf = {0};
+
+ if( env->platform == k_platform_windows )
+ {
+ vg_strcat( &conf.link, "-lws2_32 " );
+ }
+
+ //vg_strcat( &conf.defines, "-DSKATERIFT " );
+ vg_strcat( &conf.defines, "-DHGATE " );
+
+ vg_make_app( proj, &(struct vg_engine_config )
+ {
+ .fixed_update_hz = 60,
+ .legacy_support_vg_msg1 = 1,
+ .log_source_info = 1,
+ .steam_api = 1,
+ .use_3d = 1,
+ .custom_game_settings = 0,
+ .custom_shaders = 1
+ },
+ env, &conf, "client.c", "skaterift" );
+
+ vg_add_controller_database( proj );
+}
+
+struct compile_result
+build_sqlite_for_env( struct vg_compiler_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;
+
+ struct vg_compiler_conf conf = {0};
+ vg_strcat( &conf.link, "-ldl " );
+
+ 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, struct vg_compiler_env *env )
+{
+ 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_compiler_run( proj, env, &conf, sources.buffer, "server", k_obj_type_exe );
+}
+
+struct compile_result
+compile_tools( struct vg_project *proj, struct vg_compiler_env *env )
+{
+ struct vg_compiler_conf conf = {0};
+ return vg_compiler_run( proj, env, &conf, "skaterift_lib.c", "skaterift",
+ k_obj_type_shared );
+}
+
+/*
+ * Scripts
+ * -------------------------------------------------------------------------- */
+
+void s_compile_tools(void)
+{
+ vg_info( "running script: s_compile_tools(void)\n" );
+
+ 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;
+ struct compile_result r1 = compile_tools( &proj, &env );
+
+ 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__/\\*");
+}
+
+void s_release_all(void)
+{
+ vg_info( "running script: s_release_all(void)\n" );
+
+ struct vg_project content_proj, windows_proj, linux_proj;
+
+ struct vg_compiler_env env = vg_release_env;
+ env.platform = k_platform_anyplatform;
+ 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, "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, "bin", "skaterift", &env, 1 );
+ build_game_bin( &linux_proj, &env );
+
+ /* package them up for storage */
+ vg_tarball_project( &content_proj );
+ vg_tarball_project( &linux_proj );
+ vg_tarball_project( &windows_proj );
+
+ /* extreme DRM solutions */
+ FILE *fp = fopen( "dist/bin/DRM", "w" );
+ fputs( "blibby!", fp );
+ fclose( fp );
+}
+
+void s_testing_build(void)
+{
+ vg_info( "running script: s_testing_build(void)\n" );
+
+ struct vg_project test_proj;
+ vg_project_init( &test_proj, "bin", "skaterift-test", NULL, 0 );
+
+ build_game_bin( &test_proj, &vg_test_env );
+ build_game_content( &test_proj );
+ vg_add_blob( &test_proj, "steam_appid.txt", "" );
+}
+
+void s_testing_server(void)
+{
+ vg_info( "running script: s_testing_server(void)\n" );
+
+ struct vg_project 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[] )
+{
+ 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_long_opt( "testing-server" ) )
+ s_testing_server();
+
+ if( vg_long_opt( "tools" ) )
+ s_compile_tools();
+
+ if( vg_opt('r') )
+ vg_test_env.optimization = 3;
+ }
+
+ vg_success( "All scripts completed\n" );