dune
composable build system for OCaml projects
TLDR
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.init component name
Initialize new component (project, library, executable, test).fmt
Format source code using ocamlformat.promote
Promote expected test outputs.cache
Manage the shared build artifact cache.install
Install packages defined in the project.--watch, -w
Rebuild continuously on file changes.--force
Force rebuild of all targets.--verbose
Display full command lines of executed programs.
CONFIGURATION
dune
Per-directory build configuration files using S-expression syntax defining libraries, executables, and tests.dune-project
Project-level configuration at repository root specifying project metadata and language version.dune-workspace
Optional workspace configuration for multi-context builds and advanced project settings.
DUNE FILE EXAMPLE
(name mylib)
(libraries str unix))
(executable
(name main)
(libraries mylib))
(test
(name test_mylib)
(libraries mylib alcotest))
CAVEATS
Requires OCaml or Reason compiler. Build artifacts go in the _build directory. Dune files use S-expression syntax, not YAML or TOML. Package management requires opam.
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.
