diff options
Diffstat (limited to 'src/zen/xmake.lua')
| -rw-r--r-- | src/zen/xmake.lua | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/src/zen/xmake.lua b/src/zen/xmake.lua index df249ade4..c4084231d 100644 --- a/src/zen/xmake.lua +++ b/src/zen/xmake.lua @@ -5,13 +5,57 @@ target("zen") add_headerfiles("**.h") add_files("**.cpp") add_files("zen.cpp", {unity_ignored = true }) + add_rules("utils.bin2c", {extensions = {".zip"}}) + add_files(path.join(os.projectdir(), get_config("builddir") or get_config("buildir") or "build", "zen-frontend/zen-html.zip")) add_deps("zencore", "zenhttp", "zenremotestore", "zenstore", "zenutil") add_deps("zencompute", "zennet", "zentelemetry") - add_deps("cxxopts", "fmt") + add_deps("cxxopts", "fmt", "raw_pdb", "tourist") add_packages("json11") add_includedirs(".") + add_defines("ZEN_EMBED_ZEN_HTML_ZIP=1") set_symbols("debug") + on_load(function(target) + local html_dir = path.join(os.projectdir(), "src/zen/frontend/html") + local zip_dir = path.join(os.projectdir(), get_config("builddir") or get_config("buildir") or "build", "zen-frontend") + local zip_path = path.join(zip_dir, "zen-html.zip") + + -- Check if zip needs regeneration + local need_update = not os.isfile(zip_path) + if not need_update then + local zip_mtime = os.mtime(zip_path) + for _, file in ipairs(os.files(path.join(html_dir, "**"))) do + if os.mtime(file) > zip_mtime then + need_update = true + break + end + end + end + + if need_update then + print("Regenerating zen trace viewer frontend zip...") + + os.tryrm(zip_path) + os.mkdir(zip_dir) + + import("detect.tools.find_7z") + local cmd_7z = find_7z() + if cmd_7z then + os.execv(cmd_7z, {"a", "-bso0", zip_path, path.join(html_dir, "*")}) + else + import("detect.tools.find_zip") + local zip_cmd = find_zip() + if zip_cmd then + local oldir = os.cd(html_dir) + os.execv(zip_cmd, {"-r", "-q", zip_path, "."}) + os.cd(oldir) + else + raise("Unable to find a suitable zip tool (need 7z or zip)") + end + end + end + end) + if is_plat("windows") then add_files("zen.rc") add_ldflags("/subsystem:console,5.02", {force = true}) |