diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/buildtool/execution_engine/dag/TARGETS | 1 | ||||
-rw-r--r-- | src/buildtool/execution_engine/dag/dag.hpp | 35 | ||||
-rw-r--r-- | src/buildtool/execution_engine/executor/TARGETS | 1 | ||||
-rw-r--r-- | src/buildtool/execution_engine/executor/executor.hpp | 28 |
4 files changed, 33 insertions, 32 deletions
diff --git a/src/buildtool/execution_engine/dag/TARGETS b/src/buildtool/execution_engine/dag/TARGETS index ab0780c2..d7412ea6 100644 --- a/src/buildtool/execution_engine/dag/TARGETS +++ b/src/buildtool/execution_engine/dag/TARGETS @@ -11,7 +11,6 @@ , ["src/buildtool/logging", "log_level"] , ["src/buildtool/logging", "logging"] , ["src/utils/cpp", "hex_string"] - , ["src/utils/cpp", "transformed_range"] , ["src/utils/cpp", "type_safe_arithmetic"] ] , "stage": ["src", "buildtool", "execution_engine", "dag"] diff --git a/src/buildtool/execution_engine/dag/dag.hpp b/src/buildtool/execution_engine/dag/dag.hpp index cd6ef33f..e27e45c2 100644 --- a/src/buildtool/execution_engine/dag/dag.hpp +++ b/src/buildtool/execution_engine/dag/dag.hpp @@ -15,6 +15,7 @@ #ifndef INCLUDED_SRC_BUILDTOOL_EXECUTION_ENGINE_DAG_DAG_HPP #define INCLUDED_SRC_BUILDTOOL_EXECUTION_ENGINE_DAG_DAG_HPP +#include <algorithm> #include <atomic> #include <cstddef> #include <functional> @@ -36,7 +37,6 @@ #include "src/buildtool/logging/log_level.hpp" #include "src/buildtool/logging/logger.hpp" #include "src/utils/cpp/hex_string.hpp" -#include "src/utils/cpp/transformed_range.hpp" #include "src/utils/cpp/type_safe_arithmetic.hpp" /// \brief Plain DirectedAcyclicGraph. @@ -262,9 +262,6 @@ class DependencyGraph : DirectedAcyclicGraph { Action::LocalPath path; base::OtherNodePtr node; }; - using LocalPaths = - TransformedRange<std::vector<NamedOtherNodePtr>::const_iterator, - Action::LocalPath>; [[nodiscard]] static auto Create(Action const& content) noexcept -> Ptr { @@ -360,16 +357,19 @@ class DependencyGraph : DirectedAcyclicGraph { return Content().NoCache(); } - [[nodiscard]] auto OutputFilePaths() const& noexcept -> LocalPaths { - return NodePaths(&output_files_); + [[nodiscard]] auto OutputFilePaths() const& noexcept + -> std::vector<Action::LocalPath> { + return NodePaths(output_files_); } - [[nodiscard]] auto OutputDirPaths() const& noexcept -> LocalPaths { - return NodePaths(&output_dirs_); + [[nodiscard]] auto OutputDirPaths() const& noexcept + -> std::vector<Action::LocalPath> { + return NodePaths(output_dirs_); } - [[nodiscard]] auto DependencyPaths() const& noexcept -> LocalPaths { - return NodePaths(&dependencies_); + [[nodiscard]] auto DependencyPaths() const& noexcept + -> std::vector<Action::LocalPath> { + return NodePaths(dependencies_); } // To initialise the action traversal specific data before traversing @@ -391,12 +391,15 @@ class DependencyGraph : DirectedAcyclicGraph { std::make_unique<ActionNodeTraversalState>()}; [[nodiscard]] static auto NodePaths( - gsl::not_null<std::vector<NamedOtherNodePtr> const*> const& nodes) - -> LocalPaths { - return TransformedRange{ - nodes->begin(), - nodes->end(), - [](NamedOtherNodePtr const& node) { return node.path; }}; + std::vector<NamedOtherNodePtr> const& nodes) + -> std::vector<Action::LocalPath> { + std::vector<Action::LocalPath> paths{nodes.size()}; + std::transform( + nodes.cbegin(), + nodes.cend(), + paths.begin(), + [](auto const& named_node) { return named_node.path; }); + return paths; } }; diff --git a/src/buildtool/execution_engine/executor/TARGETS b/src/buildtool/execution_engine/executor/TARGETS index 523530ed..39cad1c0 100644 --- a/src/buildtool/execution_engine/executor/TARGETS +++ b/src/buildtool/execution_engine/executor/TARGETS @@ -36,7 +36,6 @@ , ["src/utils/cpp", "hex_string"] , ["src/utils/cpp", "path_rebase"] , ["src/utils/cpp", "prefix"] - , ["src/utils/cpp", "transformed_range"] ] , "stage": ["src", "buildtool", "execution_engine", "executor"] } diff --git a/src/buildtool/execution_engine/executor/executor.hpp b/src/buildtool/execution_engine/executor/executor.hpp index db204fe6..0ec7dfe6 100644 --- a/src/buildtool/execution_engine/executor/executor.hpp +++ b/src/buildtool/execution_engine/executor/executor.hpp @@ -69,7 +69,6 @@ #include "src/utils/cpp/hex_string.hpp" #include "src/utils/cpp/path_rebase.hpp" #include "src/utils/cpp/prefix.hpp" -#include "src/utils/cpp/transformed_range.hpp" /// \brief Implementations for executing actions and uploading artifacts. class ExecutorImpl { @@ -149,10 +148,10 @@ class ExecutorImpl { } auto base = action->Content().Cwd(); - auto cwd_relative_output_files = RebasePathStringsRelativeTo( - base, action->OutputFilePaths().ToVector()); - auto cwd_relative_output_dirs = RebasePathStringsRelativeTo( - base, action->OutputDirPaths().ToVector()); + auto cwd_relative_output_files = + RebasePathStringsRelativeTo(base, action->OutputFilePaths()); + auto cwd_relative_output_dirs = + RebasePathStringsRelativeTo(base, action->OutputDirPaths()); auto remote_action = (alternative_api ? *alternative_api : api) .CreateAction(*root_digest, action->Command(), @@ -554,7 +553,7 @@ class ExecutorImpl { /// are present in the artifacts map [[nodiscard]] static auto CheckOutputsExist( IExecutionResponse::ArtifactInfos const& artifacts, - DependencyGraph::ActionNode::LocalPaths const& outputs, + std::vector<Action::LocalPath> const& outputs, std::string base) noexcept -> bool { return std::all_of( outputs.begin(), @@ -617,13 +616,14 @@ class ExecutorImpl { return false; } + auto const output_files = action->OutputFilePaths(); + auto const output_dirs = action->OutputDirPaths(); + if (artifacts.value()->empty() or - not CheckOutputsExist(*artifacts.value(), - action->OutputFilePaths(), - action->Content().Cwd()) or - not CheckOutputsExist(*artifacts.value(), - action->OutputDirPaths(), - action->Content().Cwd())) { + not CheckOutputsExist( + *artifacts.value(), output_files, action->Content().Cwd()) or + not CheckOutputsExist( + *artifacts.value(), output_dirs, action->Content().Cwd())) { logger.Emit(LogLevel::Error, [&]() { std::ostringstream message{}; if (action_failed) { @@ -632,10 +632,10 @@ class ExecutorImpl { } message << "action executed with missing outputs.\nAction " "outputs should be the following artifacts:"; - for (auto const& output : action->OutputFilePaths()) { + for (auto const& output : output_files) { message << "\n - file: " << output; } - for (auto const& output : action->OutputDirPaths()) { + for (auto const& output : output_dirs) { message << "\n - dir: " << output; } return message.str(); |