aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2022-07-21 11:54:59 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2022-07-21 11:54:59 +0200
commit3f6a5deac97cdf85186c6e1164ce6895eb38c36f (patch)
treebd085585d183177474b27b12a7eecfea9e547eb6
parent9c03dbab42d4499890955a98d30d91290d714d9a (diff)
Don't issue conditional dependency declaration warning for imported projects
-rw-r--r--libbuild2/dist/module.hxx1
-rw-r--r--libbuild2/dist/operation.cxx28
-rw-r--r--libbuild2/parser.cxx26
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<path> 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> (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 <libbuild2/adhoc-rule-regex-pattern.hxx>
+#include <libbuild2/dist/module.hxx> // module
+
#include <libbuild2/config/utility.hxx> // 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: <target>: <prerequisite>: include = (<condition>)";
+ // 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> (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: "
+ << "<target>: <prerequisite>: include = (<condition>)";
+ }
}
// First enter all the targets.