aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/file.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2020-06-09 07:40:54 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2020-06-09 07:40:54 +0200
commitb8cffb11a45add241e4b8420ba96e116efccfbd9 (patch)
tree70bc6987e60c7415b351111517a4bc7eea74f93c /libbuild2/file.cxx
parentdd1cb295722a049fe21c8d0311cb1823ccb0e508 (diff)
Make metadata variable prefix mandatory
While we could automatically set it if the target is imported, there is nothing we can do if the target is used in the same project. So to avoid confusion we make it mandatory.
Diffstat (limited to 'libbuild2/file.cxx')
-rw-r--r--libbuild2/file.cxx38
1 files changed, 10 insertions, 28 deletions
diff --git a/libbuild2/file.cxx b/libbuild2/file.cxx
index 4c7e6d9..e376ab9 100644
--- a/libbuild2/file.cxx
+++ b/libbuild2/file.cxx
@@ -2522,15 +2522,13 @@ namespace build2
if (meta)
{
- // The export.metadata value should start with the version optionally
- // followed by the metadata variable prefix. If the variable prefix is
- // missing, set it to the metadata key (i.e., target name as imported)
- // by default.
+ // The export.metadata value should start with the version followed by
+ // the metadata variable prefix.
//
- value& v (t.assign (*ctx.var_export_metadata));
- if (v && !v.empty ())
+ lookup l (t.vars[ctx.var_export_metadata]);
+ if (l && !l->empty ())
{
- names& ns (cast<names> (v));
+ const names& ns (cast<names> (l));
// First verify the version.
//
@@ -2540,7 +2538,7 @@ namespace build2
// Note: does not change the passed name.
//
ver = value_traits<uint64_t>::convert (
- move (ns[0]), ns[0].pair ? &ns[1] : nullptr);
+ ns[0], ns[0].pair ? &ns[1] : nullptr);
}
catch (const invalid_argument& e)
{
@@ -2552,27 +2550,11 @@ namespace build2
fail (loc) << "unexpected metadata version " << ver
<< " in imported target " << t;
- // Next see if we have the metadata variable prefix.
+ // Next verify the metadata variable prefix.
//
- switch (ns.size ())
- {
- case 1:
- {
- ns.push_back (name (*meta));
- break;
- }
- case 2:
- {
- if (ns[1].simple ())
- break;
- }
- // Fall through.
- default:
- {
- fail (loc) << "invalid metadata variable prefix in imported "
- << "target " << t;
- }
- }
+ if (ns.size () != 2 || !ns[1].simple ())
+ fail (loc) << "invalid metadata variable prefix in imported "
+ << "target " << t;
// See if we have the stable program name in the <var-prefix>.name
// variable. If its missing, set it to the metadata key (i.e., target