build scripts
[fishladder.git] / build.c
1 #include "vg/vg_platform.h"
2 #include "vg/vg_log.h"
3 #include "vg/vg_opt.h"
4 #include "vg/vg_build.h"
5 #include "vg/vg_build_utils_shader.h"
6 #include "vg/vg_msg.h"
7
8 u32 optimize_test_compile = 0;
9
10 /*
11 * Compilation specifications
12 * -------------------------------------------------------------------------- */
13
14 void build_game_content( struct vg_project *proj )
15 {
16 vg_project_new_target( proj, "Content files", k_obj_type_none );
17 vg_symlink( proj, "textures_qoi", "textures" );
18 vg_symlink( proj, "maps", "maps" );
19 vg_symlink( proj, "sound", "sound" );
20 vg_syscall( "mkdir -p bin/%s/cfg", proj->uid.buffer );
21 vg_syscall( "mkdir -p bin/%s/sav", proj->uid.buffer );
22 }
23
24 void build_shaders(void);
25 void build_game_bin( struct vg_project *proj )
26 {
27 static int meta = 0;
28 if( !meta ){
29 meta = 1;
30 build_shaders();
31 vg_low( "\n\n" );
32 }
33
34 vg_project_new_target( proj, "fishladder", k_obj_type_exe );
35 vg_add_engine( proj, &(struct vg_engine_config)
36 {
37 .fixed_update_hz = 60,
38 .legacy_support_vg_msg1 = 0,
39 .log_source_info = 1,
40 .steam_api = 1,
41 .use_3d = 0,
42 .custom_game_settings = 1,
43 .custom_shaders = 1
44 });
45
46 vg_add_source( proj, "marblecomp.c" );
47 vg_compile_project( proj );
48 }
49
50 /*
51 * Scripts
52 * -------------------------------------------------------------------------- */
53
54 void s_release_all(void){
55 vg_info( "running script: s_release_all(void)\n" );
56
57 struct vg_project linux_proj, windows_proj;
58
59 struct vg_env env = vg_release_env;
60 env.platform = k_platform_linux;
61 vg_project_init( &linux_proj, &env, "marblecomp" );
62 build_game_content( &linux_proj );
63 build_game_bin( &linux_proj );
64
65 env = vg_release_env;
66 env.platform = k_platform_windows;
67 vg_project_init( &windows_proj, &env, "marblecomp" );
68 build_game_content( &windows_proj );
69 build_game_bin( &windows_proj );
70
71 vg_tarball_project( &linux_proj );
72 vg_tarball_project( &windows_proj );
73 }
74
75 void s_testing_build(void){
76 vg_info( "running script: s_testing_build(void)\n" );
77
78 struct vg_project test_proj;
79 vg_project_init( &test_proj, &vg_test_env, "marblecomp-test" );
80
81 build_game_content( &test_proj );
82 build_game_bin( &test_proj );
83 }
84
85 int main( int argc, char *argv[] ){
86 char *arg;
87 while( vg_argp( argc, argv ) ){
88 if( vg_long_opt( "release-all" ) )
89 s_release_all();
90
91 if( vg_long_opt( "testing-build" ) )
92 s_testing_build();
93
94 if( vg_opt('r') )
95 vg_test_env.optimization = 3;
96 }
97
98 vg_success( "All scripts ran successfully\n" );
99 }
100
101 #define _S( NAME, VS, FS ) \
102 vg_build_shader( "shaders/" VS, "shaders/" FS, NULL, "shaders", NAME )
103
104 void build_shaders(void){
105 vg_info( "Compiling shader headers\n" );
106 vg_shader_set_include_dir( "shaders" );
107
108 /* Scene */
109 _S( "tile_colour", "tile_colour.vs.glsl", "tile_colour.fs.glsl" );
110 _S( "tile_main", "tile_main.vs.glsl", "tile_main.fs.glsl" );
111 _S( "ball", "ball.vs.glsl", "ball.fs.glsl" );
112 _S( "background", "background.vs.glsl", "background.fs.glsl" );
113 _S( "wire", "wire.vs.glsl", "wire.fs.glsl" );
114 _S( "button", "button.vs.glsl", "button.fs.glsl" );
115 _S( "sprite", "sprite.vs.glsl", "sprite.fs.glsl" );
116 _S( "post_darken", "post_darken.vs.glsl", "post_darken.fs.glsl" );
117 _S( "post_comp", "post_comp.vs.glsl", "post_comp.fs.glsl" );
118 _S( "post_blur", "post_blur.vs.glsl", "post_blur.fs.glsl" );
119
120 vg_build_shader_impl( "shaders/impl.c" );
121 }