diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/buildtool/build_engine/target_map/built_in_rules.cpp | 1 | ||||
-rw-r--r-- | src/buildtool/build_engine/target_map/target_map.cpp | 1 | ||||
-rw-r--r-- | src/buildtool/build_engine/target_map/utils.cpp | 5 | ||||
-rw-r--r-- | src/buildtool/build_engine/target_map/utils.hpp | 1 | ||||
-rw-r--r-- | src/buildtool/common/action.hpp | 11 | ||||
-rw-r--r-- | src/buildtool/common/action_description.hpp | 20 |
6 files changed, 34 insertions, 5 deletions
diff --git a/src/buildtool/build_engine/target_map/built_in_rules.cpp b/src/buildtool/build_engine/target_map/built_in_rules.cpp index 8133c5d3..5db35b41 100644 --- a/src/buildtool/build_engine/target_map/built_in_rules.cpp +++ b/src/buildtool/build_engine/target_map/built_in_rules.cpp @@ -1044,6 +1044,7 @@ void GenericRuleWithDeps( env_val, std::nullopt, false, + 1.0, inputs); auto action_identifier = action->Id(); Expression::map_t::underlying_map_t artifacts; diff --git a/src/buildtool/build_engine/target_map/target_map.cpp b/src/buildtool/build_engine/target_map/target_map.cpp index 2e788f7b..13825148 100644 --- a/src/buildtool/build_engine/target_map/target_map.cpp +++ b/src/buildtool/build_engine/target_map/target_map.cpp @@ -558,6 +558,7 @@ void withDependencies( env_exp, may_fail, no_cache, + 1.0, inputs_exp); auto action_id = action->Id(); actions.emplace_back(std::move(action)); diff --git a/src/buildtool/build_engine/target_map/utils.cpp b/src/buildtool/build_engine/target_map/utils.cpp index 9be742ec..24e0e8a7 100644 --- a/src/buildtool/build_engine/target_map/utils.cpp +++ b/src/buildtool/build_engine/target_map/utils.cpp @@ -194,6 +194,7 @@ auto BuildMaps::Target::Utils::createAction( const ExpressionPtr& env, std::optional<std::string> may_fail, bool no_cache, + double timeout_scale, const ExpressionPtr& inputs_exp) -> ActionDescription::Ptr { auto hasher = HashFunction::Hasher(); hasher.Update(hash_vector(output_files)); @@ -203,6 +204,7 @@ auto BuildMaps::Target::Utils::createAction( hasher.Update(hash_vector(may_fail ? std::vector<std::string>{*may_fail} : std::vector<std::string>{})); hasher.Update(no_cache ? std::string{"N"} : std::string{"Y"}); + hasher.Update(fmt::format("{:+24a}", timeout_scale)); hasher.Update(inputs_exp->ToHash()); auto action_id = std::move(hasher).Finalize().HexString(); @@ -222,6 +224,7 @@ auto BuildMaps::Target::Utils::createAction( std::move(command), std::move(env_vars), std::move(may_fail), - no_cache}, + no_cache, + timeout_scale}, std::move(inputs)); } diff --git a/src/buildtool/build_engine/target_map/utils.hpp b/src/buildtool/build_engine/target_map/utils.hpp index 5ae77890..28642c42 100644 --- a/src/buildtool/build_engine/target_map/utils.hpp +++ b/src/buildtool/build_engine/target_map/utils.hpp @@ -65,6 +65,7 @@ auto createAction(const ActionDescription::outputs_t& output_files, const ExpressionPtr& env, std::optional<std::string> may_fail, bool no_cache, + double timeout_scale, const ExpressionPtr& inputs_exp) -> ActionDescription::Ptr; } // namespace BuildMaps::Target::Utils diff --git a/src/buildtool/common/action.hpp b/src/buildtool/common/action.hpp index 1b109e58..13760422 100644 --- a/src/buildtool/common/action.hpp +++ b/src/buildtool/common/action.hpp @@ -31,12 +31,14 @@ class Action { std::vector<std::string> command, std::map<std::string, std::string> env_vars, std::optional<std::string> may_fail, - bool no_cache) + bool no_cache, + double timeout_scale) : id_{std::move(action_id)}, command_{std::move(command)}, env_{std::move(env_vars)}, may_fail_{std::move(may_fail)}, - no_cache_{no_cache} {} + no_cache_{no_cache}, + timeout_scale_{timeout_scale} {} Action(std::string action_id, std::vector<std::string> command, @@ -45,7 +47,8 @@ class Action { std::move(command), std::move(env_vars), std::nullopt, - false) {} + false, + 1.0) {} [[nodiscard]] auto Id() const noexcept -> ActionIdentifier { return id_; } @@ -72,6 +75,7 @@ class Action { return may_fail_; } [[nodiscard]] auto NoCache() const -> bool { return no_cache_; } + [[nodiscard]] auto TimeoutScale() const -> double { return timeout_scale_; } [[nodiscard]] static auto CreateTreeAction(ActionIdentifier const& id) -> Action { @@ -85,6 +89,7 @@ class Action { bool is_tree_{}; std::optional<std::string> may_fail_{}; bool no_cache_{}; + double timeout_scale_{}; 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 4146673e..9f4583bf 100644 --- a/src/buildtool/common/action_description.hpp +++ b/src/buildtool/common/action_description.hpp @@ -134,10 +134,25 @@ class ActionDescription { no_cache = *no_cache_it; } + double timeout_scale{1.0}; + auto timeout_scale_it = desc.find("timeout scaling"); + if (timeout_scale_it != desc.end()) { + if (not timeout_scale_it->is_number()) { + Logger::Log(LogLevel::Error, + "timeout scaling has to be a number"); + } + timeout_scale = *timeout_scale_it; + } + return std::make_shared<ActionDescription>( std::move(*outputs), std::move(*output_dirs), - Action{id, std::move(*command), env, may_fail, no_cache}, + Action{id, + std::move(*command), + env, + may_fail, + no_cache, + timeout_scale}, inputs); } catch (std::exception const& ex) { Logger::Log( @@ -176,6 +191,9 @@ class ActionDescription { if (action_.NoCache()) { json["no_cache"] = true; } + if (action_.TimeoutScale() != 1.0) { + json["timeout scaling"] = action_.TimeoutScale(); + } return json; } |