diff options
Diffstat (limited to 'src/buildtool/common')
-rw-r--r-- | src/buildtool/common/action.hpp | 20 | ||||
-rw-r--r-- | src/buildtool/common/action_description.hpp | 13 |
2 files changed, 29 insertions, 4 deletions
diff --git a/src/buildtool/common/action.hpp b/src/buildtool/common/action.hpp index 13760422..e9d4581d 100644 --- a/src/buildtool/common/action.hpp +++ b/src/buildtool/common/action.hpp @@ -32,13 +32,15 @@ class Action { std::map<std::string, std::string> env_vars, std::optional<std::string> may_fail, bool no_cache, - double timeout_scale) + double timeout_scale, + std::map<std::string, std::string> execution_properties) : id_{std::move(action_id)}, command_{std::move(command)}, env_{std::move(env_vars)}, may_fail_{std::move(may_fail)}, no_cache_{no_cache}, - timeout_scale_{timeout_scale} {} + timeout_scale_{timeout_scale}, + execution_properties_{std::move(std::move(execution_properties))} {} Action(std::string action_id, std::vector<std::string> command, @@ -48,7 +50,8 @@ class Action { std::move(env_vars), std::nullopt, false, - 1.0) {} + 1.0, + std::map<std::string, std::string>{}) {} [[nodiscard]] auto Id() const noexcept -> ActionIdentifier { return id_; } @@ -77,6 +80,16 @@ class Action { [[nodiscard]] auto NoCache() const -> bool { return no_cache_; } [[nodiscard]] auto TimeoutScale() const -> double { return timeout_scale_; } + [[nodiscard]] auto ExecutionProperties() const& noexcept + -> std::map<std::string, std::string> { + return execution_properties_; + } + + [[nodiscard]] auto ExecutionProperties() && noexcept + -> std::map<std::string, std::string> { + return std::move(execution_properties_); + } + [[nodiscard]] static auto CreateTreeAction(ActionIdentifier const& id) -> Action { return Action{id}; @@ -90,6 +103,7 @@ class Action { std::optional<std::string> may_fail_{}; bool no_cache_{}; double timeout_scale_{}; + std::map<std::string, std::string> execution_properties_{}; explicit Action(ActionIdentifier id) : id_{std::move(id)}, is_tree_{true} {} }; diff --git a/src/buildtool/common/action_description.hpp b/src/buildtool/common/action_description.hpp index 9f4583bf..621e3a12 100644 --- a/src/buildtool/common/action_description.hpp +++ b/src/buildtool/common/action_description.hpp @@ -143,6 +143,13 @@ class ActionDescription { } timeout_scale = *timeout_scale_it; } + auto const execution_properties = + optional_key_value_reader(desc, "execution properties"); + if (not execution_properties.is_object()) { + Logger::Log(LogLevel::Error, + "Execution properties have to a map"); + return std::nullopt; + } return std::make_shared<ActionDescription>( std::move(*outputs), @@ -152,7 +159,8 @@ class ActionDescription { env, may_fail, no_cache, - timeout_scale}, + timeout_scale, + execution_properties}, inputs); } catch (std::exception const& ex) { Logger::Log( @@ -194,6 +202,9 @@ class ActionDescription { if (action_.TimeoutScale() != 1.0) { json["timeout scaling"] = action_.TimeoutScale(); } + if (not action_.ExecutionProperties().empty()) { + json["execution properties"] = action_.ExecutionProperties(); + } return json; } |