Open jml1795 opened 5 years ago
I like the idea. Ideally, this should work for string lists as well.
@nioncode I thought that at first as well but couldn't [quickly] come up with a compelling use case (since we don't do file globbing). Do you have an example? It should be trivial to implement in the string-list case if there is actually a good case for it.
I don't know one right now, but I'm sure I've seen this request pop up in various issues before.
Here's a use case, but for a list of files (could also be string objects, passed into file() later)
I have a build system which supports multiple architectures. There is a massive set of files which apply generally to all architectures. Each individual architecture has its own list of functions which need to be excluded.
Without filtering, I need to maintain a large number of "generic_files_but_not_for_XXX" lists, which is difficult to maintain and error prone.
An easier to maintain route would be to maintain the master list of generic files, and filter based on architecture/platform/machine to remove unsupported files.
Proposal: It is often useful to filter on a list to retrieve a subset, either by removing all items matching a regex (
filter_out
) or by keeping only those items that match a regex (filter
). This ticket is to discuss the addition of two functions to meson, specifically to theGeneratedListHolder
class (as returned by thegenerator.process()
method). Potentially, this would look like:Use Case: When generating C++ source code, we often produce both a
.hpp
and.cpp
file. The return ofgenerator.process(...)
is the complete set of code generated and there does not appear to be a mechanism to partition the resulting set into headers vs. cpp's, for example. This becomes particularly important when the generated headers need to be installed usinginstall_headers(...)
. From what I can tell there is not a work around to installing generated headers when they are contained in aGeneratedListHolder
instance holding more than just headers.The same problem exists when any subset (e.g. private headers) are to be installed vs all headers. Full filtering (vs
get_hpps()
andget_cpps()
methods for example) allow the user to decide exactly what they want installed with the addition of two functions.I made a test case demonstrating the problem on my fork
I am willing to implement this, but want to make sure this is something that is acceptable to the maintainers first. The main questions I have are: 1) Is this feature acceptable? 2) Should the filter methods be methods in the generated list holder class or free functions? 3) Any suggestions on naming etc?