diff options
Diffstat (limited to 'src')
7 files changed, 66 insertions, 1 deletions
diff --git a/src/buildtool/build_engine/analysed_target/analysed_target.hpp b/src/buildtool/build_engine/analysed_target/analysed_target.hpp index b661e24a..5867e77e 100644 --- a/src/buildtool/build_engine/analysed_target/analysed_target.hpp +++ b/src/buildtool/build_engine/analysed_target/analysed_target.hpp @@ -37,6 +37,7 @@ class AnalysedTarget { std::vector<Tree::Ptr> trees, std::unordered_set<std::string> vars, std::set<std::string> tainted, + std::set<std::string> implied_export_targets, TargetGraphInformation graph_information) : result_{std::move(result)}, actions_{std::move(actions)}, @@ -44,6 +45,7 @@ class AnalysedTarget { trees_{std::move(trees)}, vars_{std::move(vars)}, tainted_{std::move(tainted)}, + implied_export_targets_{std::move(implied_export_targets)}, graph_information_{std::move(graph_information)} {} [[nodiscard]] auto Actions() const& noexcept @@ -100,6 +102,13 @@ class AnalysedTarget { [[nodiscard]] auto Tainted() && noexcept -> std::set<std::string> { return std::move(tainted_); } + [[nodiscard]] auto ImpliedExport() const& noexcept + -> std::set<std::string> const& { + return implied_export_targets_; + } + [[nodiscard]] auto ImpliedExport() && noexcept -> std::set<std::string> { + return std::move(implied_export_targets_); + } [[nodiscard]] auto Result() const& noexcept -> TargetResult const& { return result_; } @@ -125,6 +134,7 @@ class AnalysedTarget { std::vector<Tree::Ptr> trees_; std::unordered_set<std::string> vars_; std::set<std::string> tainted_; + std::set<std::string> implied_export_targets_; TargetGraphInformation graph_information_; }; diff --git a/src/buildtool/build_engine/base_maps/source_map.cpp b/src/buildtool/build_engine/base_maps/source_map.cpp index 0453657a..242e546a 100644 --- a/src/buildtool/build_engine/base_maps/source_map.cpp +++ b/src/buildtool/build_engine/base_maps/source_map.cpp @@ -39,6 +39,7 @@ auto as_target(const BuildMaps::Base::EntityName& key, ExpressionPtr artifact) std::vector<Tree::Ptr>{}, std::unordered_set<std::string>{}, std::set<std::string>{}, + std::set<std::string>{}, TargetGraphInformation::kSource); } diff --git a/src/buildtool/build_engine/target_map/absent_target_map.cpp b/src/buildtool/build_engine/target_map/absent_target_map.cpp index 6ccf1672..1aac6443 100644 --- a/src/buildtool/build_engine/target_map/absent_target_map.cpp +++ b/src/buildtool/build_engine/target_map/absent_target_map.cpp @@ -120,6 +120,7 @@ auto BuildMaps::Target::CreateAbsentTargetMap( std::unordered_set<std::string>{flexible_vars->begin(), flexible_vars->end()}, std::set<std::string>{}, + entry.ToImplied(), deps_info); analysis_result = result_map->Add(key.target, 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 6732fd1e..19a12105 100644 --- a/src/buildtool/build_engine/target_map/built_in_rules.cpp +++ b/src/buildtool/build_engine/target_map/built_in_rules.cpp @@ -171,6 +171,12 @@ void BlobGenRuleWithDeps( } } + std::set<std::string> implied_export{}; + for (auto const& dep : dependency_values) { + implied_export.insert((*dep)->ImpliedExport().begin(), + (*dep)->ImpliedExport().end()); + } + auto name_exp = desc->ReadOptionalExpression( "name", ExpressionPtr{std::string{"out.txt"}}); if (not name_exp) { @@ -233,6 +239,7 @@ void BlobGenRuleWithDeps( std::vector<Tree::Ptr>{}, std::move(vars_set), std::move(tainted), + std::move(implied_export), std::move(deps_info)); analysis_result = result_map->Add(key.target, effective_conf, std::move(analysis_result)); @@ -399,6 +406,12 @@ void TreeRuleWithDeps( } } + std::set<std::string> implied_export{}; + for (auto const& dep : dependency_values) { + implied_export.insert((*dep)->ImpliedExport().begin(), + (*dep)->ImpliedExport().end()); + } + auto vars_set = std::unordered_set<std::string>{}; vars_set.insert(param_vars->begin(), param_vars->end()); for (auto const& dep : dependency_values) { @@ -460,6 +473,7 @@ void TreeRuleWithDeps( std::move(trees), std::move(vars_set), std::move(tainted), + std::move(implied_export), std::move(deps_info)); analysis_result = result_map->Add(key.target, effective_conf, std::move(analysis_result)); @@ -616,6 +630,13 @@ void InstallRuleWithDeps( } } + // Compute implied export targets + std::set<std::string> implied_export{}; + for (auto const& dep : dependency_values) { + implied_export.insert((*dep)->ImpliedExport().begin(), + (*dep)->ImpliedExport().end()); + } + // Stage deps (runfiles only) auto stage = ExpressionPtr{Expression::map_t{}}; for (auto const& dep : deps) { @@ -700,6 +721,7 @@ void InstallRuleWithDeps( std::vector<Tree::Ptr>{}, std::move(effective_vars), std::move(tainted), + std::move(implied_export), std::move(deps_info)); result = result_map->Add(key.target, effective_conf, std::move(result)); @@ -951,6 +973,13 @@ void GenericRuleWithDeps( } } + // Compute implied export targets + std::set<std::string> implied_export{}; + for (auto const& dep : dependency_values) { + implied_export.insert((*dep)->ImpliedExport().begin(), + (*dep)->ImpliedExport().end()); + } + // Evaluate cmd, outs, env auto string_fields_fcts = FunctionMap::MakePtr(FunctionMap::underlying_map_t{ @@ -1277,6 +1306,7 @@ void GenericRuleWithDeps( std::vector<Tree::Ptr>{}, std::move(effective_vars), std::move(tainted), + std::move(implied_export), std::move(deps_info)); result = result_map->Add(key.target, effective_conf, std::move(result)); @@ -1487,7 +1517,8 @@ void ConfigureRule( std::vector<std::string>{}, std::vector<Tree::Ptr>{}, std::move(vars_set), - std::set<std::string>{}, + tainted, + configured_target->ImpliedExport(), std::move(deps_info)); analysis_result = result_map->Add(key.target, std::move(effective_conf), diff --git a/src/buildtool/build_engine/target_map/export.cpp b/src/buildtool/build_engine/target_map/export.cpp index 50238b26..a2215411 100644 --- a/src/buildtool/build_engine/target_map/export.cpp +++ b/src/buildtool/build_engine/target_map/export.cpp @@ -65,6 +65,13 @@ void FinalizeExport( std::unordered_set<std::string> vars_set{}; vars_set.insert(vars.begin(), vars.end()); + std::set<std::string> implied{}; + if (target_cache_key) { + implied.insert((*value)->ImpliedExport().begin(), + (*value)->ImpliedExport().end()); + implied.insert(target_cache_key->Id().digest.hash()); + } + auto analysis_result = std::make_shared<AnalysedTarget const>( TargetResult{.artifact_stage = (*value)->Artifacts(), .provides = provides, @@ -74,6 +81,7 @@ void FinalizeExport( std::vector<Tree::Ptr>{}, std::move(vars_set), std::set<std::string>{}, + std::move(implied), std::move(deps_info)); analysis_result = result_map->Add(target, effective_config, @@ -151,6 +159,7 @@ void ExportRule( std::unordered_set<std::string>{flexible_vars->begin(), flexible_vars->end()}, std::set<std::string>{}, + entry.ToImplied(), deps_info); analysis_result = result_map->Add(key.target, diff --git a/src/buildtool/build_engine/target_map/target_map.cpp b/src/buildtool/build_engine/target_map/target_map.cpp index ebb07a91..5ca46c93 100644 --- a/src/buildtool/build_engine/target_map/target_map.cpp +++ b/src/buildtool/build_engine/target_map/target_map.cpp @@ -297,6 +297,13 @@ void withDependencies( } } + // Compute implied export targets + std::set<std::string> implied_export{}; + for (auto const& dep : dependency_values) { + implied_export.insert((*dep)->ImpliedExport().begin(), + (*dep)->ImpliedExport().end()); + } + // Evaluate string parameters auto string_fields_fcts = FunctionMap::MakePtr(FunctionMap::underlying_map_t{ @@ -849,6 +856,7 @@ void withDependencies( std::move(trees), std::move(effective_vars), std::move(tainted), + std::move(implied_export), deps_info); analysis_result = result_map->Add(key.target, effective_conf, std::move(analysis_result)); @@ -1371,6 +1379,7 @@ void withTargetNode( {}, {}, {}, + {}, TargetGraphInformation::kSource})); } else { @@ -1472,6 +1481,7 @@ void TreeTarget( std::vector<Tree::Ptr>{}, std::unordered_set<std::string>{}, std::set<std::string>{}, + std::set<std::string>{}, TargetGraphInformation::kSource); analysis_result = result_map->Add(key.target, {}, std::move(analysis_result)); @@ -1557,6 +1567,7 @@ void TreeTarget( std::vector<Tree::Ptr>{tree}, std::unordered_set<std::string>{}, std::set<std::string>{}, + std::set<std::string>{}, TargetGraphInformation::kSource); analysis_result = result_map->Add( key.target, {}, std::move(analysis_result)); @@ -1590,6 +1601,7 @@ void GlobResult(const std::vector<AnalysedTargetPtr const*>& values, std::vector<Tree::Ptr>{}, std::unordered_set<std::string>{}, std::set<std::string>{}, + std::set<std::string>{}, TargetGraphInformation::kSource); (*setter)(std::move(target)); } diff --git a/src/buildtool/main/analyse.cpp b/src/buildtool/main/analyse.cpp index 8b69daeb..19656b81 100644 --- a/src/buildtool/main/analyse.cpp +++ b/src/buildtool/main/analyse.cpp @@ -126,6 +126,7 @@ void DetectAndReportPending(std::string const& name, target->Trees(), target->Vars(), target->Tainted(), + target->ImpliedExport(), target->GraphInformation()); } |