package opam-format
Install
dune-project
Dependency
Authors
-
David Allsopp
-
VVincent Bernardoff <vb@luminar.eu.org>
-
RRaja Boujbel <raja.boujbel@ocamlpro.com>
-
KKate Deplaix <kit-ty-kate@outlook.com>
-
RRoberto Di Cosmo <roberto@dicosmo.org>
-
TThomas Gazagnaire <thomas@gazagnaire.org>
-
LLouis Gesbert <louis.gesbert@ocamlpro.com>
-
FFabrice Le Fessant <Fabrice.Le_fessant@inria.fr>
-
AAnil Madhavapeddy <anil@recoil.org>
-
GGuillem Rieu <guillem.rieu@ocamlpro.com>
-
RRalf Treinen <ralf.treinen@pps.jussieu.fr>
-
FFrederic Tuong <tuong@users.gforge.inria.fr>
Maintainers
Sources
md5=4eadb5cd5773cff17b19da3c3b70387d
sha512=ee1656715f7e03c36ed9aa0a158033bbdb977d3e9017efa0ceddcd7b073e9b587eb6340ddf1916d9da197c7f48766e569221e6d8e43314bf761326329e4be0a6
doc/opam-format/OpamFilter/index.html
Module OpamFilterSource
Formulas on variables, as used in opam files build scripts
Filters are a small language of formulas over strings and booleans used for conditions and text replacements. It has relational operators over strings (using version-number comparison), And, Or and Not boolean operations, dynamic casting (using strings "true" and "false"), and string interpolation. Variables are resolved using a user function returning an option, undefined values are propagated.
String interpolation uses the syntax %{identifier}%
Identifiers have the form
[package:]var[?str_if_true:str_if_false_or_undef]
The last optional part specifies a conversion from boolean to static strings.
The syntax pkg1+pkg2+pkgn:var is allowed as a shortcut to pkg1:var & pkg2:var & pkgn:var.
The special variable pkg:enable is allowed as a shortcut for pkg:installed?enable:disable
val to_string :
?custom:
(context:[> `And | `Defined | `Not | `Or | `Relop ] ->
paren:(?cond:bool -> string -> string) ->
OpamTypes.filter ->
string option) ->
OpamTypes.filter ->
stringPretty-print custom ?context ?paren filter is a function that permit to customise part of filter pretty-printing.
Folds on the tree of a filter
Maps on all nodes of a filter, bottom-up
Regex matching string interpolation syntax ("%%", "%{xxx}%", or "%{xxx" if unclosed)
Returns all the variables appearing in a filter (including the ones within string interpolations
Type of filter environment.
The type of filter idents with (optionally multiple) qualifying package names and optional string converter. Package name None encodes the self-reference _
val map_variables :
(OpamTypes.full_variable -> OpamTypes.full_variable) ->
OpamTypes.filter ->
OpamTypes.filterMaps on all variables appearing in a filter.
val map_variables_in_string :
(OpamTypes.full_variable -> OpamTypes.full_variable) ->
string ->
stringSame limitation as map_variables
val map_variables_in_fident :
(OpamTypes.full_variable -> OpamTypes.full_variable) ->
fident ->
fidentDistributes the negations to apply only to atoms
Rewrites string interpolations within a string. default is applied to the fident string (e.g. what's between %{ and }%) when the expansion is undefined.
With partial, default defaults to the identity, and is otherwise expected to return a fident. In this case, the returned string is supposed to be expanded again (expansion results are escaped, escapes are otherwise kept). This makes the function idempotent.
Returns the (beginning, end) offsets and substrings of any unclosed %{ expansions
val eval :
?default:OpamTypes.variable_contents ->
env ->
OpamTypes.filter ->
OpamTypes.variable_contentsComputes the value of a filter.
Like eval but casts the result to a bool.
Same as eval_to_bool, but takes an option as filter and returns always true on None, false when the filter is Undefined. This is the most common behaviour for using "filters" for filtering
Like eval but casts the result to a string
Reduces what can be, keeps the rest unchanged
Wraps a full_variable into a fident accessor
A fident accessor directly referring a variable with the given name
val ident_value :
?default:OpamTypes.variable_contents ->
env ->
fident ->
OpamTypes.variable_contentsResolves a filter ident.
Like ident_value, but casts the result to a string
Like ident_value, but casts the result to a bool
val expand_interpolations_in_file_full :
env ->
src:OpamTypes.filename ->
dst:OpamTypes.filename ->
unitSame as expand_interpolations_in_file but allows to set the source src and destination dst files independently instead of implying src = dst.in
Rewrites basename.in to basename, expanding interpolations. If the first line begins "opam-version:", assumes that expansion of variables within strings should be properly escaped. In particular, this means that Windows paths should expand correctly when generating .config files.
Processes filters evaluation in a command list: parameter expansion and conditional filtering
Process a simpler command, without filters
Extracts the list of variables from an argument
Extracts variables appearing in a list of commands
Converts a generic formula to a filter, given a converter for atoms
val filter_formula :
?default_version:OpamTypes.version ->
?default:bool ->
env ->
OpamTypes.filtered_formula ->
OpamTypes.formulaResolves the filter in a filtered formula, reducing to a pure formula.
default is the assumed result for undefined filters. If a version filter doesn't resolve to a valid version, the constraint is dropped unless default_version is specified.
Reduces according to what is defined in env, and returns the simplified formula
val gen_filter_formula :
('a -> [< `True | `False | `Formula of 'b OpamTypes.generic_formula ]) ->
('c * 'a) OpamFormula.formula ->
('c * 'b OpamTypes.generic_formula) OpamFormula.formulaA more generic formula reduction function, that takes a "partial resolver" as argument
val variables_of_filtered_formula :
OpamTypes.filtered_formula ->
OpamTypes.full_variable listval filter_deps :
build:bool ->
post:bool ->
?test:bool ->
?doc:bool ->
?dev_setup:bool ->
?dev:bool ->
?default_version:OpamTypes.version ->
?default:bool ->
OpamTypes.filtered_formula ->
OpamTypes.formulaResolves the build, post, test, doc, dev flags in a filtered formula (which is supposed to have been pre-processed to remove switch and global variables). default determines the behaviour on undefined filters, and the function may raise if it is undefined. If a constraint resolves to an invalid version, it is dropped, or replaced with default_version if specified. If test, doc or dev are unspecified, they are assumed to be filtered out already and encountering them will raise an assert.
val deps_var_env :
build:bool ->
post:bool ->
?test:bool ->
?doc:bool ->
?dev_setup:bool ->
?dev:bool ->
envThe environment used in resolving the dependency filters, as per filter_deps.
Like OpamFormula.simplify_version_formula, but on filtered formulas (filters are kept unchanged, but put in front)
val atomise_extended :
OpamTypes.filtered_formula ->
(OpamPackage.Name.t
* (OpamTypes.filter * (OpamTypes.relop * OpamTypes.filter) option))
OpamFormula.formulaval sort_filtered_formula :
((OpamTypes.name * OpamTypes.condition) ->
(OpamTypes.name * OpamTypes.condition) ->
int) ->
OpamTypes.filtered_formula ->
OpamTypes.filtered_formula