Module Topkg.Conf
Build configuration.
Key value converters
val conv : ?docv:string -> (string -> 'a result) -> (Stdlib.Format.formatter -> 'a -> unit) -> 'a convconv ~docv parse printis a configuration value converter parsing values withparseand printing them withprint.docvis a documentation meta-variable used in the documentation to stand for the configuration value, defaults to"VALUE".
val bool : bool convboolis a converter for booleans.
val int : int convintis a converter for integers.
val string : string convstringis a converter for strings.
Keys
Warning. Configuration keys must be created before the call to Pkg.describe. Yes you are right, that's a little bit dirty.
type 'a keyThe type for configuration keys whose lookup value is of type
'a.A configuration key has a name and represents a value of type
'ain a build configuration. If"name"is the name of the key then its value can be specified on the command line using--name vwherevis the value of the key and is parsed according to the key's value converter.There are a few predefined key, see the configuration section.
val key : ?docv:string -> ?doc:string -> ?env:string -> string -> 'a conv -> absent:'a -> 'a keykey name conv ~absent ~env ~doc ~docvis a configuration key with namenameparsed from the command line withconv.absentis used if the value is not specified on the command line. Ifenvis specified and exists in the process environment, the value of the variable is parsed withconvand used instead ofabsentwhen needed.docis a documentation string for the key.docvis a documentation meta-variable to stand for the key value, defaulting to thedocvofconv. Indoc, occurences of the substring"$(docv)"are replaced by the value ofdocv.
val discovered_key : ?docv:string -> ?doc:string -> ?env:string -> string -> 'a conv -> absent:(unit -> 'a result) -> 'a keydiscovered_keyis like Keys but the absent value is discovered, if needed, withabsent.
val with_pkg : ?default:bool -> string -> bool keywith_pkg ~default pkgis a boolean configuration key named(strf "with-%s" pkg)to assert existence of opam packages. If absent defaults todefault.Usually specified in opam build instructions with:
"--with-thatpkg" thatpkg:installedalong with an entry in the depopt field of the opam file.
Warning. Only use this combinator for denoting opam package existence, the resulting key may switch to a discovery process in the future.
Configurations
val value : t -> 'a key -> 'avalue c kis the value of configuration keykinc.- raises Invalid_argument
If
kwas (illegaly) created after the call toPkg.describeor if dirty tricks are being played.
val pkg_name : t -> stringpkg_name cis either the value of the package name as given toPkg.describeor the value of a predefined key--pkg-namewhich overrides the package name. This defines the name of the generated opam install file. Used to handle multiple opam packages.
val build_dir : t -> fpathbuild_dir cis either the value of build directory as given toPkg.describevia Build description or the value of a predefined key--build-dirwhich overrides the package definition.
val vcs : t -> boolvcs cis the value of a predefined key--vcs. It istrueif the package directory is VCS managed. Usually should not be specified manually: if absent it is determined automatically by usingTopkg.Vcs.findand used to determine thebuild_context.
val dev_pkg : t -> booldev_pkg cis the value of a predefined key--dev-pkg. It istrueif the build is initiated by an installer like opam and the package sources are a checkout from a VCS rather than a distribution archive. Usually specified in opam build instruction with either:"--dev-pkg" "%{dev}%" # for opam >= 2.0 "--dev-pkg" "%{pinned}%" # < 2.0
val pinned : t -> bool
val jobs : t -> intjobs cis the value of a predefined key--jobs. If absent it is determined from the build context as follows.`Devbuilds default to number of CPU cores, or 4 if it cannot be determined.- all other contexts default to 4
type build_context=[|`Dev|`Distrib|`Pin]The type for build contexts. See
build_contextfor semantics.
val build_context : t -> [ `Dev | `Distrib | `Pin ]build_context cis the build context ofc. This is derived fromvcsanddev_pkg(or the deprecatedpinned) as follows.`Distribiffnot (vcs c). No VCS is present, this is a build from a distribution. If there are configuration bits they should be setup according to the build configuration.`Deviffvcs c && not (dev_pkg c || pinned c). This is a development build invoked manually in a source repository. The repository checkout should likely not be touched and configuration bits not be setup. This is happening for example if the developer is testing the package description in her working source repository by invokingpkg/pkg.mlortopkg build.`Piniffvcs c && (dev_pkg c || pinned c). This is a package manager development build. In this case the repository checkout may need to be massaged into a pseudo-distribution for the package to be installed. This means that distribution watermarking and massaging should be performed, see Distribution description and theprepare_on_pinargument of Build description. Besides exisiting configuration bits should be setup according to the build environment. Note. This is called`Pindue to a blind spot, a more approriate name would be something like`Dev_pkgbuild.
val build_tests : t -> boolbuild_tests cis the value of a predefined key--teststhat indicates if the tests should be built. If absent the value depends on thebuild_context, it istruein the`Devcontext andfalsein the other contexts.
val debug : t -> booldebug cis the value of a predefined key--debugthat indicates if the build should include debugging information in the build artefacts. If absent the value istrueor the value of the environment variable TOPKG_CONF_DEBUG if specified.
val debugger_support : t -> booldebugger_support cis the value of a predefined key--debugger-supportthat indicates if build artefacts needed for source level debuggers should be built and installed. If absent the value isfalseor the value of the environment variable TOPKG_CONF_DEBUGGER_SUPPORT if specified.
val profile : t -> boolprofile cis the value of a predefined key--profilethat indicates if the build artefacts include run-time profiling support. If absent the value isfalseor the value of the environment variable TOPKG_CONF_PROFILE if specified.
val toolchain : t -> string optiontoolchain cis the value of a predefined key--toolchainthat specifies the ocamlbuild toolchain. If absent the value isNoneor the value of the environment variable TOPKG_CONF_TOOLCHAIN if specified.
val dump : Stdlib.Format.formatter -> t -> unitdump ppf cformats an unspecified representation ofconppf.
Tool lookup
If your package description needs to run tools (e.g. in the pre and post build hooks, see Build description) it should get the tool to invoke with the following function. This allows to control the executable being run which is useful for cross-compilation scenarios.
type os=[|`Build_os|`Host_os]The type for operating systems.
`Build_osis the build OS, the OS on which the package is built.`Host_osis the host OS, the OS on which the package is hosted and runs.
val tool : ?conf:t -> string -> os -> Cmd.ttool ~conf cmd osis a commandcmdwhich can be run on the build OS which produces output suitable for the OSos, taking into account configurationconf.The actual command returned depends on the following lookup procedure, here exemplified on the invocation
tool "mytool" `Host_os(resp.`Build_os).Cmd.v "cmd", if the environment variable HOST_OS_MYTOOL (resp. BUILD_OS_MYTOOL) is set to"cmd"Cmd.v (Fpath.append path "mytool"), if the environment variable HOST_OS_XBIN (resp. BUILD_OS_BIN) is set topath.Cmd.v ("mytool" ^ "suff"), if the environment variable HOST_OS_SUFF (resp. BUILD_OS_SUFF).Cmd.(v "ocamlfind" % "-toolchain" % "toolchain" % "mytool")if"mytool"is part of the OCaml tools that can be invoked through ocamlfind,toolchain confis notNone, andosis`Host_os.Cmd.(v "ocamlfind" % "mytool")if"mytool"is part of the OCaml tools that can be invoked through ocamlfind.Cmd.v "mytool"otherwise.
OCaml configuration
module OCaml : sig ... endOCaml configuration.