summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/buildtool/build_engine/target_map/TARGETS1
-rw-r--r--src/buildtool/build_engine/target_map/result_map.hpp3
-rw-r--r--src/buildtool/computed_roots/analyse_and_build.cpp6
-rw-r--r--src/buildtool/graph_traverser/TARGETS1
-rw-r--r--src/buildtool/graph_traverser/graph_traverser.cpp50
-rw-r--r--src/buildtool/graph_traverser/graph_traverser.hpp10
-rw-r--r--src/buildtool/main/main.cpp3
-rw-r--r--src/buildtool/serve_api/serve_service/target.cpp3
8 files changed, 62 insertions, 15 deletions
diff --git a/src/buildtool/build_engine/target_map/TARGETS b/src/buildtool/build_engine/target_map/TARGETS
index c2c865b5..5684f5c7 100644
--- a/src/buildtool/build_engine/target_map/TARGETS
+++ b/src/buildtool/build_engine/target_map/TARGETS
@@ -27,6 +27,7 @@
, ["src/buildtool/common", "common"]
, ["src/buildtool/common", "statistics"]
, ["src/buildtool/common", "tree"]
+ , ["src/buildtool/common", "tree_overlay"]
, ["src/buildtool/logging", "log_level"]
, ["src/buildtool/logging", "logging"]
, ["src/buildtool/multithreading", "task_system"]
diff --git a/src/buildtool/build_engine/target_map/result_map.hpp b/src/buildtool/build_engine/target_map/result_map.hpp
index 594ee3fe..6b5295c2 100644
--- a/src/buildtool/build_engine/target_map/result_map.hpp
+++ b/src/buildtool/build_engine/target_map/result_map.hpp
@@ -44,6 +44,7 @@
#include "src/buildtool/common/identifier.hpp"
#include "src/buildtool/common/statistics.hpp"
#include "src/buildtool/common/tree.hpp"
+#include "src/buildtool/common/tree_overlay.hpp"
#include "src/buildtool/logging/log_level.hpp"
#include "src/buildtool/logging/logger.hpp"
#include "src/buildtool/multithreading/task_system.hpp"
@@ -65,6 +66,7 @@ class ResultTargetMap {
std::vector<ActionDescription::Ptr> actions;
std::vector<std::string> blobs;
std::vector<Tree::Ptr> trees;
+ std::vector<TreeOverlay::Ptr> tree_overlays;
};
explicit ResultTargetMap(std::size_t jobs) : width_{ComputeWidth(jobs)} {}
@@ -442,6 +444,7 @@ struct ResultTargetMap::ResultType</*kIncludeOrigins=*/true> {
std::vector<ActionWithOrigin> actions;
std::vector<std::string> blobs;
std::vector<Tree::Ptr> trees;
+ std::vector<TreeOverlay::Ptr> tree_overlays;
};
} // namespace BuildMaps::Target
diff --git a/src/buildtool/computed_roots/analyse_and_build.cpp b/src/buildtool/computed_roots/analyse_and_build.cpp
index 05d37f5b..4f9dd1bf 100644
--- a/src/buildtool/computed_roots/analyse_and_build.cpp
+++ b/src/buildtool/computed_roots/analyse_and_build.cpp
@@ -54,8 +54,9 @@
auto const [artifacts, runfiles] =
ReadOutputArtifacts(analysis_result->target);
- auto [actions, blobs, trees] = analysis_result->result_map.ToResult(
- analyse_context->statistics, analyse_context->progress, logger);
+ auto [actions, blobs, trees, tree_overlays] =
+ analysis_result->result_map.ToResult(
+ analyse_context->statistics, analyse_context->progress, logger);
auto const cache_targets = analysis_result->result_map.CacheTargets();
@@ -74,6 +75,7 @@
std::move(actions),
std::move(blobs),
std::move(trees),
+ std::move(tree_overlays),
std::move(extra_artifacts));
if (not build_result) {
diff --git a/src/buildtool/graph_traverser/TARGETS b/src/buildtool/graph_traverser/TARGETS
index 520f7b0b..918cc272 100644
--- a/src/buildtool/graph_traverser/TARGETS
+++ b/src/buildtool/graph_traverser/TARGETS
@@ -12,6 +12,7 @@
, ["src/buildtool/common", "cli"]
, ["src/buildtool/common", "common"]
, ["src/buildtool/common", "tree"]
+ , ["src/buildtool/common", "tree_overlay"]
, ["src/buildtool/execution_engine/dag", "dag"]
, ["src/buildtool/execution_engine/executor", "context"]
, ["src/buildtool/logging", "logging"]
diff --git a/src/buildtool/graph_traverser/graph_traverser.cpp b/src/buildtool/graph_traverser/graph_traverser.cpp
index 4add7a17..14392d2a 100644
--- a/src/buildtool/graph_traverser/graph_traverser.cpp
+++ b/src/buildtool/graph_traverser/graph_traverser.cpp
@@ -60,6 +60,7 @@ auto GraphTraverser::BuildAndStage(
std::vector<ActionDescription::Ptr>&& action_descriptions,
std::vector<std::string>&& blobs,
std::vector<Tree::Ptr>&& trees,
+ std::vector<TreeOverlay::Ptr>&& tree_overlays,
std::vector<ArtifactDescription>&& extra_artifacts) const
-> std::optional<BuildResult> {
DependencyGraph graph; // must outlive artifact_nodes
@@ -68,6 +69,7 @@ auto GraphTraverser::BuildAndStage(
runfile_descriptions,
std::move(action_descriptions),
std::move(trees),
+ std::move(tree_overlays),
std::move(blobs),
extra_artifacts);
if (not artifacts) {
@@ -150,7 +152,7 @@ auto GraphTraverser::BuildAndStage(
if (not desc) {
return std::nullopt;
}
- auto [blobs, tree_descs, actions] = *std::move(desc);
+ auto [blobs, tree_descs, actions, tree_overlay_descs] = *std::move(desc);
HashFunction::Type const hash_type = context_.apis->local->GetHashType();
std::vector<ActionDescription::Ptr> action_descriptions{};
@@ -172,6 +174,15 @@ auto GraphTraverser::BuildAndStage(
trees.emplace_back(std::move(*tree));
}
+ std::vector<TreeOverlay::Ptr> tree_overlays{};
+ for (auto const& [id, description] : tree_overlay_descs.items()) {
+ auto tree_overlay = TreeOverlay::FromJson(hash_type, id, description);
+ if (not tree_overlay) {
+ return std::nullopt;
+ }
+ tree_overlays.emplace_back(std::move(*tree_overlay));
+ }
+
std::map<std::string, ArtifactDescription> artifact_descriptions{};
for (auto const& [rel_path, description] : artifacts.items()) {
auto artifact = ArtifactDescription::FromJson(hash_type, description);
@@ -185,14 +196,16 @@ auto GraphTraverser::BuildAndStage(
{},
std::move(action_descriptions),
std::move(blobs),
- std::move(trees));
+ std::move(trees),
+ std::move(tree_overlays));
}
auto GraphTraverser::ReadGraphDescription(
std::filesystem::path const& graph_description,
- Logger const* logger)
- -> std::optional<
- std::tuple<nlohmann::json, nlohmann::json, nlohmann::json>> {
+ Logger const* logger) -> std::optional<std::tuple<nlohmann::json,
+ nlohmann::json,
+ nlohmann::json,
+ nlohmann::json>> {
auto const graph_description_opt = Json::ReadFile(graph_description);
if (not graph_description_opt.has_value()) {
Logger::Log(logger,
@@ -225,11 +238,31 @@ auto GraphTraverser::ReadGraphDescription(
"graph description.",
s);
});
- if (not blobs_opt or not trees_opt or not actions_opt) {
+ std::optional<nlohmann::json> tree_overlays_opt;
+ if (graph_description_opt->contains("tree_overlays")) {
+ tree_overlays_opt = ExtractValueAs<nlohmann::json>(
+ *graph_description_opt,
+ "tree_overlays",
+ [logger](std::string const& s) {
+ Logger::Log(
+ logger,
+ LogLevel::Error,
+ "{}\ncan not retrieve value for \"tree_overlays\" from "
+ "graph description.",
+ s);
+ });
+ }
+ else {
+ tree_overlays_opt = nlohmann::json::object();
+ }
+ if (not blobs_opt or not trees_opt or not actions_opt or
+ not tree_overlays_opt) {
return std::nullopt;
}
- return std::make_tuple(
- std::move(*blobs_opt), std::move(*trees_opt), std::move(*actions_opt));
+ return std::make_tuple(std::move(*blobs_opt),
+ std::move(*trees_opt),
+ std::move(*actions_opt),
+ std::move(*tree_overlays_opt));
}
auto GraphTraverser::UploadBlobs(
@@ -404,6 +437,7 @@ auto GraphTraverser::BuildArtifacts(
std::map<std::string, ArtifactDescription> const& runfiles,
std::vector<ActionDescription::Ptr>&& actions,
std::vector<Tree::Ptr>&& trees,
+ std::vector<TreeOverlay::Ptr>&& /*tree_overlays*/,
std::vector<std::string>&& blobs,
std::vector<ArtifactDescription> const& extra_artifacts) const
-> std::optional<
diff --git a/src/buildtool/graph_traverser/graph_traverser.hpp b/src/buildtool/graph_traverser/graph_traverser.hpp
index 0958a507..a0214e69 100644
--- a/src/buildtool/graph_traverser/graph_traverser.hpp
+++ b/src/buildtool/graph_traverser/graph_traverser.hpp
@@ -35,6 +35,7 @@
#include "src/buildtool/common/cli.hpp"
#include "src/buildtool/common/identifier.hpp"
#include "src/buildtool/common/tree.hpp"
+#include "src/buildtool/common/tree_overlay.hpp"
#include "src/buildtool/execution_engine/dag/dag.hpp"
#include "src/buildtool/execution_engine/executor/context.hpp"
#include "src/buildtool/logging/logger.hpp"
@@ -81,6 +82,7 @@ class GraphTraverser {
std::vector<ActionDescription::Ptr>&& action_descriptions,
std::vector<std::string>&& blobs,
std::vector<Tree::Ptr>&& trees,
+ std::vector<TreeOverlay::Ptr>&& tree_overlays,
std::vector<ArtifactDescription>&& extra_artifacts = {}) const
-> std::optional<BuildResult>;
@@ -104,9 +106,10 @@ class GraphTraverser {
/// and the actions as a json object.
[[nodiscard]] static auto ReadGraphDescription(
std::filesystem::path const& graph_description,
- Logger const* logger)
- -> std::optional<
- std::tuple<nlohmann::json, nlohmann::json, nlohmann::json>>;
+ Logger const* logger) -> std::optional<std::tuple<nlohmann::json,
+ nlohmann::json,
+ nlohmann::json,
+ nlohmann::json>>;
/// \brief Requires for the executor to upload blobs to CAS. In the case any
/// of the uploads fails, execution is terminated
@@ -156,6 +159,7 @@ class GraphTraverser {
std::map<std::string, ArtifactDescription> const& runfiles,
std::vector<ActionDescription::Ptr>&& actions,
std::vector<Tree::Ptr>&& trees,
+ std::vector<TreeOverlay::Ptr>&& tree_overlays,
std::vector<std::string>&& blobs,
std::vector<ArtifactDescription> const& extra_artifacts = {}) const
-> std::optional<
diff --git a/src/buildtool/main/main.cpp b/src/buildtool/main/main.cpp
index 158b4a9b..75c7ca73 100644
--- a/src/buildtool/main/main.cpp
+++ b/src/buildtool/main/main.cpp
@@ -1215,7 +1215,7 @@ auto main(int argc, char* argv[]) -> int {
}
#ifndef BOOTSTRAP_BUILD_TOOL
ReportTaintedness(*analyse_result);
- auto [actions, blobs, trees] =
+ auto [actions, blobs, trees, tree_overlays] =
analyse_result->result_map.ToResult(&stats, &progress);
// collect cache targets and artifacts for target-level caching
@@ -1242,6 +1242,7 @@ auto main(int argc, char* argv[]) -> int {
std::move(actions),
std::move(blobs),
std::move(trees),
+ std::move(tree_overlays),
std::move(cache_artifacts));
dump_and_cleanup_thread.join();
if (build_result) {
diff --git a/src/buildtool/serve_api/serve_service/target.cpp b/src/buildtool/serve_api/serve_service/target.cpp
index 7b2641a2..cc51f1f8 100644
--- a/src/buildtool/serve_api/serve_service/target.cpp
+++ b/src/buildtool/serve_api/serve_service/target.cpp
@@ -572,7 +572,7 @@ auto TargetService::ServeTarget(
ReadOutputArtifacts(analyse_result->target);
// get the analyse_result map outputs
- auto [actions, blobs, trees] =
+ auto [actions, blobs, trees, tree_overlays] =
analyse_result->result_map.ToResult(&stats, &progress, &logger);
// collect cache targets and artifacts for target-level caching
@@ -591,6 +591,7 @@ auto TargetService::ServeTarget(
std::move(actions),
std::move(blobs),
std::move(trees),
+ std::move(tree_overlays),
std::move(cache_artifacts));
if (not build_result) {