package b0
Install
Dune Dependency
Authors
Maintainers
Sources
sha512=78fd9e53b84cf5d6bf497adaf4b6d7d974134044318639cdfe5e01c7faaa8d987d04769abe3b3b1cbdb937132e21d8723dc185cd3c68433a793278907a8e757e
doc/b0.kit/B0_srcs/index.html
Module B0_srcs
Select source files.
FIXME. This will need a few more design rounds. Here are a few things:
- Review w.r.t.
b0
. - We likely want combinators represenging
sel
s and producingt
and ways uniont
s (for `Fut users). - The
`Fut
case should return at
. - Support for watermaking should likely occur here.
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 directory
src-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
andsrc/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.
Source selection
type sel = [
| `Dir of B00_std.Fpath.t
| `Dir_rec of B00_std.Fpath.t
| `X of B00_std.Fpath.t
| `File of B00_std.Fpath.t
| `Fut of B0_build.t -> B00_std.Fpath.Set.t B00_std.Fut.t
]
The type for file selectors.
`File f
unconditionaly selects the filef
.f
must exist and be a file.`Dir d
selects the files of directoryd
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 atd
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 byx
, respecting segment boundaries. A potential trailing directory separators inx
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, seeroot_of_file
, maybe we should return at
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
.
type sels = sel list
The type for source selection.
val select : B0_build.t -> sels -> t B00_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 -> B00_fexts.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.