feat(daemon): clean generated build outputs on request
This commit is contained in:
1 parent
7fdda96553
commit
cf06b427b7
13 files changed
+198
-25
No files matched your search
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <Void/Build.hpp>
|
||||
#include <Void/Build/BootstrapConfig.hpp>
|
||||
#include <Void/Build/Config/BuildTree.hpp>
|
||||
#include <Void/Build/Config/Frontend.hpp>
|
||||
#include <Void/Build/Editor/CompDb.hpp>
|
||||
#include <Void/Build/Execution/Scheduler.hpp>
|
||||
@@ -1695,6 +1696,29 @@ DaemonServer::Impl::DispatchResult DaemonServer::Impl::dispatch(std::string_view
|
||||
if (*name == "ide_configs") {
|
||||
return {ide_configs_project(options), false};
|
||||
}
|
||||
if (*name == "clean") {
|
||||
bool all = false;
|
||||
if (const auto entry = object->find("all"); entry != object->end()) {
|
||||
const auto *value = std::get_if<bool>(&entry->second.value);
|
||||
if (value == nullptr) {
|
||||
return {error_response("\"all\" must be a boolean"), false};
|
||||
}
|
||||
all = *value;
|
||||
}
|
||||
auto cleaned = Config::clean_build_tree(options.build_root, all);
|
||||
if (!cleaned) {
|
||||
return {error_response(std::format("clean: {}", cleaned.error().format())), false};
|
||||
}
|
||||
JsonValue::Object cleaned_object;
|
||||
cleaned_object.emplace("ok", JsonValue{true});
|
||||
cleaned_object.emplace("op", JsonValue{std::string{"clean"}});
|
||||
cleaned_object.emplace("build_root", JsonValue{options.build_root.string()});
|
||||
cleaned_object.emplace("existed", JsonValue{cleaned->build_root_exists});
|
||||
cleaned_object.emplace("removed_all", JsonValue{cleaned->removed_entire_root});
|
||||
cleaned_object.emplace("removed_paths",
|
||||
JsonValue{static_cast<std::int64_t>(cleaned->removed_paths)});
|
||||
return {serialize_response(JsonValue{std::move(cleaned_object)}), false};
|
||||
}
|
||||
if (*name == "compdb_generations") {
|
||||
const auto entry = object->find("profile");
|
||||
if (entry == object->end()) {
|
||||
|
||||
Reference in new issue
Block a user