LinuxCommandLibrary

dune

TLDR

Build the project

$ dune build
copy
Run tests
$ dune test
copy
Run an executable
$ dune exec [program]
copy
Clean build artifacts
$ dune clean
copy
Build and watch for changes
$ dune build --watch
copy
Format code
$ dune fmt
copy
Create new project
$ dune init project [name]
copy

SYNOPSIS

dune command [options]

DESCRIPTION

Dune is the standard build system for OCaml and Reason projects. It automatically discovers project structure, handles dependencies, and provides fast incremental builds with caching.
Projects are configured with dune files using an S-expression syntax. Dune integrates with opam for package management and supports cross-compilation, multiple build contexts, and IDE integration.

PARAMETERS

build [targets]

Build specified targets or all.
test
Run tests.
exec program
Build and execute program.
clean
Remove build artifacts.
runtest test
Run specific test.
init component name
Initialize new component (project, library, executable).
fmt
Format source code.
promote
Promote expected test outputs.
--watch
Rebuild on file changes.
--force
Force rebuild of targets.
--release
Build in release mode.

DUNE FILE EXAMPLE

$ (library
 (name mylib)
 (libraries str unix))

(executable
 (name main)
 (libraries mylib))

(test
 (name test_mylib)
 (libraries mylib alcotest))
copy

CAVEATS

Requires OCaml or Reason compiler. Build artifacts are in _build directory. Dune files use S-expression syntax, not YAML or TOML. Package management requires opam. Large projects benefit from dune-workspace files.

HISTORY

Dune was originally called jbuilder, created by Jane Street in 2016. It was renamed to Dune in 2018 and became the de facto standard build system for the OCaml ecosystem. The project aims to provide a modern, fast, and user-friendly build experience.

SEE ALSO

ocaml(1), opam(1), ocamlfind(1), make(1)

Copied to clipboard