@@ -9,14 +9,80 @@ The [CLI](cli-reference/dub.md) can be used to
9
9
- compile projects and external programs ([ dub build] ( cli-reference/dub-build.md ) , [ dub run] ( cli-reference/dub-run.md ) )
10
10
- test projects ([ dub test] ( cli-reference/dub-test.md ) )
11
11
12
- To see how to obtain dub, ** go to the next page by pressing the button below** .
12
+ DUB is bundled with most D compilers' distributions. However, it's also possible to install it separately.
13
+ See [ Installing DUB] ( getting-started/install.md ) for details.
13
14
14
15
<!-- old docs anchors for index page, all link to first steps -->
15
16
<a id =" own-projects " ></a >
16
17
<a id =" adding-deps " ></a >
17
18
<a id =" foreign-projects " ></a >
18
19
<a id =" advanced-usage " ></a >
19
20
20
- ## Starting a new project
21
+ ## DUB Basics
21
22
22
- You can also skip ahead to [ First steps] ( getting-started/first-steps.md ) if you already have dub installed.
23
+ DUB is a build tool similar to other modern languages build tools like Javascript's [ npm] ( https://www.npmjs.com/ )
24
+ and Rust's [ cargo] ( https://crates.io/ ) .
25
+
26
+ A file called ` dub.sdl ` (or ` dub.json ` ) is used to configure a DUB project.
27
+
28
+ > [ SDL] ( https://sdlang.org/ ) is a "Simple Declarative Language" inspired by D's syntax.
29
+ > Whether to use SDL or JSON for the DUB file is a [ matter of taste] ( https://forum.dlang.org/thread/[email protected] ) .
30
+
31
+ A DUB file may look like this:
32
+
33
+ ``` sdl
34
+ name "myproject"
35
+ description "A minimal D application."
36
+ authors "My Name"
37
+ copyright "Copyright © 2024, My Name"
38
+ license "Boost"
39
+
40
+ dependency "libasync" version="~>0.9.5"
41
+
42
+ configuration "library" {
43
+ targetPath "target/lib"
44
+ }
45
+
46
+ configuration "unittest" {
47
+ dependency "tested" version="~>0.9.5"
48
+ dependency "dshould" version="~>1.7.1"
49
+ targetPath "target/test"
50
+ }
51
+ ```
52
+
53
+ [ DUB Configurations] ( dub-reference/configurations.md ) are used to create different variations of a project.
54
+
55
+ In the above example, all configurations include a dependency on ` libasync ` because that's declared at the top-level,
56
+ but only the ` unittest ` configuration includes the dependencies ` tested ` and ` dshould ` .
57
+
58
+ When running ` dub test ` , all [ Unit Tests] ( https://tour.dlang.org/tour/en/gems/unittesting ) found in
59
+ [ sourcePaths] ( dub-reference/build_settings.md#sourcepaths ) are executed using the ` unittest ` configuration by default.
60
+
61
+ To specify a configuration explicitly when building, use the ` --config ` option:
62
+
63
+ ```
64
+ dub build --config=library
65
+ ```
66
+
67
+ DUB also uses the concept of [ build types] ( dub-reference/buildtypes.md ) to define what to build. Many build types are
68
+ pre-defined, but the most common ones are ` debug ` and ` release ` .
69
+
70
+ Hence, to build the release version of a library, the following command could be used:
71
+
72
+ ```
73
+ dub build --config=library --build=release
74
+ ```
75
+
76
+ Finally, to run the application, use ` dub run ` .
77
+
78
+ Check [ Building] ( dub-guide/building.md ) for more details.
79
+
80
+ ## Next Steps
81
+
82
+ [ First Steps] ( getting-started/first-steps.md ) completes this overview of the basic DUB workflow.
83
+
84
+ The [ DUB Guide] ( dub-guide/recipe.md ) goes into more details about building, testing, configuring dependencies and registries,
85
+ shared libraries, publishing packages and more.
86
+
87
+ More experienced users can use the [ DUB Reference] ( dub-reference/recipe.md ) and [ CLI Reference] ( cli-reference/dub/ )
88
+ for a comprehensive list of the available options.
0 commit comments