diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2023-04-10 14:28:23 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2023-04-10 14:28:23 +0200 |
commit | 1308eb0d740a687161641d52dabad8c0f849db08 (patch) | |
tree | d44ae8e001db5c54f0b619616d04efe2706a207e | |
parent | 74d42005e25e4a3c8356d44010b82a206b8aa7e6 (diff) |
Add support for negation in config.install.filter
-rw-r--r-- | doc/manual.cli | 22 | ||||
-rw-r--r-- | libbuild2/install/utility.cxx | 22 | ||||
-rw-r--r-- | libbuild2/install/utility.hxx | 2 |
3 files changed, 33 insertions, 13 deletions
diff --git a/doc/manual.cli b/doc/manual.cli index 101493c..7f6b730 100644 --- a/doc/manual.cli +++ b/doc/manual.cli @@ -6328,14 +6328,20 @@ modifier to only apply to symlink filesystem entries. For example: $ b config.install.filter='\"*.so\"@false,symlink' \ -Note that this mechanism only affects what gets physically copied to the -installation directory without affecting what gets built for install or the -view of what gets installed at the \c{buildfile} level. For example, -given the \c{include/@false *.a@false} filters, static libraries will still be -built (unless arranged not to with \c{config.bin.lib}) and the \c{pkg-config} -files will still end up with \c{-I} options pointing to the header -installation directory. Note also that this mechanism applies to both -\c{install} and \c{uninstall} operations. +A filter can be negated by specifying \c{!} as the first pair. For example: + +\ +$ b install config.install.filter='! include/@false \"*.a\"@false' +\ + +Note that the filtering mechanism only affects what gets physically copied to +the installation directory without affecting what gets built for install or +the view of what gets installed at the \c{buildfile} level. For example, given +the \c{include/@false *.a@false} filters, static libraries will still be built +(unless arranged not to with \c{config.bin.lib}) and the \c{pkg-config} files +will still end up with \c{-I} options pointing to the header installation +directory. Note also that this mechanism applies to both \c{install} and +\c{uninstall} operations. \N|If you are familiar with the Debian or Fedora packaging, this mechanism is somewhat similar to (and can be used for a similar purpose as) the Debian's diff --git a/libbuild2/install/utility.cxx b/libbuild2/install/utility.cxx index c8e1699..c8b6a92 100644 --- a/libbuild2/install/utility.cxx +++ b/libbuild2/install/utility.cxx @@ -57,10 +57,21 @@ namespace build2 // If redoing all this work for every entry proves too slow, we can // consider some form of caching (e.g., on the per-project basis). // + auto i (fs->begin ()); + + bool negate (false); + if (i->first == "!") + { + negate = true; + ++i; + } + size_t limit (0); // See below. - for (const pair<string, string>& kv: *fs) + for (auto e (fs->end ()); i != e; ++i) { + const pair<string, optional<string>>& kv (*i); + path k; try { @@ -77,7 +88,7 @@ namespace build2 bool v; { - const string& s (kv.second); + const string& s (kv.second ? *kv.second : string ()); size_t p (s.find (',')); @@ -269,13 +280,16 @@ namespace build2 } } + if (negate) + v = !v; + l4 ([&]{trace << (base / leaf) << (v ? " included by " : " excluded by ") - << kv.first << '@' << kv.second;}); + << kv.first << '@' << *kv.second;}); return v; } - return true; + return !negate; } } } diff --git a/libbuild2/install/utility.hxx b/libbuild2/install/utility.hxx index dca8eb4..fc40ebe 100644 --- a/libbuild2/install/utility.hxx +++ b/libbuild2/install/utility.hxx @@ -113,7 +113,7 @@ namespace build2 // // If entry type is a directory, then leaf must be empty. // - using filters = vector<pair<string, string>>; + using filters = vector<pair<string, optional<string>>>; LIBBUILD2_SYMEXPORT bool filter_entry (const scope& rs, |