From 51ead7bc35b846da51753eacb06d3a631440afe1 Mon Sep 17 00:00:00 2001 From: Tomuxs Date: Fri, 2 May 2025 15:41:09 +0200 Subject: [PATCH] Organized build process --- config/meson.build | 9 +-------- config/template.build | 7 +++++++ postbuild.py | 19 +++++++++++++++++++ prebuild.py | 11 +++++++++-- 4 files changed, 36 insertions(+), 10 deletions(-) create mode 100644 config/template.build create mode 100644 postbuild.py diff --git a/config/meson.build b/config/meson.build index 3522d77..5a5dd3a 100644 --- a/config/meson.build +++ b/config/meson.build @@ -1,12 +1,5 @@ games = $games - foreach game : games - executable( - game, - lunch_src + windows.compile_resources(files(join_paths(game, 'resource.rc'))), - include_directories: includes, - d_import_dirs: [game], - link_with: [lua, luad, toml] - ) + subdir(game) endforeach \ No newline at end of file diff --git a/config/template.build b/config/template.build new file mode 100644 index 0000000..0541e9e --- /dev/null +++ b/config/template.build @@ -0,0 +1,7 @@ +exec = executable( + '$name', + lunch_src + windows.compile_resources(files('resource.rc')), + include_directories: includes, + d_import_dirs: ['.'], + link_with: [lua, luad, toml] +) \ No newline at end of file diff --git a/postbuild.py b/postbuild.py new file mode 100644 index 0000000..6e09003 --- /dev/null +++ b/postbuild.py @@ -0,0 +1,19 @@ +import os +import shutil + +if os.path.exists("launchers"): + shutil.rmtree("launchers") +os.mkdir("launchers") + +open("launchers/.gitignore", "w").write("*") + + +for game in os.listdir("build/games"): + path = os.path.join("build/games", game) + if not os.path.isdir(path): + continue + + shutil.copyfile( + os.path.join(path, game+".exe"), + os.path.join("launchers", game+".exe"), + ) \ No newline at end of file diff --git a/prebuild.py b/prebuild.py index 9201e53..857d6da 100644 --- a/prebuild.py +++ b/prebuild.py @@ -13,7 +13,10 @@ def read(filename: str) -> str: # Prepare `lunch` config template -template = string.Template(read("template.toml")) +config_template = string.Template(read("template.toml")) + +# Prepare `lunch` config template +meson_template = string.Template(read("config/template.build")) # Prepare games directory @@ -86,7 +89,7 @@ for dirent in os.listdir("config"): # Generate `lunch` config with open(pjoin(opath, "config.toml"), "w") as file: - file.write(template.substitute(dict(flat_config))) + file.write(config_template.substitute(dict(flat_config))) # Generate icon icon_png = pjoin(path, "icon.png") @@ -105,6 +108,10 @@ for dirent in os.listdir("config"): "ICON\tICON\t\"icon.ico\"" ]) + # Generate meson file + with open(pjoin(opath, "meson.build"), "w") as file: + file.write(meson_template.substitute(dict(flat_config))) + # Prepare meson configuration mesontemplate = string.Template(read("config/meson.build"))