diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2024-01-15 08:49:57 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2024-01-15 08:53:30 +0200 |
commit | 8a0ebb2b607c92b8c1bdab7e525da2b711b31565 (patch) | |
tree | 4556f7d33dd9fe22fe299b5466b3cb6a930ddfe1 /libbuild2/file.hxx | |
parent | 05ee8c20d83c2f108aa71a65e19b7adff8ff9aa0 (diff) |
Automatically alias unknown target types of imported targets
Diffstat (limited to 'libbuild2/file.hxx')
-rw-r--r-- | libbuild2/file.hxx | 31 |
1 files changed, 22 insertions, 9 deletions
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<names, import_kind> + template <typename T> + struct import_result + { + const T* target; // Note: T can be imported target or imported scope. + names name; + import_kind kind; + }; + + // Note that import_result<scope>::target may be NULL even if name is not + // empty (e.g, out of project target imported via phase 2). + // + LIBBUILD2_SYMEXPORT import_result<scope> import (scope& base, name, const optional<string>& phase2, @@ -409,14 +420,6 @@ namespace build2 // // Note: cannot be used to import buildfile targets (use import_buildfile() // instead). - // - template <typename T> - struct import_result - { - const T* target; - names name; - import_kind kind; - }; // Print import_direct<exe>() 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. // |