B0_srcs
Select source files.
FIXME. This will need a few more design rounds. Here are a few things:
b0
.sel
s and producing t
and ways union t
s (for `Fut users).`Fut
case should return a t
.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:
src-exe
.src
.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 `Future
selections.
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.
type sel = [
| `Dir of B0_std.Fpath.t
| `Dir_rec of B0_std.Fpath.t
| `X of B0_std.Fpath.t
| `File of B0_std.Fpath.t
| `Fut of B0_build.t -> B0_std.Fpath.Set.t B0_std.Fut.t
]
The type for file selectors.
`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, maybe we should return a t
itself and merge the resultsExcept for `Fut
, any relative path is made absolute to the current build unit with B0_unit.scope_dir
.
type sels = sel list
The type for source selection.
val select : B0_build.t -> sels -> t B0_std.Fut.t
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.
val by_ext : t -> B0_file_exts.map
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.