| 1 |
# Dlang module |
| 2 |
|
| 3 |
This module provides tools related to the D programming language. |
| 4 |
|
| 5 |
## Usage |
| 6 |
|
| 7 |
To use this module, just do: **`dlang = import('dlang')`**. |
| 8 |
You can, of course, replace the name `dlang` with anything else. |
| 9 |
|
| 10 |
The module only exposes one function, `generate_dub_file`, used to |
| 11 |
automatically generate Dub configuration files. |
| 12 |
|
| 13 |
### generate_dub_file() |
| 14 |
This method only has two required arguments, the project name and the |
| 15 |
source folder. You can pass other arguments with additional keywords, |
| 16 |
they will be automatically translated to json and added to the |
| 17 |
`dub.json` file. |
| 18 |
|
| 19 |
**Structure** |
| 20 |
```meson |
| 21 |
generate_dub_file("project name", "source/folder", key: "value" ...) |
| 22 |
``` |
| 23 |
|
| 24 |
**Example** |
| 25 |
```meson |
| 26 |
dlang = import('dlang') |
| 27 |
dlang.generate_dub_file(meson.project_name().to_lower(), meson.source_root(), |
| 28 |
authors: 'Meson Team', |
| 29 |
description: 'Test executable', |
| 30 |
copyright: 'Copyright © 2018, Meson Team', |
| 31 |
license: 'MIT', |
| 32 |
sourceFiles: 'test.d', |
| 33 |
targetType: 'executable', |
| 34 |
dependencies: my_dep |
| 35 |
) |
| 36 |
``` |
| 37 |
|
| 38 |
You can manually edit a Meson generated `dub.json` file or provide a |
| 39 |
initial one. The module will only update the values specified in |
| 40 |
`generate_dub_file()`. |
| 41 |
|
| 42 |
Although not required, you will need to have a `description` and |
| 43 |
`license` if you want to publish the package in the [D package |
| 44 |
registry](https://code.dlang.org/). |