package b0

  1. Overview
  2. Docs
On This Page
  1. Source selection
Legend:
Library
Module
Module type
Parameter
Class
Class type

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 sels and producing t and ways union ts (for `Fut users).
  • The `Fut case should return a t.
  • 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 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.

Source selection

type sel = [
  1. | `Dir of B00_std.Fpath.t
  2. | `Dir_rec of B00_std.Fpath.t
  3. | `X of B00_std.Fpath.t
  4. | `File of B00_std.Fpath.t
  5. | `Fut of B0_build.t -> B00_std.Fpath.Set.t B00_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, 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.

type sels = sel list

The type for source selection.

type t

The type for source selection results.

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.

OCaml

Innovation. Community. Security.