DUB: Packages and Build Configuration
45.1 dub.json / dub.sdl
{
"name": "myapp",
"description": "A sample D application",
"authors": ["Your Name"],
"license": "MIT",
"targetType": "executable",
"dependencies": {
"vibe-d": "~>0.10.0",
"mir-algorithm": "~>3.22"
},
"configurations": [
{ "name": "default" },
{ "name": "unittest", "dependencies": { "unit-threaded": "~>2.1" } }
],
"buildTypes": {
"profile-gc": { "buildOptions": ["debugInfo"], "dflags": ["-profile=gc"] }
},
"dflags-ldc": ["-mcpu=native"],
"versions": ["EnableLogging"],
"libs-posix": ["sqlite3"],
"stringImportPaths": ["views"]
}name "myapp"
dependency "vibe-d" version="~>0.10.0"
targetType "executable"
configuration "default" {}45.2 Common Commands
Build types: debug (default), plain, release, release-debug, release-nobounds, unittest, docs, ddox, profile, profile-gc, cov, unittest-cov, syntax.
Registry: code.dlang.org. Publish by registering a GitHub/GitLab repo with semver tags.
Alternatives: reggae (meta-build), meson (native D support), CMake (cmake-d), plain makefiles.
dub init myapp -t vibe.d # template project
dub build --build=release --compiler=ldc2
dub build --build=release-debug --arch=x86_64
dub run -- arg1 arg2
dub test
dub add mir-algorithm
dub upgrade # update dub.selections.json
dub fetch dfmt && dub run dfmt -- source/
dub describe # project info (JSON)
dub lint # D-Scanner
dub --single script.d # single-file package
dub build --config=library