From 8a0ebb2b607c92b8c1bdab7e525da2b711b31565 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 15 Jan 2024 08:49:57 +0200 Subject: Automatically alias unknown target types of imported targets --- libbuild2/file.hxx | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'libbuild2/file.hxx') diff --git a/libbuild2/file.hxx b/libbuild2/file.hxx index 68c284b..36e4c00 100644 --- a/libbuild2/file.hxx +++ b/libbuild2/file.hxx @@ -371,7 +371,18 @@ namespace build2 // enum class import_kind {adhoc, normal, fallback}; - LIBBUILD2_SYMEXPORT pair + template + struct import_result + { + const T* target; // Note: T can be imported target or imported scope. + names name; + import_kind kind; + }; + + // Note that import_result::target may be NULL even if name is not + // empty (e.g, out of project target imported via phase 2). + // + LIBBUILD2_SYMEXPORT import_result import (scope& base, name, const optional& phase2, @@ -409,14 +420,6 @@ namespace build2 // // Note: cannot be used to import buildfile targets (use import_buildfile() // instead). - // - template - struct import_result - { - const T* target; - names name; - import_kind kind; - }; // Print import_direct() result either as a target for a normal import // or as a process path for ad hoc and fallback imports. Normally used in @@ -518,6 +521,16 @@ namespace build2 bool metadata, const location&); + // Import (more precisely, alias as if using the `define =` syntax) the + // target type from imported project (iroot) into this project (root). If + // the target type with this name is already defined in this project, then + // make sure it is the same as in the imported project. + // + LIBBUILD2_SYMEXPORT const target_type& + import_target_type (scope& root, + const scope& iroot, const string&, + const location&); + // Suggest appropriate ways to import the specified target (as type and // name) from the specified project. // -- cgit v1.1