create command line packing utility
This commit is contained in:
parent
427e2f1998
commit
dd10686721
@ -653,7 +653,7 @@ i32 W32_Main(void)
|
|||||||
//~ CRT main
|
//~ CRT main
|
||||||
|
|
||||||
#if IsConsoleApp
|
#if IsConsoleApp
|
||||||
int main(char **argc, int argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
return W32_Main();
|
return W32_Main();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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 (lane->idx == 0)
|
||||||
{
|
{
|
||||||
if (M.cmdline.target_compiler == M_CompilerKind_Msvc)
|
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("-DIsUnoptimized=1"));
|
||||||
PushStringToList(perm, &cp.defs, Lit("-DIsRtcEnabled=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("-DIsAsanEnabled=0"));
|
||||||
PushStringToList(perm, &cp.defs, Lit("-DIsDebinfoEnabled=1"));
|
PushStringToList(perm, &cp.defs, Lit("-DIsDebinfoEnabled=1"));
|
||||||
PushStringToList(perm, &cp.defs, Lit("-DIsDeveloperModeEnabled=1"));
|
PushStringToList(perm, &cp.defs, Lit("-DIsDeveloperModeEnabled=1"));
|
||||||
|
|||||||
@ -140,6 +140,7 @@ Enum(M_CompilerKind)
|
|||||||
Struct(M_CommandLine)
|
Struct(M_CommandLine)
|
||||||
{
|
{
|
||||||
b32 release;
|
b32 release;
|
||||||
|
b32 console;
|
||||||
String leaf_layer_name;
|
String leaf_layer_name;
|
||||||
M_PlatformKind target_platform;
|
M_PlatformKind target_platform;
|
||||||
M_CompilerKind target_compiler;
|
M_CompilerKind target_compiler;
|
||||||
|
|||||||
75
src/pack/pack.c
Normal file
75
src/pack/pack.c
Normal file
@ -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);
|
||||||
|
}
|
||||||
2
src/pack/pack.h
Normal file
2
src/pack/pack.h
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
void PCK_Run(WaveLaneCtx *lane);
|
||||||
|
void PCK_Bootstrap(void);
|
||||||
18
src/pack/pack.lay
Normal file
18
src/pack/pack.lay
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
@Layer pack
|
||||||
|
|
||||||
|
//////////////////////////////
|
||||||
|
//- Dependencies
|
||||||
|
|
||||||
|
@Dep platform
|
||||||
|
|
||||||
|
//////////////////////////////
|
||||||
|
//- Api
|
||||||
|
|
||||||
|
@IncludeC pack.h
|
||||||
|
|
||||||
|
@Bootstrap PCK_Bootstrap
|
||||||
|
|
||||||
|
//////////////////////////////
|
||||||
|
//- Impl
|
||||||
|
|
||||||
|
@IncludeC pack.c
|
||||||
Loading…
Reference in New Issue
Block a user