Compare commits

...

3 Commits

Author SHA1 Message Date
229e0c8efd Fixed #2 2025-11-27 01:11:55 +01:00
a66f19190e Increased build speed
Instead of recompiling all of lunch source for each game, we generate
source files containing the `main` function and default configuration
for every game instead.
2025-11-27 00:44:48 +01:00
46abfdeead Report errors by default 2025-11-27 00:44:24 +01:00
8 changed files with 37 additions and 27 deletions

View File

@ -1,7 +1,7 @@
exec = executable(
'$name',
lunch_src + windows.compile_resources(files('resource.rc')),
files('main.d') + windows.compile_resources(files('resource.rc')),
include_directories: includes,
d_import_dirs: ['.'],
link_with: [lua, luad, toml]
link_with: [lunch, lua, luad, toml]
)

View File

@ -6,12 +6,12 @@ python3 = find_program('python3')
lunch_src = files(
'source/lunch/app.d',
'source/lunch/color.d',
'source/lunch/conf.d',
'source/lunch/http.d',
'source/lunch/launch.d',
'source/lunch/logger.d',
'source/lunch/main.d',
'source/lunch/ui.d',
'source/lunch/update.d',
)
@ -89,6 +89,7 @@ source = d_source + c_source
includes = include_directories('source')
lunch = static_library('lunch', lunch_src, include_directories: includes)
toml = static_library('toml', toml_src, include_directories: includes)
luad = static_library('luad', luad_src, include_directories: includes)
lua = static_library('lua', lua_src, include_directories: includes)

View File

@ -108,6 +108,20 @@ for dirent in os.listdir("config"):
"ICON\tICON\t\"icon.ico\""
])
# Generate source file
with open(pjoin(opath, "main.d"), "w") as file:
file.writelines([
"module main;\n",
"\n",
"import lunch.app;\n",
"\n",
"\n",
"void main()\n",
"{\n",
" app(import(\"config.toml\"));\n",
"}\n",
])
# Generate meson file
with open(pjoin(opath, "meson.build"), "w") as file:
file.write(meson_template.substitute(dict(flat_config)))

View File

@ -14,8 +14,11 @@ import lunch.update;
import lunch.launch;;
void app()
void _app(string config_toml)
{
// Load default config
wrapTOML(cast()config, config_toml.parseTOML());
// Focus on exe
chdir( thisExePath.dirName() );
@ -64,7 +67,7 @@ void app()
if (config.ui.config_dump)
{
options ~= () { writeFile(config.app.config_name, default_config_toml); };
options ~= () { writeFile(config.app.config_name, config_toml); };
writefln("[%d] %s", options.length, config.ui.config_dump_label);
}
@ -93,11 +96,11 @@ void app()
}
void main()
void app(string config_toml)
{
try
{
app();
_app(config_toml);
}
catch (Exception ex)
{

View File

@ -71,9 +71,7 @@ struct Config
}
immutable string default_config_toml = import("config.toml");
immutable Config default_config;
immutable Config config;
shared Config config;
private string dash2minus(string str)
@ -149,10 +147,3 @@ Config parseConfig(string toml) @safe
wrapTOML(config, doc);
return config;
}
shared static this()
{
default_config = cast(immutable)parseConfig(default_config_toml);
config = default_config;
}

View File

@ -10,6 +10,7 @@ import lunch.logger;
version (Windows)
{
pragma(lib, "User32");
import core.sys.windows.windows;
}
@ -75,7 +76,7 @@ void launch()
try
{
chdir(config.launcher.workdir);
Pid pid = spawnProcess(config.launcher.command);
Pid pid = spawnProcess(config.launcher.command.dup);
wait(pid);
}
catch (Exception ex)

View File

@ -25,14 +25,14 @@ private struct RemoteFile
string source;
string hash;
ulong size;
size_t mtime;
long mtime;
}
private struct Remote
{
string source;
ulong size;
size_t mtime;
long mtime;
RemoteFile[] files;
}
@ -40,7 +40,7 @@ private struct LocalFile
{
string file;
ulong size;
size_t mtime;
long mtime;
string hash() inout @property
{
@ -64,7 +64,7 @@ private struct LocalFile
private struct Local
{
ulong size;
size_t mtime;
long mtime;
LocalFile[] files;
}
@ -76,10 +76,10 @@ private struct Action
download,
}
What what;
What what;
string file;
string url;
size_t mtime;
long mtime;
alias this = what;
}
@ -228,7 +228,7 @@ private string workdir(string path)
}
private void touch(string path, size_t mtime = Clock.currTime().toUnixTime)
private void touch(string path, long mtime = Clock.currTime().toUnixTime)
{
infof("Touching %s", path);
SysTime old_atime, old_mtime;
@ -287,7 +287,7 @@ private immutable(Local) local()
loc.files ~= LocalFile(
file: entry.name.relativePath(workdir).replace('\\', '/'),
size: entry.size.to!uint,
size: entry.size.to!ulong,
mtime: entry.timeLastModified.toUnixTime,
);

View File

@ -3,7 +3,7 @@
talkative = false
# Error reporting
report-errors = false
report-errors = true
report-url = "https://arch.myddns.me/bin/"
# Allow loading external config