-
-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrote DUB introduction in index page. #84
Open
renatoathaydes
wants to merge
2
commits into
dlang:master
Choose a base branch
from
renatoathaydes:better-intro
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,14 +9,89 @@ The [CLI](cli-reference/dub.md) can be used to | |
- compile projects and external programs ([dub build](cli-reference/dub-build.md), [dub run](cli-reference/dub-run.md)) | ||
- test projects ([dub test](cli-reference/dub-test.md)) | ||
|
||
To see how to obtain dub, **go to the next page by pressing the button below**. | ||
DUB is bundled with most D compilers' distributions. However, it's also possible to install it separately. | ||
See [Installing DUB](getting-started/install.md) for details. | ||
|
||
<!-- old docs anchors for index page, all link to first steps --> | ||
<a id="own-projects"></a> | ||
<a id="adding-deps"></a> | ||
<a id="foreign-projects"></a> | ||
<a id="advanced-usage"></a> | ||
|
||
## Starting a new project | ||
## DUB Basics | ||
|
||
You can also skip ahead to [First steps](getting-started/first-steps.md) if you already have dub installed. | ||
DUB is a build tool similar to other modern languages build tools like Javascript's [npm](https://www.npmjs.com/) | ||
and Rust's [cargo](https://crates.io/). | ||
|
||
A [recipe file](dub-guide/recipe.md) called `dub.sdl` (or `dub.json`) is used to configure a DUB project. | ||
|
||
> [SDL](https://sdlang.org/) is a "Simple Declarative Language" that uses a familiar C syntax. | ||
> Whether to use SDL or JSON for the DUB file is a [matter of taste](https://forum.dlang.org/thread/[email protected]). | ||
|
||
User/System-wide default settings can be specified in a [settings file](dub-reference/settings.md). | ||
|
||
A recipe file may look like this: | ||
|
||
```sdl | ||
name "myproject" | ||
description "A minimal D application." | ||
authors "My Name" | ||
copyright "Copyright © 2024, My Name" | ||
license "Boost" | ||
|
||
dependency "libasync" version="~>0.9.5" | ||
|
||
configuration "library" { | ||
targetPath "target/lib" | ||
} | ||
|
||
configuration "unittest" { | ||
dependency "tested" version="~>0.9.5" | ||
dependency "dshould" version="~>1.7.1" | ||
targetPath "target/test" | ||
} | ||
``` | ||
|
||
[DUB Configurations](dub-reference/configurations.md) are used to create different variations of a project. | ||
|
||
In the above example, all configurations include a dependency on `libasync` because that's declared at the top-level, | ||
but only the `unittest` configuration includes the dependencies `tested` and `dshould`. | ||
|
||
To build a project, run [`dub build`](cli-reference/dub-build/) (or just `dub`). | ||
|
||
As a project is built, DUB automatically resolves, downloads and builds its dependencies as needed. | ||
|
||
The resolved dependency versions are stored in a file next to the recipe file, called [dub.selections.json](dub-guide/selections.md), | ||
which is similar to a lock file. | ||
|
||
When running `dub test`, all [Unit Tests](https://tour.dlang.org/tour/en/gems/unittesting) found in | ||
[sourcePaths](dub-reference/build_settings.md#sourcepaths) are executed using the `unittest` configuration by default. | ||
|
||
To specify a configuration explicitly when building, use the `--config` option: | ||
|
||
``` | ||
dub build --config=library | ||
``` | ||
|
||
DUB also uses the concept of [build types](dub-reference/buildtypes.md) to define what to build. Many build types are | ||
pre-defined, but the most common ones are `debug` and `release`. | ||
|
||
Hence, to build the release version of a library, the following command could be used: | ||
|
||
``` | ||
dub build --config=library --build=release | ||
``` | ||
|
||
Finally, to run the application, use `dub run`. | ||
|
||
Check [Building](dub-guide/building.md) for more details. | ||
|
||
## Next Steps | ||
|
||
[First Steps](getting-started/first-steps.md) completes this overview of the basic DUB workflow. | ||
|
||
The [DUB Guide](dub-guide/recipe.md) goes into more details about building, testing, configuring dependencies and registries, | ||
shared libraries, publishing packages and more. | ||
|
||
More experienced users can use the [DUB Reference](dub-reference/recipe.md) and [CLI Reference](cli-reference/dub/) | ||
for a comprehensive list of the available options. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note for yourself: There is a longstanding bug in dub and that is currently not the case. But we intend to fix it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh... but does the test lib actually get included in the compiled binaries?