aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver
diff options
context:
space:
mode:
Diffstat (limited to 'src/zenserver')
-rw-r--r--src/zenserver/buildstore/buildstore.cpp75
-rw-r--r--src/zenserver/buildstore/buildstore.h30
-rw-r--r--src/zenserver/buildstore/httpbuildstore.cpp28
-rw-r--r--src/zenserver/buildstore/httpbuildstore.h28
-rw-r--r--src/zenserver/config.h1
-rw-r--r--src/zenserver/zenserver.cpp10
-rw-r--r--src/zenserver/zenserver.h2
7 files changed, 174 insertions, 0 deletions
diff --git a/src/zenserver/buildstore/buildstore.cpp b/src/zenserver/buildstore/buildstore.cpp
new file mode 100644
index 000000000..81dffc09c
--- /dev/null
+++ b/src/zenserver/buildstore/buildstore.cpp
@@ -0,0 +1,75 @@
+// Copyright Epic Games, Inc. All Rights Reserved.
+
+#include "buildstore.h"
+
+#include <zencore/testing.h>
+#include <zencore/testutils.h>
+
+#include <zencore/uid.h>
+#include <zencore/xxhash.h>
+
+namespace zen {
+
+BuildStore::BuildStore(BuildStoreConfig Config)
+{
+ const uint64_t MaxBlockSize = 256 * 1024 * 1024;
+ const uint64_t MaxBlockCount = 32 * 1024;
+ m_BlockStore.Initialize(Config.RootDirectory, MaxBlockSize, MaxBlockCount);
+}
+
+BuildStore::~BuildStore()
+{
+}
+
+// TODO: reconsider key size
+inline Oid
+IdFromKey(std::string_view Key)
+{
+ XXH3_128 Hash = XXH3_128::HashMemory(Key.data(), Key.size());
+
+ Oid Id;
+ memcpy(&Id.OidBits, Hash.Hash, sizeof Id);
+ return Id;
+}
+
+void
+BuildStore::Put(std::string_view Key, IoBuffer Value)
+{
+ ZEN_UNUSED(Key, Value);
+}
+
+IoBuffer
+BuildStore::Get(std::string_view Key)
+{
+ ZEN_UNUSED(Key);
+ return {};
+}
+
+/*
+ ___________ __
+ \__ ___/___ _______/ |_ ______
+ | |_/ __ \ / ___/\ __\/ ___/
+ | |\ ___/ \___ \ | | \___ \
+ |____| \___ >____ > |__| /____ >
+ \/ \/ \/
+*/
+
+#if ZEN_WITH_TESTS
+
+TEST_CASE("BuildStore")
+{
+ ScopedTemporaryDirectory _;
+
+ BuildStoreConfig Config;
+ Config.RootDirectory = _.Path() / "build_store";
+ BuildStore Store(Config);
+}
+
+void
+buildstore_forcelink()
+{
+}
+
+#endif
+
+} // namespace zen
diff --git a/src/zenserver/buildstore/buildstore.h b/src/zenserver/buildstore/buildstore.h
new file mode 100644
index 000000000..b2801fc7f
--- /dev/null
+++ b/src/zenserver/buildstore/buildstore.h
@@ -0,0 +1,30 @@
+
+// Copyright Epic Games, Inc. All Rights Reserved.
+
+#include <zenstore/blockstore.h>
+
+#include <filesystem>
+
+namespace zen {
+
+struct BuildStoreConfig
+{
+ std::filesystem::path RootDirectory;
+};
+
+class BuildStore
+{
+public:
+ BuildStore(BuildStoreConfig Config);
+ ~BuildStore();
+
+ void Put(std::string_view Key, IoBuffer Value);
+ IoBuffer Get(std::string_view Key);
+
+private:
+ BlockStore m_BlockStore;
+};
+
+void buildstore_forcelink();
+
+} // namespace zen
diff --git a/src/zenserver/buildstore/httpbuildstore.cpp b/src/zenserver/buildstore/httpbuildstore.cpp
new file mode 100644
index 000000000..1a0998c15
--- /dev/null
+++ b/src/zenserver/buildstore/httpbuildstore.cpp
@@ -0,0 +1,28 @@
+// Copyright Epic Games, Inc. All Rights Reserved.
+
+#include "httpbuildstore.h"
+
+namespace zen {
+
+HttpBuildStoreService::HttpBuildStoreService(BuildStoreConfig Cfg) : m_Config(Cfg)
+{
+ m_BuildStore = std::make_unique<BuildStore>(m_Config);
+}
+
+HttpBuildStoreService::~HttpBuildStoreService()
+{
+}
+
+const char*
+HttpBuildStoreService::HttpBuildStoreService::BaseUri() const
+{
+ return "/builds/";
+}
+
+void
+HttpBuildStoreService::HandleRequest(zen::HttpServerRequest& Request)
+{
+ ZEN_UNUSED(Request);
+}
+
+} // namespace zen
diff --git a/src/zenserver/buildstore/httpbuildstore.h b/src/zenserver/buildstore/httpbuildstore.h
new file mode 100644
index 000000000..d34035d0f
--- /dev/null
+++ b/src/zenserver/buildstore/httpbuildstore.h
@@ -0,0 +1,28 @@
+// Copyright Epic Games, Inc. All Rights Reserved.
+
+#pragma once
+
+#include "buildstore.h"
+
+#include <zenhttp/httpserver.h>
+
+#include <filesystem>
+
+namespace zen {
+
+class HttpBuildStoreService final : public zen::HttpService
+{
+public:
+ HttpBuildStoreService(BuildStoreConfig Cfg);
+ virtual ~HttpBuildStoreService();
+
+ virtual const char* BaseUri() const override;
+ virtual void HandleRequest(zen::HttpServerRequest& Request) override;
+
+private:
+ BuildStoreConfig m_Config;
+
+ std::unique_ptr<BuildStore> m_BuildStore;
+};
+
+} // namespace zen
diff --git a/src/zenserver/config.h b/src/zenserver/config.h
index c7781aada..d2965b819 100644
--- a/src/zenserver/config.h
+++ b/src/zenserver/config.h
@@ -172,6 +172,7 @@ struct ZenServerOptions
bool SentryAllowPII = false; // Allow personally identifiable information in sentry crash reports
bool Detach = true; // Whether zenserver should detach from existing process group (Mac/Linux)
bool ObjectStoreEnabled = false;
+ bool BuildStoreEnabled = false;
bool NoConsoleOutput = false; // Control default use of stdout for diagnostics
std::string Loggers[zen::logging::level::LogLevelCount];
std::string ScrubOptions;
diff --git a/src/zenserver/zenserver.cpp b/src/zenserver/zenserver.cpp
index f84bc0b00..ace8229d7 100644
--- a/src/zenserver/zenserver.cpp
+++ b/src/zenserver/zenserver.cpp
@@ -310,6 +310,15 @@ ZenServer::Initialize(const ZenServerOptions& ServerOptions, ZenServerState::Zen
m_Http->RegisterService(*m_ObjStoreService);
}
+ if (ServerOptions.BuildStoreEnabled)
+ {
+ BuildStoreConfig ObjCfg;
+ ObjCfg.RootDirectory = m_DataRoot / "builds";
+
+ m_BuildStoreService = std::make_unique<HttpBuildStoreService>(std::move(ObjCfg));
+ m_Http->RegisterService(*m_BuildStoreService);
+ }
+
#if ZEN_WITH_VFS
m_VfsService = std::make_unique<VfsService>();
m_VfsService->AddService(Ref<ProjectStore>(m_ProjectStore));
@@ -1056,6 +1065,7 @@ void
zenserver_forcelinktests()
{
zen::prj_forcelink();
+ zen::buildstore_forcelink();
}
#endif
diff --git a/src/zenserver/zenserver.h b/src/zenserver/zenserver.h
index 80054dc35..b698f001b 100644
--- a/src/zenserver/zenserver.h
+++ b/src/zenserver/zenserver.h
@@ -25,6 +25,7 @@ ZEN_THIRD_PARTY_INCLUDES_END
#include <zenstore/cache/structuredcachestore.h>
#include <zenstore/gc.h>
#include "admin/admin.h"
+#include "buildstore/httpbuildstore.h"
#include "cache/httpstructuredcache.h"
#include "diag/diagsvcs.h"
#include "frontend/frontend.h"
@@ -140,6 +141,7 @@ private:
HttpHealthService m_HealthService;
std::unique_ptr<HttpFrontendService> m_FrontendService;
std::unique_ptr<HttpObjectStoreService> m_ObjStoreService;
+ std::unique_ptr<HttpBuildStoreService> m_BuildStoreService;
std::unique_ptr<VfsService> m_VfsService;
std::unique_ptr<JobQueue> m_JobQueue;
std::unique_ptr<HttpAdminService> m_AdminService;