docs: add documentation related to dub and the dlang module

pull/3893/head
FFY00 7 years ago
parent ec01a77421
commit a477737637
No known key found for this signature in database
GPG Key ID: 46F633CBB0EB4BF2
  1. 5
      docs/markdown/D.md
  2. 19
      docs/markdown/Dependencies.md
  3. 41
      docs/markdown/Dlang-module.md
  4. 1
      docs/sitemap.txt

@ -87,3 +87,8 @@ executable('myapp', myapp_src, dependencies: [mylib_dep])
Please keep in mind that the library and executable would both need to be built with the exact same D compiler and D compiler version. The D ABI is not
stable across compilers and their versions, and mixing compilers will lead to problems.
# Integrating with DUB
DUB is a fully integrated build system for D, but it is also a way to provide dependencies. Adding dependencies from the [D package registry](https://code.dlang.org/) is pretty straight forward.
You can find how to do this in [Dependencies](Dependencies.md#Dub). You can also automatically generate a `dub.json` file as explained in [Dlang](Dlang-module.md#generatedubfile).

@ -186,6 +186,25 @@ have been compiled for single-threaded use instead.
`method` may be `auto`, `config-tool`, `pkg-config` or `extraframework`.
## Dub
Use `method` to find dependencies with Dub. Just create a dependency as you would normally, but add `dub` as the dependency method.
```meson
urld_dep = dependency('urld', method: 'dub')
```
If the dependency is not resolved using Dub, meson will still try to find it with Pkg-Config.
Please understand that meson is only able to find existing dependencies. You still need to manually fetch and build them with Dub.
```
dub fetch urld
dub build urld
```
Other thing you need to keep in mind is that both meson and Dub need to be using the same compiler. This can be achieved using Dub's `-compiler` argument and/or manually setting the `DC` environment variable when running meson.
```
dub build urld --compiler=dmd
DC="dmd" meson builddir
```
## GL
This finds the OpenGL library in a way appropriate to the platform.

@ -0,0 +1,41 @@
# Dlang module
This module provides tools related to the D programming language.
## Usage
To use this module, just do: **`dlang = import('dlang')`**.
You can, of course, replace the name `dlang` with anything else.
The module only exposes one funtion, `generate_dub_file`, used to automatically generate Dub configuration files.
### generate_dub_file()
This method only has two required arguments, the project name and the source folder.
You can pass other arguments with additional keywords, they will be automatically translated to json and added to the `dub.json` file.
**Structure**
```meson
generate_dub_file("project name", "source/folder", key: "value" ...)
```
**Example**
```meson
dlang = import('dlang')
dlang.generate_dub_file(meson.project_name().to_lower(), meson.source_root(),
authors: 'Meson Team',
description: 'Test executable',
copyright: 'Copyright © 2018, Meson Team',
license: 'MIT',
sourceFiles: 'test.d',
targetType: 'executable',
dependencies: my_dep
)
```
You can manually edit a meson generated `dub.json` file or provide a initial one.
The module will only update the values specified in `generate_dub_file()`.
Although not required, you will need to have a `description` and `license` if you want to publish the package in the [D package registry](https://code.dlang.org/).
Other thing to keep in mind is that currently, the module ignores `configurations`, `subConfigurations`, and `buildTypes`.
You can configure that directly in `dub.json`.

@ -39,6 +39,7 @@ index.md
RPM-module.md
Simd-module.md
Windows-module.md
Dlang-module.md
Java.md
Vala.md
D.md

Loading…
Cancel
Save