This module provides a type to select source files for build units in B0 files. To support generated source files, selections can depend on the build.
In a nutshell the declaration:
let srcs =
Fpath.[ `Dir (v "src-exe"); `Dir_rec (v "src"); `X (v "src/not.ml");
`X (v "src/not")]
instructs to:
Select all the files in directorysrc-exe.
Select all the files in the file hierarchy rooted at directory src.
Remove from the files found in directories the files whose paths segments are prefixed by src/not.ml and src/not.
Relative file paths are expressed relative to the build unit's scope directory.
The prefix relation for exclusions respects path segments boundaries. In the example any file whose path matches src/not.ml, src/not.ml/*, src/not or src/not/* is excluded from the selection. But for example src/not.c is not.
The relative order of directory selections and exclusions doesn't matter, the semantics is to select all the files via `Dir and `Dir_rec and then apply the exclusion `X on the resulting set. Exclusions affect only directory selections, not file `File and future `Futureselections.
When a directory is selected via `Dir or `Dir_rec, all its files are, modulo exclusions. It is expected that build units themselves filter the final result by file extension or additional mechanisms. Consult the documentation of build units for more information.
`File f unconditionaly selects the file f. f must exist and be a file.
`Dir d selects the files of directory d modulo `X exclusions. d must exist and be a directory. dotfile paths are ignored.
`Dir_rec d selects the files of the file hierarchy rooted at d modulo `X exclusions. d must exist and be a directory. dotfile paths are ignored.
`X x removes from directory selections any file whose path segments are prefixed by x, respecting segment boundaries. A potential trailing directory separators in x is removed.
`Fut f uses the given future during the build to determine a set of files unconditionally added to the selection. FIXME this s not the right interface, see root_of_file, maybe we should return a t itself and merge the results
Except for `Fut, any relative path is made absolute to the current build unit with B0_build.Unit.root_dir.
select b sels selects in b the sources specified by sels.
Important. All files in the map that were selected via `File, `D and `D_rec are automatically made ready in b. For those selected via `Fut readyness determination is left to the invoked funtion.
FIXME. Provide ordering guarantes and avoid non-det from the fs.
by_ext s are the selected files mapped by their file extension (not multiple file extension). Each file is guaranteed to appear only once in the map and is absolute.