LinuxCommandLibrary

dune

Build OCaml projects reproducibly

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 COMMAND [OPTIONS]

PARAMETERS

build
    Build the specified targets.

runtest
    Run the tests defined in the project.

exec
    Execute a specific executable.

utop
    Load the project's modules into a UTop session.

clean
    Remove build artifacts.

fmt
    Format the OCaml code in the project.

init
    Initializes a new dune project.

release
    Prepare a release of the project.
It can automatically generate the changelog and archive.

promote
    Copy files from the build directory to the source directory, for example after running `dune build @fmt`.

--version
    Prints the version of Dune

DESCRIPTION

Dune is a build system designed for OCaml projects, focusing on speed, correctness, and user-friendliness. It allows users to describe the dependencies of their projects in a declarative way and then automatically builds the projects, handles dependencies, and generates necessary build artifacts. Dune aims to provide a consistent and reproducible build environment, abstracting away the complexities of manual makefiles or custom build scripts. It utilizes a high-level description of the project structure and dependencies to generate efficient build plans, ensuring that only necessary parts are rebuilt when changes are made. Dune integrates well with the OCaml ecosystem, including package managers like OPAM, and supports various features such as preprocessing, code generation, and testing.
Its build specifications are declarative, so one only needs to describe the desired build results and not the steps to achieve them. Dune then figures out dependencies and creates an efficient build order.

CONFIGURATION FILES

Dune relies on dune files (usually named dune or dune-project) to describe the build rules and dependencies of a project. These files are written in a simple S-expression-based syntax.

BUILD CONTEXTS

Dune supports building projects in different contexts, which allows you to build for different platforms or with different compiler versions without modifying the source code.

SEE ALSO

make(1)

Copied to clipboard