aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver/xmake.lua
diff options
context:
space:
mode:
Diffstat (limited to 'src/zenserver/xmake.lua')
-rw-r--r--src/zenserver/xmake.lua150
1 files changed, 137 insertions, 13 deletions
diff --git a/src/zenserver/xmake.lua b/src/zenserver/xmake.lua
index 9ab51beb2..b609d1050 100644
--- a/src/zenserver/xmake.lua
+++ b/src/zenserver/xmake.lua
@@ -12,42 +12,65 @@ target("zenserver")
"zenremotestore",
"zenstore",
"zentelemetry",
- "zenutil",
- "zenvfs")
+ "zenutil")
+ if is_plat("windows") then
+ add_deps("zenvfs")
+ end
add_headerfiles("**.h")
add_rules("utils.bin2c", {extensions = {".zip"}})
add_files("**.cpp")
- add_files("frontend/*.zip")
+ add_files(path.join(os.projectdir(), get_config("builddir") or get_config("buildir") or "build", "frontend/html.zip"))
add_files("zenserver.cpp", {unity_ignored = true })
+
+ if is_plat("linux") and not (get_config("toolchain") or ""):find("clang") then
+ -- GCC false positives in deeply inlined code (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100137)
+ add_files("storage/projectstore/httpprojectstore.cpp", {force = {cxxflags = "-Wno-stringop-overflow"} })
+ add_files("storage/storageconfig.cpp", {force = {cxxflags = "-Wno-array-bounds"} })
+ end
add_includedirs(".")
set_symbols("debug")
add_deps("protozero", "asio", "cxxopts")
add_deps("sol2")
+ add_packages("llhttp")
add_packages("json11")
+ add_packages("zlib")
add_packages("lua")
add_packages("consul")
+ add_packages("minio")
+ add_packages("oidctoken")
+ add_packages("nomad")
- if has_config("zenmimalloc") then
+ if has_config("zenmimalloc") and not use_asan then
add_packages("mimalloc")
end
- if has_config("zensentry") then
+ if has_config("zensentry") and not use_asan then
add_packages("sentry-native")
end
+ if has_config("zenhorde") then
+ add_deps("zenhorde")
+ end
+
+ if has_config("zennomad") then
+ add_deps("zennomad")
+ end
+
if is_mode("release") then
set_optimize("fastest")
end
if is_plat("windows") then
- add_ldflags("/subsystem:console,5.02")
- add_ldflags("/MANIFEST:EMBED")
- add_ldflags("/LTCG")
+ add_ldflags("/subsystem:console,5.02", {force = true})
+ add_ldflags("/MANIFEST:EMBED", {force = true})
+ if not (get_config("toolchain") or ""):find("clang") then
+ add_ldflags("/LTCG")
+ end
add_files("zenserver.rc")
add_cxxflags("/bigobj")
add_links("delayimp", "projectedfslib")
- add_ldflags("/delayload:ProjectedFSLib.dll")
+ add_ldflags("/delayload:ProjectedFSLib.dll", {force = true})
else
remove_files("windows/**")
end
@@ -61,7 +84,70 @@ target("zenserver")
add_ldflags("-framework SystemConfiguration")
end
- -- to work around some unfortunate Ctrl-C behaviour on Linux/Mac due to
+ 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")
+
+ -- 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)
+ -- 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...")
+
+ -- 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", "-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(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)
+
+ -- to work around some unfortunate Ctrl-C behaviour on Linux/Mac due to
-- our use of setsid() at startup we pass in `--no-detach` to zenserver
-- ensure that it recieves signals when the user requests termination
on_run(function(target)
@@ -81,11 +167,19 @@ target("zenserver")
table.insert(args, "--detach=false")
+ -- On Windows the ASAN runtime is a DLL whose directory must be on PATH;
+ -- runenvs.make collects that (and any other Windows package run envs).
+ local addenvs, setenvs
+ if is_host("windows") then
+ import("private.action.run.runenvs")
+ addenvs, setenvs = runenvs.make(target)
+ end
+
-- debugging?
if option.get("debug") then
- debugger.run(targetfile, args, {curdir = rundir})
+ debugger.run(targetfile, args, {curdir = rundir, addenvs = addenvs, setenvs = setenvs})
else
- os.execv(targetfile, args, {curdir = rundir, detach = option.get("detach")})
+ os.execv(targetfile, args, {curdir = rundir, detach = option.get("detach"), addenvs = addenvs, setenvs = setenvs})
end
end)
@@ -116,7 +210,7 @@ target("zenserver")
end
end
- if has_config("zensentry") then
+ if has_config("zensentry") and not target:policy("build.sanitizer.address") then
local pkg = target:pkg("sentry-native")
if pkg then
local installdir = pkg:installdir()
@@ -145,4 +239,34 @@ target("zenserver")
end
copy_if_newer(path.join(installdir, "bin", consul_bin), path.join(target:targetdir(), consul_bin), consul_bin)
end
+
+ local minio_pkg = target:pkg("minio")
+ if minio_pkg then
+ local installdir = minio_pkg:installdir()
+ local minio_bin = "minio"
+ if is_plat("windows") then
+ minio_bin = "minio.exe"
+ end
+ copy_if_newer(path.join(installdir, "bin", minio_bin), path.join(target:targetdir(), minio_bin), minio_bin)
+ end
+
+ local oidctoken_pkg = target:pkg("oidctoken")
+ if oidctoken_pkg then
+ local installdir = oidctoken_pkg:installdir()
+ local oidctoken_bin = "OidcToken"
+ if is_plat("windows") then
+ oidctoken_bin = "OidcToken.exe"
+ end
+ copy_if_newer(path.join(installdir, "bin", oidctoken_bin), path.join(target:targetdir(), oidctoken_bin), oidctoken_bin)
+ end
+
+ local nomad_pkg = target:pkg("nomad")
+ if nomad_pkg then
+ local installdir = nomad_pkg:installdir()
+ local nomad_bin = "nomad"
+ if is_plat("windows") then
+ nomad_bin = "nomad.exe"
+ end
+ copy_if_newer(path.join(installdir, "bin", nomad_bin), path.join(target:targetdir(), nomad_bin), nomad_bin)
+ end
end)