aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2026-03-13 23:02:44 +0100
committerGitHub Enterprise <[email protected]>2026-03-13 23:02:44 +0100
commit95febbd1e2b52bae870685591a163e9f0f75f7d5 (patch)
tree5422165add51d987bbee7de6265a1da0a1ba32a2
parentMerge branch 'main' into sb/builds-subcmds (diff)
parentMade CPR optional, html generated at build time (#840) (diff)
downloadzen-sb/builds-subcmds.tar.xz
zen-sb/builds-subcmds.zip
Merge branch 'main' into sb/builds-subcmdssb/builds-subcmds
-rw-r--r--.gitignore4
-rw-r--r--CLAUDE.md4
-rw-r--r--scripts/updatefrontend.lua111
-rw-r--r--src/zencore/include/zencore/logbase.h2
-rw-r--r--src/zenhttp/httpclient.cpp19
-rw-r--r--src/zenhttp/include/zenhttp/cprutils.h22
-rw-r--r--src/zenhttp/include/zenhttp/httpclient.h2
-rw-r--r--src/zenhttp/xmake.lua7
-rw-r--r--src/zenserver/frontend/html.zipbin431365 -> 0 bytes
-rw-r--r--src/zenserver/xmake.lua48
-rw-r--r--src/zenstore/xmake.lua7
-rw-r--r--xmake.lua21
12 files changed, 100 insertions, 147 deletions
diff --git a/.gitignore b/.gitignore
index 0aa028930..5c9195566 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,6 +6,7 @@
.DS_Store
.claude/settings.local.json
.profile/
+.xwin-cache/
# User-specific files
*.suo
@@ -112,3 +113,6 @@ CMake*
# Ue tool chain temp directory
.tmp-ue-toolchain/
+
+# Generated frontend zip (built automatically by xmake)
+src/zenserver/frontend/html.zip
diff --git a/CLAUDE.md b/CLAUDE.md
index 32c4b3d40..45a9bddce 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -173,7 +173,7 @@ The codebase is organized into layered modules with clear dependencies:
- Web UI bundled as ZIP in `src/zenserver/frontend/*.zip`
- Dashboards for hub, orchestrator, and compute services are located in `src/zenserver/frontent/html/`
- These are the files which end up being bundled into the front-end zip mentioned above
-- Update with `xmake updatefrontend` after modifying HTML/JS, and check in the resulting zip
+- The zip is generated automatically at build time when source files change
**Memory Management:**
- Can use mimalloc or rpmalloc for performance
@@ -309,6 +309,4 @@ When debugging zenserver-test or other multi-process scenarios, use child proces
# Create deployable ZIP bundle
xmake bundle
-# Update frontend ZIP after HTML changes
-xmake updatefrontend
```
diff --git a/scripts/updatefrontend.lua b/scripts/updatefrontend.lua
deleted file mode 100644
index ab37819d7..000000000
--- a/scripts/updatefrontend.lua
+++ /dev/null
@@ -1,111 +0,0 @@
--- Copyright Epic Games, Inc. All Rights Reserved.
-
---------------------------------------------------------------------------------
-local function _exec(cmd, ...)
- local args = {}
- for _, arg in pairs({...}) do
- if arg then
- table.insert(args, arg)
- end
- end
-
- print("--", cmd, table.unpack(args))
- local ret = os.execv(cmd, args)
- print()
- return ret
-end
-
---------------------------------------------------------------------------------
-local function _zip(store_only, zip_path, ...)
- -- Here's the rules; if len(...) is 1 and it is a dir then create a zip with
- -- archive paths like this;
- --
- -- glob(foo/bar/**) -> foo/bar/abc, foo/bar/dir/123 -> zip(abc, dir/123)
- --
- -- Otherwise assume ... is file paths and add without leading directories;
- --
- -- foo/abc, bar/123 -> zip(abc, 123)
-
- zip_path = path.absolute(zip_path)
- os.tryrm(zip_path)
-
- local inputs = {...}
-
- local source_dir = nil
- if #inputs == 1 and os.isdir(inputs[1]) then
- source_dir = inputs[1]
- end
-
- import("detect.tools.find_7z")
- local cmd_7z = find_7z()
- if cmd_7z then
- input_paths = {}
- if source_dir then
- -- Suffixing a directory path with a "/." will have 7z set the path
- -- for archived files relative to that directory.
- input_paths = { path.join(source_dir, ".") }
- else
- for _, input_path in pairs(inputs) do
- -- If there is a "/./" anywhere in file paths then 7z drops all
- -- directory information and just archives the file by name
- input_path = path.relative(input_path, ".")
- if input_path:sub(2,2) ~= ":" then
- input_path = "./"..input_path
- end
- table.insert(input_paths, input_path)
- end
- end
-
- compression_level = "-mx1"
- if store_only then
- compression_level = "-mx0"
- end
-
- local ret = _exec(cmd_7z, "a", compression_level, zip_path, table.unpack(input_paths))
- if ret > 0 then
- raise("Received error from 7z")
- end
- return
- end
-
- print("7z not found, falling back to zip")
-
- import("detect.tools.find_zip")
- zip_cmd = find_zip()
- if zip_cmd then
- local input_paths = inputs
- local cwd = os.curdir()
- if source_dir then
- os.cd(source_dir)
- input_paths = { "." }
- end
-
- compression_level = "-1"
- if store_only then
- compression_level = "-0"
- end
-
- local strip_leading_path = nil
- if not source_dir then
- strip_leading_path = "--junk-paths"
- end
-
- local ret = _exec(zip_cmd, "-r", compression_level, strip_leading_path, zip_path, table.unpack(input_paths))
- if ret > 0 then
- raise("Received error from zip")
- end
-
- os.cd(cwd)
- return
- end
- print("zip not found")
-
- raise("Unable to find a suitable zip tool")
-end
-
---------------------------------------------------------------------------------
-function main()
- local zip_path = "src/zenserver/frontend/html.zip"
- local content_dir = "src/zenserver/frontend/html/"
- _zip(true, zip_path, content_dir)
-end
diff --git a/src/zencore/include/zencore/logbase.h b/src/zencore/include/zencore/logbase.h
index ad2ab218d..046e96db3 100644
--- a/src/zencore/include/zencore/logbase.h
+++ b/src/zencore/include/zencore/logbase.h
@@ -101,7 +101,7 @@ struct LoggerRef
inline logging::Logger* operator->() const;
inline logging::Logger& operator*() const;
- bool ShouldLog(logging::LogLevel Level) const { return m_Logger->ShouldLog(Level); }
+ bool ShouldLog(logging::LogLevel Level) const { return m_Logger && m_Logger->ShouldLog(Level); }
void SetLogLevel(logging::LogLevel NewLogLevel) { m_Logger->SetLevel(NewLogLevel); }
logging::LogLevel GetLogLevel() { return m_Logger->GetLevel(); }
diff --git a/src/zenhttp/httpclient.cpp b/src/zenhttp/httpclient.cpp
index deeeb6c85..9f49802a0 100644
--- a/src/zenhttp/httpclient.cpp
+++ b/src/zenhttp/httpclient.cpp
@@ -36,15 +36,17 @@
namespace zen {
+#if ZEN_WITH_CPR
extern HttpClientBase* CreateCprHttpClient(std::string_view BaseUri,
const HttpClientSettings& ConnectionSettings,
std::function<bool()>&& CheckIfAbortFunction);
+#endif
extern HttpClientBase* CreateCurlHttpClient(std::string_view BaseUri,
const HttpClientSettings& ConnectionSettings,
std::function<bool()>&& CheckIfAbortFunction);
-static HttpClientBackend g_DefaultHttpClientBackend = HttpClientBackend::kCpr;
+static HttpClientBackend g_DefaultHttpClientBackend = HttpClientBackend::kCurl;
void
SetDefaultHttpClientBackend(HttpClientBackend Backend)
@@ -55,11 +57,14 @@ SetDefaultHttpClientBackend(HttpClientBackend Backend)
void
SetDefaultHttpClientBackend(std::string_view Backend)
{
+#if ZEN_WITH_CPR
if (Backend == "cpr")
{
g_DefaultHttpClientBackend = HttpClientBackend::kCpr;
}
- else if (Backend == "curl")
+ else
+#endif
+ if (Backend == "curl")
{
g_DefaultHttpClientBackend = HttpClientBackend::kCurl;
}
@@ -363,13 +368,15 @@ HttpClient::HttpClient(std::string_view BaseUri, const HttpClientSettings& Conne
switch (EffectiveBackend)
{
- case HttpClientBackend::kCurl:
- m_Inner = CreateCurlHttpClient(BaseUri, ConnectionSettings, std::move(CheckIfAbortFunction));
- break;
+#if ZEN_WITH_CPR
case HttpClientBackend::kCpr:
- default:
m_Inner = CreateCprHttpClient(BaseUri, ConnectionSettings, std::move(CheckIfAbortFunction));
break;
+#endif
+ case HttpClientBackend::kCurl:
+ default:
+ m_Inner = CreateCurlHttpClient(BaseUri, ConnectionSettings, std::move(CheckIfAbortFunction));
+ break;
}
}
diff --git a/src/zenhttp/include/zenhttp/cprutils.h b/src/zenhttp/include/zenhttp/cprutils.h
index c252a5d99..3cfe652c5 100644
--- a/src/zenhttp/include/zenhttp/cprutils.h
+++ b/src/zenhttp/include/zenhttp/cprutils.h
@@ -2,17 +2,19 @@
#pragma once
-#include <zencore/compactbinary.h>
-#include <zencore/compactbinaryvalidation.h>
-#include <zencore/iobuffer.h>
-#include <zencore/string.h>
-#include <zenhttp/formatters.h>
-#include <zenhttp/httpclient.h>
-#include <zenhttp/httpcommon.h>
+#if ZEN_WITH_CPR
+
+# include <zencore/compactbinary.h>
+# include <zencore/compactbinaryvalidation.h>
+# include <zencore/iobuffer.h>
+# include <zencore/string.h>
+# include <zenhttp/formatters.h>
+# include <zenhttp/httpclient.h>
+# include <zenhttp/httpcommon.h>
ZEN_THIRD_PARTY_INCLUDES_START
-#include <cpr/response.h>
-#include <fmt/format.h>
+# include <cpr/response.h>
+# include <fmt/format.h>
ZEN_THIRD_PARTY_INCLUDES_END
template<>
@@ -92,3 +94,5 @@ struct fmt::formatter<cpr::Response>
}
}
};
+
+#endif // ZEN_WITH_CPR
diff --git a/src/zenhttp/include/zenhttp/httpclient.h b/src/zenhttp/include/zenhttp/httpclient.h
index e95d78772..e878c900f 100644
--- a/src/zenhttp/include/zenhttp/httpclient.h
+++ b/src/zenhttp/include/zenhttp/httpclient.h
@@ -52,7 +52,9 @@ enum class HttpClientErrorCode : int
enum class HttpClientBackend : uint8_t
{
kDefault,
+#if ZEN_WITH_CPR
kCpr,
+#endif
kCurl,
};
diff --git a/src/zenhttp/xmake.lua b/src/zenhttp/xmake.lua
index 9b461662e..b4c65ea96 100644
--- a/src/zenhttp/xmake.lua
+++ b/src/zenhttp/xmake.lua
@@ -8,7 +8,12 @@ target('zenhttp')
add_files("servers/httpsys.cpp", {unity_ignored=true})
add_files("servers/wshttpsys.cpp", {unity_ignored=true})
add_includedirs("include", {public=true})
- add_deps("zencore", "zentelemetry", "transport-sdk", "asio", "cpr")
+ add_deps("zencore", "zentelemetry", "transport-sdk", "asio")
+ if has_config("zencpr") then
+ add_deps("cpr")
+ else
+ remove_files("clients/httpclientcpr.cpp")
+ end
add_packages("http_parser", "json11")
add_options("httpsys")
diff --git a/src/zenserver/frontend/html.zip b/src/zenserver/frontend/html.zip
deleted file mode 100644
index 58778a592..000000000
--- a/src/zenserver/frontend/html.zip
+++ /dev/null
Binary files differ
diff --git a/src/zenserver/xmake.lua b/src/zenserver/xmake.lua
index 3cfaa956d..52889fff5 100644
--- a/src/zenserver/xmake.lua
+++ b/src/zenserver/xmake.lua
@@ -12,12 +12,14 @@ 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("frontend/html.zip")
add_files("zenserver.cpp", {unity_ignored = true })
if is_plat("linux") and not (get_config("toolchain") or ""):find("clang") then
@@ -78,7 +80,45 @@ 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 zip_path = path.join(os.projectdir(), "src/zenserver/frontend/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 frontend zip...")
+ os.tryrm(zip_path)
+
+ import("detect.tools.find_7z")
+ local cmd_7z = find_7z()
+ if cmd_7z then
+ os.execv(cmd_7z, {"a", "-mx0", 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", "-0", zip_path, "."})
+ os.cd(oldir)
+ else
+ raise("Unable to find a suitable zip tool (need 7z or zip)")
+ end
+ end
+ 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)
diff --git a/src/zenstore/xmake.lua b/src/zenstore/xmake.lua
index ea8155e94..94c2b51ca 100644
--- a/src/zenstore/xmake.lua
+++ b/src/zenstore/xmake.lua
@@ -6,6 +6,11 @@ target('zenstore')
add_headerfiles("**.h")
add_files("**.cpp")
add_includedirs("include", {public=true})
- add_deps("zencore", "zentelemetry", "zenutil", "zenvfs")
+ add_deps("zencore", "zentelemetry", "zenutil")
+ if is_plat("windows") then
+ add_deps("zenvfs")
+ else
+ add_includedirs("$(projectdir)/src/zenvfs/include", {public=true})
+ end
add_deps("robin-map")
add_packages("eastl", {public=true});
diff --git a/xmake.lua b/xmake.lua
index 6e7b22b1d..561f9f399 100644
--- a/xmake.lua
+++ b/xmake.lua
@@ -310,6 +310,13 @@ option("zentrace")
option_end()
add_define_by_config("ZEN_WITH_TRACE", "zentrace")
+option("zencpr")
+ set_default(true)
+ set_showmenu(true)
+ set_description("Enable CPR HTTP client backend")
+option_end()
+add_define_by_config("ZEN_WITH_CPR", "zencpr")
+
set_warnings("allextra", "error")
set_languages("cxx20")
@@ -352,7 +359,9 @@ end
includes("src/zenstore", "src/zenstore-test")
includes("src/zentelemetry", "src/zentelemetry-test")
includes("src/zenutil", "src/zenutil-test")
-includes("src/zenvfs")
+if is_plat("windows") then
+ includes("src/zenvfs")
+end
includes("src/zenserver", "src/zenserver-test")
includes("src/zen")
includes("src/zentest-appstub")
@@ -390,16 +399,6 @@ task("kill")
end
end)
-task("updatefrontend")
- set_menu {
- usage = "xmake updatefrontend",
- description = "Create Zip of the frontend/html folder for bundling with zenserver executable",
- }
- on_run(function()
- import("scripts.updatefrontend")
- updatefrontend()
- end)
-
task("precommit")
set_menu {
usage = "xmake precommit",