# Xmake Dlang

> Use when building D projects with xmake — binary/library targets with `.d` sources, DUB package integration via `add_requires("dub::...")`, and selecting DMD / LDC / GDC compilers.

- **Type:** Skill
- **Install:** `agentstack add skill-xmake-io-xmake-skills-xmake-dlang`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [xmake-io](https://agentstack.voostack.com/s/xmake-io)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** Apache-2.0
- **Upstream author:** [xmake-io](https://github.com/xmake-io)
- **Source:** https://github.com/xmake-io/xmake-skills/tree/master/skills/languages/xmake-dlang

## Install

```sh
agentstack add skill-xmake-io-xmake-skills-xmake-dlang
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Building D (dlang) with Xmake

D has three main compilers (DMD, LDC, GDC); xmake drives all of them through a unified `target()` API and supports DUB for package dependencies.

## 1. Minimal project

```bash
xmake create -l dlang -t console hello
cd hello
xmake run
```

```lua
add_rules("mode.debug", "mode.release")

target("hello")
    set_kind("binary")
    add_files("src/*.d")
```

## 2. Target kinds

```lua
target("app")       set_kind("binary")
target("mylib")     set_kind("static")
target("mydyn")     set_kind("shared")
```

## 3. DUB dependencies (v2.3.6+)

```lua
add_requires("dub::vibe-d ~>0.9.5")
add_requires("dub::libasync")

target("app")
    set_kind("binary")
    add_files("src/*.d")
    add_packages("dub::vibe-d", "dub::libasync")
```

Known limitation: cascading transitive deps must be declared manually for now. Add every dep in the tree explicitly.

## 4. Compiler selection

```bash
xmake f --toolchain=dlang                    # DMD (default)
xmake f --toolchain=ldc
xmake f --toolchain=gdc
```

Or pin paths:

```bash
xmake f --toolchain=ldc --sdk=/opt/ldc-1.30
```

LDC is usually the best choice for release builds (LLVM backend, best optimization). DMD is fastest to compile with.

## 5. Flags

```lua
target("app")
    add_files("src/*.d")
    add_dcflags("-O", "-release")          -- passed to the D compiler
    add_ldflags("-Wl,--as-needed")
```

`add_dcflags` = D compiler flags. Each compiler has its own flag dialect — prefer portable ones or gate with `if is_toolchain("ldc") then ... end`.

## 6. Mixing D with C

```lua
target("app")
    set_kind("binary")
    add_files("src/main.d", "src/extern.c")    -- mix C and D in one target
    add_includedirs("include")
```

D can call C directly via `extern (C)` declarations on the D side. No bridging needed.

## Pitfalls

- **Transitive DUB deps.** You must add them manually until xmake's DUB integration is complete.
- **Compiler-specific flags leaking across toolchains.** `add_dcflags("-mattr=+avx2")` works on LDC, fails on DMD. Gate with `is_toolchain`.
- **D shared libraries on Windows.** DMD and LDC produce different import-library formats; stick to one per project on Windows.

## When to branch out

- Build modes → `xmake-targets`, `xmake-build-optimization`
- Cross-compile → `xmake-cross-compilation` (LDC supports many targets)
- Package management basics → `xmake-packages`

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [xmake-io](https://github.com/xmake-io)
- **Source:** [xmake-io/xmake-skills](https://github.com/xmake-io/xmake-skills)
- **License:** Apache-2.0

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-xmake-io-xmake-skills-xmake-dlang
- Seller: https://agentstack.voostack.com/s/xmake-io
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
