Module Ocb_stubblr

OCamlbuild plugin for C stubs

See the Intro, Interface or Examples.

Intro

1. Using .clib files

2. pkg-config

3. Multi-lib

Interface

type ocb_hook = Ocamlbuild_plugin.hook -> unit
type path = Ocamlbuild_plugin.Pathname.t
val init : ?⁠incdirs:bool -> ?⁠mllibs:path list -> ocb_hook

init ?incdirs ?paths initializes the plugin.

incdirs causes include_include_dirs to be called on initialisation. Defaults to true.

mllibs are passed to ocaml_libs, to detect any <lib>.mllib files and enable their corresponding use_<lib> tags. Use [] to disable. Defaults to ["."].

Utilities

val ocaml_libs : ?⁠mllibs:path list -> ocb_hook

ocaml_libs ~mllibs calls Ocamlbuild_plugin.ocaml_lib on every .mllib found in mllibs. It's a shortcut to enable use_<lib> tag for every <lib>.mllib in the project.

mllibs is a list of files or directories. Directories in the list are searched recursively. mllibs defaults to ["."].

val include_include_dirs : ocb_hook

include_include_dirs will add -I dir when linking OCaml programs and cmxs for every dir marked as include.

val ccopt : ?⁠tags:string list -> string -> ocb_hook

ccopt tags options adds -ccopt options when compiling the C sources tagged with ~tags.

tags defaults to [].

val cclib : ?⁠tags:string list -> string -> ocb_hook

cclib tags options adds -cclib options when linking the C libraries tagged with ~tags.

tags defaults to [].

val ldopt : ?⁠tags:string list -> string -> ocb_hook

ldopt tags options adds -ldopt options when linking the C libraries tagged with ~tags.

tags defaults to [].

val after_rules : (unit -> unit) -> ocb_hook

after_rules f is function After_rules -> f () | _ -> ().

val dispatchv : ocb_hook list -> unit

dispatchv hooks is a shortcut for registering several ocb_hooks.

It is equivalent to Ocamlbuild_plugin.dispatch hookf where hookf is a function that applies each hook from hooks in order.

val (&) : ocb_hook -> ocb_hook -> ocb_hook

h1 & h2 is a hook combining h1 and h2.

module Pkg_config : sig ... end

Query pkg-config.

OS and machine detection

type os = [
| `Linux
| `Hurd
| `Darwin
| `FreeBSD
| `OpenBSD
| `NetBSD
| `DragonFly
| `KFreeBSD
| `Haiku
| `HP_UX
| `AIX
| `Interix
| `Minix
| `QNX
| `SunOS
| `Cygwin of string
| `Mingw of string
| `Uwin of string
| `UNKNOWN of string
]

A selection of popular operating systems.

type machine = [
| `x86_64
| `x86
| `ARMv6
| `ARMv7
| `UNKNOWN of string
]

A selection of machine architectures supported by OCaml.

val os : unit -> os

os () is the normalized result of uname -s.

val machine : unit -> machine

machine () is the normalized result of uname -m.

Examples

Basic integration

pkg-config

In-tree executables

Multi-lib

Mirage

Composition