From bd2ba663855541d727588455b4905ffb19a51fc3 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 21 May 2023 09:06:57 +0200 Subject: Add support for dynamic target extraction in addition to prerequisites This functionality is enabled with the depdb-dyndep --dyn-target option. Only the make format is supported, where the listed targets are added as ad hoc group members (unless already specified as static members). This functionality is not available in the --byproduct mode. --- libbuild2/dyndep.hxx | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'libbuild2/dyndep.hxx') diff --git a/libbuild2/dyndep.hxx b/libbuild2/dyndep.hxx index a6f800e..6ae585e 100644 --- a/libbuild2/dyndep.hxx +++ b/libbuild2/dyndep.hxx @@ -94,6 +94,10 @@ namespace build2 // and those derived from them are considered. Otherwise, any file-based // type is considered but not the file type itself. // + // It's possible the extension-to-target type mapping is ambiguous (for + // example, because both C and C++-language headers use the same .h + // extension). So this function can return multiple target types. + // static small_vector map_extension (const scope& base, const string& name, const string& ext, @@ -244,6 +248,23 @@ namespace build2 return inject_group_member ( a, bs, g, move (p), T::static_type).template as (); } + + // Find or insert a target file path as a target, make it a member of the + // specified ad hoc group unless it already is, and set its path. Return + // the target and an indication of whether it was added as a member. + // + // The target type is determined using the map_extension function if + // specified, falling back to the fallback type if unable to. + // + // The file path must be absolute and normalized. Note that this function + // assumes that this target can only be known as a member of this group. + // + static pair + inject_adhoc_group_member (const char* what, + action, const scope& base, target& g, + path, + const function&, + const target_type& fallback); }; } -- cgit v1.1