From f9e9d10bcb60b807466ddb646a9c0a0a447f7a20 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 15 Dec 2021 07:42:13 +0200 Subject: Return stable imported target name from import_direct() --- libbuild2/file.hxx | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'libbuild2/file.hxx') diff --git a/libbuild2/file.hxx b/libbuild2/file.hxx index 1c8e57e..b47d8dc 100644 --- a/libbuild2/file.hxx +++ b/libbuild2/file.hxx @@ -360,9 +360,19 @@ namespace build2 // The what argument specifies what triggered the import (for example, // "module load") and is used in diagnostics. // - // This function also returns the kind of import that was performed. + // This function also returns the stable exported target name (see + // target::as_name() for details) as well as the kind of import that was + // performed. // - pair + template + struct import_result + { + const T* target; + names name; + import_kind kind; + }; + + import_result import_direct (scope& base, name, bool phase2, @@ -376,7 +386,7 @@ namespace build2 // details. Note that a phase 2 fallback/default logic is not considered new // (though this can be easily adjusted based on import kind). // - LIBBUILD2_SYMEXPORT pair + LIBBUILD2_SYMEXPORT import_result import_direct (bool& new_value, scope& base, name, @@ -388,13 +398,13 @@ namespace build2 template - pair + import_result import_direct (scope&, name, bool, bool, bool, const location&, const char* = "import"); template - pair + import_result import_direct (bool&, scope&, name, @@ -406,7 +416,7 @@ namespace build2 // build system modules to print the configuration report. // LIBBUILD2_SYMEXPORT ostream& - operator<< (ostream&, const pair&); + operator<< (ostream&, const import_result&); // As import phase 2 but only imports as an already existing target. But // unlike it, this function can be called during the load and execute -- cgit v1.1