diff options
Diffstat (limited to 'src/zenserver/xmake.lua')
| -rw-r--r-- | src/zenserver/xmake.lua | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/src/zenserver/xmake.lua b/src/zenserver/xmake.lua index aa306190f..c2c81e7aa 100644 --- a/src/zenserver/xmake.lua +++ b/src/zenserver/xmake.lua @@ -34,6 +34,7 @@ target("zenserver") add_deps("sol2") add_packages("http_parser") add_packages("json11") + add_packages("zlib") add_packages("lua") add_packages("consul") add_packages("minio") @@ -85,6 +86,7 @@ target("zenserver") on_load(function(target) local html_dir = path.join(os.projectdir(), "src/zenserver/frontend/html") + local docs_dir = path.join(os.projectdir(), "docs") local zip_dir = path.join(os.projectdir(), get_config("buildir") or "build", "frontend") local zip_path = path.join(zip_dir, "html.zip") @@ -92,34 +94,56 @@ target("zenserver") local need_update = not os.isfile(zip_path) if not need_update then local zip_mtime = os.mtime(zip_path) + -- Check html sources for _, file in ipairs(os.files(path.join(html_dir, "**"))) do if os.mtime(file) > zip_mtime then need_update = true break end end + -- Check docs sources (bundled as data/ in the zip) + if not need_update and os.isdir(docs_dir) then + for _, file in ipairs(os.files(path.join(docs_dir, "**"))) do + if os.mtime(file) > zip_mtime then + need_update = true + break + end + end + end end if need_update then print("Regenerating frontend zip...") - os.mkdir(zip_dir) + + -- Stage files in a temporary directory so docs/ appears as data/ in the zip + local staging_dir = path.join(zip_dir, "staging") + os.tryrm(staging_dir) + os.mkdir(staging_dir) + os.cp(path.join(html_dir, "*"), staging_dir) + if os.isdir(docs_dir) then + os.cp(docs_dir, path.join(staging_dir, "data")) + os.tryrm(path.join(staging_dir, "data", "dev")) + end + os.tryrm(zip_path) import("detect.tools.find_7z") local cmd_7z = find_7z() if cmd_7z then - os.execv(cmd_7z, {"a", "-mx0", "-bso0", zip_path, path.join(html_dir, ".")}) + os.execv(cmd_7z, {"a", "-bso0", zip_path, path.join(staging_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", "-0", "-q", zip_path, "."}) + local oldir = os.cd(staging_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 + + os.tryrm(staging_dir) end end) |