From c78f03ca550bfdcec1de4e2fd96a2604476374d7 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 9 Jun 2020 15:23:27 +0200 Subject: Make importation of unqualified targets illegal --- libbuild2/file.cxx | 15 +++++++++------ libbuild2/target.hxx | 4 ++++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/libbuild2/file.cxx b/libbuild2/file.cxx index f7073e6..e0467ad 100644 --- a/libbuild2/file.cxx +++ b/libbuild2/file.cxx @@ -1729,15 +1729,18 @@ namespace build2 { tracer trace ("import_search"); - // If there is no project specified for this target, then our run will be - // short and sweet: we simply return it as empty-project-qualified and - // let someone else (e.g., a rule) take a stab at it. + // Note: in the future the plan is to turn this into project-local import. // if (tgt.unqualified ()) - { - tgt.proj = project_name (); + fail (loc) << "importation of an unqualified target " << tgt << + info << "use empty project qualification to import a target " + << "without a project"; + + // If the project name is empty then we simply return it as is to let + // someone else (e.g., a rule, import phase 2) take a stab at it. + // + if (tgt.proj->empty ()) return make_pair (move (tgt), optional ()); - } context& ctx (ibase.ctx); diff --git a/libbuild2/target.hxx b/libbuild2/target.hxx index 2af389d..c2954f8 100644 --- a/libbuild2/target.hxx +++ b/libbuild2/target.hxx @@ -1260,6 +1260,10 @@ namespace build2 // map. The key's hash ignores the extension, so the hash will stay stable // across extension updates. // + // @@ TODO: we currently do not detect ambiguity if there are multiple merge + // candidates for a no-extension key. We could probably do it using the + // unordered_map::bucket() API. + // // Note also that once the extension is specified, it becomes immutable. // class LIBBUILD2_SYMEXPORT target_set -- cgit v1.1