From 3f6a5deac97cdf85186c6e1164ce6895eb38c36f Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 21 Jul 2022 11:54:59 +0200 Subject: Don't issue conditional dependency declaration warning for imported projects --- libbuild2/dist/module.hxx | 1 + libbuild2/dist/operation.cxx | 28 ++++++++++++++++++++++++++-- libbuild2/parser.cxx | 26 +++++++++++++++++++------- 3 files changed, 46 insertions(+), 9 deletions(-) diff --git a/libbuild2/dist/module.hxx b/libbuild2/dist/module.hxx index 314dc96..9c682d0 100644 --- a/libbuild2/dist/module.hxx +++ b/libbuild2/dist/module.hxx @@ -73,6 +73,7 @@ namespace build2 : var_dist_package (v_d_p) {} public: + bool distributed = false; // True if this project is being distributed. vector adhoc; struct callback diff --git a/libbuild2/dist/operation.cxx b/libbuild2/dist/operation.cxx index bce0823..87710d6 100644 --- a/libbuild2/dist/operation.cxx +++ b/libbuild2/dist/operation.cxx @@ -64,6 +64,30 @@ namespace build2 return o; } + static void + dist_load_load (const values& vs, + scope& rs, + const path& bf, + const dir_path& out_base, + const dir_path& src_base, + const location& l) + { + // @@ TMP: redo after release (do it here and not in execute, also add + // custom search and do the other half there). + // +#if 0 + if (rs.out_path () != out_base || rs.src_path () != src_base) + fail (l) << "dist meta-operation target must be project root directory"; +#endif + + // Mark this project as being distributed. + // + if (auto* m = rs.find_module (module::name)) + m->distributed = true; + + load (vs, rs, bf, out_base, src_base, l); + } + // Enter the specified source file as a target of type T. The path is // expected to be normalized and relative to src_root. If the third // argument is false, then first check if the file exists. If the fourth @@ -1037,7 +1061,7 @@ namespace build2 true, // bootstrap_outer nullptr, // meta-operation pre &dist_operation_pre, - &load, // normal load + &dist_load_load, &search, // normal search nullptr, // no match (see dist_execute()). &dist_load_execute, @@ -1073,7 +1097,7 @@ namespace build2 init_config (rs); } - void + static void dist_bootstrap_search (const values&, const scope& rs, const scope&, diff --git a/libbuild2/parser.cxx b/libbuild2/parser.cxx index dec23df..0ce0cfe 100644 --- a/libbuild2/parser.cxx +++ b/libbuild2/parser.cxx @@ -24,6 +24,8 @@ #include +#include // module + #include // lookup_config using namespace std; @@ -2385,13 +2387,23 @@ namespace build2 ctx->current_mif != nullptr && ctx->current_mif->id == dist_id) { - warn (tloc) << "conditional dependency declaration may result in " - << "incomplete distribution" << - info (ploc) << "prerequisite declared here" << - info (*condition_) << "conditional buildfile fragment starts here" << - info << "instead use 'include' prerequisite-specific variable to " - << "conditionally include prerequisites" << - info << "for example: : : include = ()"; + // Only issue the warning for the projects being distributed. In + // particular, this makes sure we don't complain about imported + // projects. + // + auto* dm (root_->find_module (dist::module::name)); + + if (dm != nullptr && dm->distributed) + { + warn (tloc) << "conditional dependency declaration may result in " + << "incomplete distribution" << + info (ploc) << "prerequisite declared here" << + info (*condition_) << "conditional buildfile fragment starts here" << + info << "instead use 'include' prerequisite-specific variable to " + << "conditionally include prerequisites" << + info << "for example: " + << ": : include = ()"; + } } // First enter all the targets. -- cgit v1.1