From bd3fb4a1324228b768bfa1f34ab4ce12539eb45b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 19 May 2018 09:18:29 +0200 Subject: Add manifest{} target type ('manifest' file name automatically mapped as such) --- build2/target.cxx | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'build2/target.cxx') diff --git a/build2/target.cxx b/build2/target.cxx index 201bd15..13db67e 100644 --- a/build2/target.cxx +++ b/build2/target.cxx @@ -1035,4 +1035,48 @@ namespace build2 &file_search, false }; + + static const char* + manifest_target_extension (const target_key& tk) + { + // If the name is special 'manifest', then there is no extension, + // otherwise it is .manifest. + // + return *tk.name == "manifest" ? "" : "manifest"; + } + + static bool + manifest_target_pattern (const target_type&, + const scope&, + string& v, + bool r) + { + size_t p (path::traits::find_extension (v)); + + if (r) + { + assert (p != string::npos); + v.resize (p); + } + else if (p == string::npos && v != "manifest") + { + v += ".manifest"; + return true; + } + + return false; + } + + const target_type manifest::static_type + { + "manifest", + &doc::static_type, + &target_factory, + &manifest_target_extension, + nullptr, /* default_extension */ + &manifest_target_pattern, + nullptr, + &file_search, + false + }; } -- cgit v1.1