LinuxCommandLibrary

dune

A build system for OCaml programs.

TLDR

Build all targets

$ dune build
copy


Clean up the workspace
$ dune clean
copy


Run all tests
$ dune runtest
copy


Start the utop REPL with compiled modules automatically loaded into it, to remove the need to load them by hand
$ dune utop
copy

SYNOPSIS

dune build [watch]

dune runtest [watch]

dune exec NAME

dune utop [DIR]

dune install

dune init project NAME [PATH] [libs=l1,l2 ppx=p1,p2 inlinetests]

DESCRIPTION

Dune is a build system designed for OCaml projects only It focuses on providing the user with a consistent experience and takes care of most of the lowlevel details of OCaml compilation All you have to do is provide a description of your project and Dune will do the rest

The scheme it implements is inspired from the one used inside Jane Street and adapted to the open source world It has matured over a long time and is used daily by hundreds of developers, which means that it is highly tested and productive

COMMANDS

build

Build the given targets, or all installable targets if none are given

cache

Manage the shared artifacts cache

clean

Clean the project

compute

Compute internal function

describe

Describe the workspace

exec

Execute a command in a similar environment as if installation was performed

externallibdeps

Print out external libraries needed to build the given targets

formatdunefile

Format dune files

help

Additional Dune help

init

Initialize dune components

install

Install packages

installedlibraries

Print out libraries installed on the system

ocamlmerlin

Start a merlin configuration server

printenv

Print the environment of a directory

promote

Promote files from the last run

rules

Dump internal rules

runtest

Run tests

subst

Substitute watermarks in source files

top

Print a list of toplevel directives for including directories and loading cma files

uninstall

Uninstall packages

upgrade

Upgrade jbuilder projects to dune

utop

Load library in utop

COMMAND ALIASES

test

An alias for runtest

OPTIONS

buildinfo

Show build information

f, force

Force actions associated to aliases to be reexecuted even if their dependencies havent changed

help[=FMT] (default=auto)

Show this help in format FMT The value FMT must be one of `auto, `pager, `groff or `plain With `auto, the format is `pager` or `plain whenever the TERM env var is `dumb or undefined

sandbox=VAL (absent DUNE_SANDBOX env)

Sandboxing mode to use by default Some actions require a certain sandboxing mode, so they will ignore this setting The allowed values are: none, symlink, copy

version

Show version information

w, watch

Instead of terminating build after completion, wait continuously for file changes

COMMON OPTIONS

These options are common to all commands

alwaysshowcommandline

Always show the full command lines of programs executed by dune

autopromote

Automatically promote files This is similar to running dune promote after the build

builddir=FILE (absent DUNE_BUILD_DIR env)

Specified build directory _build if unspecified

cache=VAL (absent DUNE_CACHE env)

Activate binary cache (either `disabled or `enabled) Default is `disabled

cachecheckprobability=VAL (absent=0 or DUNE_CACHE_CHECK_PROBABILITY env)

Probability cached rules are rerun to check for reproducibility

cacheduplication=VAL (absent DUNE_CACHE_DUPLICATION env)

Binary cache duplication mode

cachetransport=VAL (absent DUNE_CACHE_TRANSPORT env)

Binary cache protocol

configfile=FILE

Load this configuration file instead of the default one

debugartifactsubstitution

Print debugging info about artifact substitution

debugbacktraces

Always print exception backtraces

debugdependencypath

In case of error, print the dependency path from the targets on the command line to the rule that failed

debugfindlib

Debug the findlib subsystem

defaulttarget=TARGET (absent=@@default)

Set the default target that when none is specified to dune build

diffcommand=VAL

Shell command to use to diff files Use to disable printing the diff

disablepromotion (absent DUNE_DISABLE_PROMOTION env)

Disable all promotion rules

display=MODE

Control the display mode of Dune See duneconfig(5) for more details

ignorepromotedrules

Ignore rules with (mode promote), except ones with (only ) The variable %{ignoring_promoted_rules} in dune files reflects whether this option was passed or not

instrumentwith=BACKENDS (absent DUNE_INSTRUMENT_WITH env)

"Enable instrumentation by BACKENDS BACKENDS is a commaseparated list of library names, each one of which must declare an instrumentation backend

j JOBS

Run no more than JOBS commands simultaneously

nobuffer

Do not buffer the output of commands executed by dune By default dune buffers the output of subcommands, in order to prevent interleaving when multiple commands are executed in parallel However, this can be an issue when debugging long running tests With nobuffer, commands have direct access to the terminal Note that as a result their output wont be captured in the log file You should use this option in conjunction with j 1, to avoid interleaving Additionally you should use verbose as well, to make sure that commands are printed before they are being executed

noconfig

Do not load the configuration file

noprintdirectory

Suppress "Entering directory" messages

onlypackages=PACKAGES

Ignore stanzas referring to a package that is not in PACKAGES PACKAGES is a commaseparated list of package names Note that this has the same effect as deleting the relevant stanzas from dune files It is mostly meant for releases During development, it is likely that what you want instead is to build a particular <package>install target

p PACKAGES, forreleaseofpackages=PACKAGES (required)

Shorthand for release onlypackages PACKAGE You must use this option in your <package>opam files, in order to build only whats necessary when your project contains multiple packages as well as getting reproducible builds

profile=VAL (absent DUNE_PROFILE env)

Select the build profile, for instance dev or release The default is dev

promoteinstallfiles[=VAL] (default=true)

Promote the generated <package>install files to the source tree

release

Put dune into a reproducible release mode This is in fact a shorthand for root ignorepromotedrules noconfig profile release alwaysshowcommandline promoteinstallfiles defaulttarget @install You should use this option for release builds For instance, you must use this option in your <package>opam files Except if you already use p, as p implies this option

root=DIR

Use this directory as workspace root instead of guessing it Note that this option doesnt change the interpretation of targets given on the command line It is only intended for scripts

storeorigsourcedir (absent DUNE_STORE_ORIG_SOURCE_DIR env)

Store original source location in dunepackage metadata

terminalpersistence=MODE

Changes how the log of build results are displayed to the console between rebuilds while in watch mode Supported modes: preserve, clearonrebuild

tracefile=FILE

Output trace data in catapult format (compatible with chrome://tracing)

verbose

Same as display verbose

workspace=FILE (absent DUNE_WORKSPACE env)

Use this specific workspace file instead of looking it up

x VAL

Crosscompile using this toolchain

MORE HELP

Use `dune COMMAND help for help on a single command

ENVIRONMENT

These environment variables affect the execution of dune:

DUNE_BUILD_DIR

Specified build directory _build if unspecified

DUNE_CACHE

Activate binary cache (either `disabled or `enabled) Default is `disabled

DUNE_CACHE_CHECK_PROBABILITY

Probability cached rules are rerun to check for reproducibility

DUNE_CACHE_DUPLICATION

Binary cache duplication mode

DUNE_CACHE_TRANSPORT

Binary cache protocol

DUNE_DISABLE_PROMOTION

Disable all promotion rules

DUNE_INSTRUMENT_WITH

"Enable instrumentation by BACKENDS BACKENDS is a commaseparated list of library names, each one of which must declare an instrumentation backend

DUNE_PROFILE

Build profile dev if unspecified or release if p is set

DUNE_SANDBOX

Sandboxing mode to use by default (see sandbox)

DUNE_STORE_ORIG_SOURCE_DIR

Store original source location in dunepackage metadata

DUNE_WORKSPACE

Use this specific workspace file instead of looking it up

BUGS

Check bug reports at https://githubcom/ocaml/dune/issues

EXAMPLES

1

Initialise a new project named `foo:

      dune init project foo
2

Build all targets in the current source tree:

      dune build
3

Run the executable named `bar:

      dune exec bar
4

Run all tests in the current source tree:

      dune runtest
5

Install all components defined in the project:

      dune install
6

Remove all build artefacts:

      dune clean

Copied to clipboard