Skip to content

Commit 28de236

Browse files
Muhammed Kadir YücelWebFreak001
authored andcommitted
Document Have_<dependency> feature for conditional compilations
1 parent 97dec86 commit 28de236

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

views/advanced_usage.dt

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,27 @@ block body
5555
p For adding subpackages from the registry, execute <code> dub add &lt;packagename&gt;:&lt;subpackage&gt; </code>
5656

5757
p If you need to compile a subpackage only, use <code> dub build :&lt;subpackage&gt; </code>
58-
58+
59+
h2#have-version Conditional compilation according to dependency presence
60+
61+
p Projects can have additional special dependencies for specific configurations.
62+
63+
pre.code
64+
|"configurations": [
65+
| {
66+
| "name": "myconfig",
67+
| "dependencies": {
68+
| "mydep": { "version": "*" }
69+
| }
70+
| }
71+
|]
72+
73+
p DUB provides version identifier of dependencies for conditional compilation with <a href="https://dlang.org/spec/version.html#version">version conditions</a>. <code>Have_&lt;dependency&gt;</code> version identifier can be used for conditional compilation.
74+
75+
p
76+
strong NOTE: Special characters other than identifier characters (<code>[a-z, A-Z, 0-9, _]</code>) in dependency name are replaced with <code>_</code> character in version identifier.
77+
78+
pre.code.
79+
version (Have_mydep) {
80+
import mydep;
81+
}

0 commit comments

Comments
 (0)