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.
This commit is contained in:
@ -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]
|
||||
)
|
||||
@ -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)
|
||||
|
||||
14
prebuild.py
14
prebuild.py
@ -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)))
|
||||
|
||||
@ -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)
|
||||
{
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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)
|
||||
|
||||
Reference in New Issue
Block a user