diff --git a/src/base/base_win32/base_win32.c b/src/base/base_win32/base_win32.c index 861c8a38..963c0d08 100644 --- a/src/base/base_win32/base_win32.c +++ b/src/base/base_win32/base_win32.c @@ -653,7 +653,7 @@ i32 W32_Main(void) //~ CRT main #if IsConsoleApp - int main(char **argc, int argv) + int main(int argc, char **argv) { return W32_Main(); } diff --git a/src/meta/meta.c b/src/meta/meta.c index e8fa9660..cebfba0a 100644 --- a/src/meta/meta.c +++ b/src/meta/meta.c @@ -396,6 +396,15 @@ void M_BuildEntryPoint(WaveLaneCtx *lane) } } + // Subsystem + { + CommandlineArg arg = CommandlineArgFromName(Lit("console")); + if (arg.exists) + { + M.cmdline.console = 1; + } + } + if (lane->idx == 0) { if (M.cmdline.target_compiler == M_CompilerKind_Msvc) @@ -436,7 +445,16 @@ void M_BuildEntryPoint(WaveLaneCtx *lane) PushStringToList(perm, &cp.defs, Lit("-DIsUnoptimized=1")); PushStringToList(perm, &cp.defs, Lit("-DIsRtcEnabled=1")); } - PushStringToList(perm, &cp.defs, Lit("-DIsConsoleApp=0")); + + if (M.cmdline.console) + { + PushStringToList(perm, &cp.defs, Lit("-DIsConsoleApp=1")); + } + else + { + PushStringToList(perm, &cp.defs, Lit("-DIsConsoleApp=0")); + } + PushStringToList(perm, &cp.defs, Lit("-DIsAsanEnabled=0")); PushStringToList(perm, &cp.defs, Lit("-DIsDebinfoEnabled=1")); PushStringToList(perm, &cp.defs, Lit("-DIsDeveloperModeEnabled=1")); diff --git a/src/meta/meta.h b/src/meta/meta.h index ebba91fe..0344c58c 100644 --- a/src/meta/meta.h +++ b/src/meta/meta.h @@ -140,6 +140,7 @@ Enum(M_CompilerKind) Struct(M_CommandLine) { b32 release; + b32 console; String leaf_layer_name; M_PlatformKind target_platform; M_CompilerKind target_compiler; diff --git a/src/pack/pack.c b/src/pack/pack.c new file mode 100644 index 00000000..f34c81d8 --- /dev/null +++ b/src/pack/pack.c @@ -0,0 +1,75 @@ +void PCK_Run(WaveLaneCtx *lane) +{ + Arena *perm = PermArena(); + String src_path = StringFromCommandlineIdx(1); + String dst_path = StringFromCommandlineIdx(2); + + b32 ok = 1; + + StringList msgs = Zi; + + if (ok && !PLT_IsFile(src_path)) + { + ok = 0; + PushStringToList(perm, &msgs, (StringF( + perm, + "Source file \"%F\" not found", + FmtString(src_path) + ))); + } + + String src_data = Zi; + if (ok) + { + PLT_File file = PLT_OpenFileReadWait(src_path); + src_data = PLT_ReadFile(perm, file); + PLT_CloseFile(file); + } + + String packed = Zi; + if (ok) + { + packed = PLT_Compress(perm, src_data, PLT_CompressionLevel_3); + PLT_File file = PLT_OpenFileWrite(dst_path); + PLT_WriteFile(file, packed); + PLT_CloseFile(file); + } + + if (ok) + { + if (!PLT_IsFile(dst_path)) + { + ok = 0; + PushStringToList(perm, &msgs, (StringF( + perm, + "Failed to write to \"%F\"", + FmtString(dst_path) + ))); + } + else + { + f32 src_mb = (f32)src_data.len / 1024 / 1024; + f32 dst_mb = (f32)packed.len / 1024 / 1024; + + PushStringToList(perm, &msgs, (StringF( + perm, + "Packed \"%F\" -> \"%F\" (%FMib -> %FMib)", + FmtString(src_path), + FmtString(dst_path), + FmtFloat(src_mb, .p = 3), + FmtFloat(dst_mb, .p = 3) + ))); + } + } + + String msgs_str = StringFromList(perm, msgs, Lit("\n")); + Echo(msgs_str); + Echo(Lit("\n")); + + ExitNow(!ok); +} + +void PCK_Bootstrap(void) +{ + DispatchWave(Lit("Pack"), 1, PCK_Run, 0); +} diff --git a/src/pack/pack.h b/src/pack/pack.h new file mode 100644 index 00000000..abff00ba --- /dev/null +++ b/src/pack/pack.h @@ -0,0 +1,2 @@ +void PCK_Run(WaveLaneCtx *lane); +void PCK_Bootstrap(void); diff --git a/src/pack/pack.lay b/src/pack/pack.lay new file mode 100644 index 00000000..4ea68efc --- /dev/null +++ b/src/pack/pack.lay @@ -0,0 +1,18 @@ +@Layer pack + +////////////////////////////// +//- Dependencies + +@Dep platform + +////////////////////////////// +//- Api + +@IncludeC pack.h + +@Bootstrap PCK_Bootstrap + +////////////////////////////// +//- Impl + +@IncludeC pack.c