LinuxCommandLibrary

dub

Manage and build D language projects

TLDR

Interactively create a new D project

$ dub init [project_name]
copy

Non-interactively create a new D project
$ dub init [project_name] [[-n|--non-interactive]]
copy

Build and run a D project
$ dub
copy

Install dependencies specified in a D project's dub.json or dub.sdl file
$ dub fetch
copy

Update the dependencies in a D project
$ dub upgrade
copy

Display help
$ dub [[-h|--help]]
copy

SYNOPSIS

dub [GLOBAL_OPTIONS...] COMMAND [COMMAND_OPTIONS...] [ARGS...]

Common Commands:
dub init: Initialize a new DUB package.
dub build: Build the current DUB package.
dub run: Build and run the current DUB package.
dub test: Build and run unit tests for the current DUB package.
dub fetch [package-name]: Fetch remote dependencies.
dub clean: Clean build artifacts.
dub add-local: Add a local package to the DUB package list.

PARAMETERS

-v, --verbose
    Enable verbose output for detailed information during operations.

--quiet
    Suppress most output, showing only essential information or errors.

--force
    Force an action, such as overwriting existing files or rebuilding when not strictly necessary.

--compiler=name
    Specify the D compiler to use (e.g., dmd, ldc2, gdc).

--config=name
    Specify a particular build configuration defined in dub.json or dub.sdl.

--build=type
    Specify the build type (e.g., debug, release, unittest, profile).

--arch=arch
    Specify the target architecture (e.g., x86, x86_64).

--os=os
    Specify the target operating system (e.g., linux, windows, osx).

--platform=platform
    Specify the target platform (a combination of OS and architecture).

--root=path
    Specify the root directory of the package to operate on.

--version
    Display the dub version information and exit.

--help
    Display a general help message or command-specific help.

DESCRIPTION

dub is the official, comprehensive build tool and package manager for the D programming language. It significantly streamlines the development workflow by handling crucial aspects of project management, from initialization to deployment.

At its core, dub automates dependency management, fetching and resolving packages from the DUB package registry (code.dlang.org/packages) or local paths. It orchestrates the compilation process, invoking the appropriate D compiler (such as dmd, ldc2, or gdc) based on project configurations and user settings. dub supports various project types, including executables, static libraries, shared libraries, and DUB packages themselves. It also facilitates running applications, executing unit tests, generating project descriptions, and cleaning build artifacts. Through its dub.json or dub.sdl project definition files, dub provides a consistent and reproducible build environment for D projects across different systems, making it an indispensable tool for D developers.

CAVEATS

The dub command is specifically designed for the D programming language ecosystem and is not a generic Linux utility. Its functionality relies on the presence of a D compiler (like dmd, ldc2, or gdc) and a properly defined dub.json or dub.sdl package file. Fetching external dependencies requires network access to the DUB package registry.

PROJECT DEFINITION FILES

dub projects are configured using either a dub.json or dub.sdl file located at the package root. These files define project metadata, dependencies, source files, build configurations, and various other settings crucial for dub's operation.

DUB PACKAGE REGISTRY

The DUB Package Registry (accessible via code.dlang.org/packages) is the central repository for publicly available D packages. dub interacts with this registry to fetch and manage project dependencies, enabling easy sharing and reuse of D code.

HISTORY

dub emerged as an essential tool to address the growing need for robust dependency management and build automation within the D programming language community. Initially developed independently, it rapidly gained traction and became the official and de facto standard package manager and build system for D projects. Its continuous development reflects the evolving needs of the D ecosystem, providing a stable and feature-rich foundation for D software development since its early adoption.

SEE ALSO

dmd(1), ldc2(1), gdc(1), git(1)

Copied to clipboard