Skip to content

Commit 29b1c17

Browse files
committed
Update: Better documentation of redub features
1 parent 46d11a9 commit 29b1c17

File tree

1 file changed

+69
-35
lines changed

1 file changed

+69
-35
lines changed

README.md

Lines changed: 69 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,50 @@
11
# Redub - Dub Based Build System
22
[![Update release and nightly](https://github.com/MrcSnm/redub/actions/workflows/ci.yml/badge.svg)](https://github.com/MrcSnm/redub/actions/workflows/ci.yml)
33

4-
5-
## Running redub without having it on path
4+
## Redub for dub users
65
- Change directory to the project you want to build and enter in terminal `dub run redub`
7-
- You may also get help by running `dub run redub -- --help`
8-
- If you're unsure on how to update redub to the latest version using dub, you may also do `dub run redub -- update`
6+
> To fully take advantage of redub speed, you might as well use redub directly.
97
108
## Building redub
11-
- Enter in terminal and execute `dub`
9+
- Enter in terminal and execute [`dub`](https://github.com/dlang/dub)
1210
- Highly recommended that you build it with `dub build -b release-debug --compiler=ldc2` since this will also improve its speed on dependency resolution
13-
- I would also add redub/bin to the environment variables, with that, you'll be able to simply execute `redub` in the folder you're in and get your project built and running
14-
- After having your first redub version, you may also update redub by entering on terminal `redub update`. This will download the latest version, rebuild redub with optimizations and replace your current redub executable
1511

16-
## Using its library API
1712

18-
The usage of the library APIispretty straightforward. You get mainly 2 functions
19-
1. `resolveDependencies` which will parse the project and its dependencies, after that, you got all the project information
20-
2. `buildProject` which will get the project information and build in parallel
13+
# Redub Additions
14+
Those are the additions I've made over dub
15+
- **Self Update**: `redub update` will either sync to the latest repo (and build it) or replace it with latest release
16+
- [**Compiler Management**](#compiler-management) - Support to change default compiler and install on command line
17+
- [**Redub Plugins**](#redub-plugins) - Alternative to rdmd. Execute arbitrary D code in the build steps.
18+
- [**Multi Language**](#multi-language) - Compile a C project together and include it on the linking step
19+
- [**Library API**](#using-its-library-api) - Integrate redub directly in your application
20+
- **Watching Directories** - `redub watch`- Builds dependents automatically on changes. Add `--run` to run the program after building.
21+
- **MacOS Universal Builds** - `redub build-universal` - Generates a single binary containing arm64 and x86_64 architectures on MacOS
2122

22-
```d
23-
import redub.api;
24-
import redub.logging;
2523

26-
void main()
27-
{
28-
import std.file;
29-
//Enables logging on redub
30-
setLogLevel(LogLevel.verbose);
24+
## Redub Help
25+
- [Original Dub Documentation](https://dub.pm/)
26+
- You may also get help by running `dub run redub -- --help` or simply `redub --help`
3127

32-
//Gets the project information
33-
ProjectDetails d = resolveDependencies(
34-
invalidateCache: false,
35-
std.system.os,
36-
CompilationDetails("dmd", "arch not yet implemented", "dmd v[2.105.0]"),
37-
ProjectToParse("configuration", getcwd(), "subPackage", "path/to/dub/recipe.json (optional)")
38-
);
3928

40-
/** Optionally, you can change some project information by accessing the details.tree (a ProjectNode), from there, you can freely modify the BuildRequirements of the project
41-
* d.tree.requirements.cfg.outputDirectory = "some/path";
42-
* d.tree.requirements.cfg.dFlags~= "-gc";
43-
*/
4429

45-
//Execute the build process
46-
buildProject(d);
47-
}
48-
```
30+
## Compiler Management
31+
- Installing new compilers, use `redub install`:
32+
```
33+
redub install requires 1 additional argument:
34+
opend: installs opend
35+
ldc <version?|help>: installs ldc latest if version is unspecified.
36+
help: Lists available ldc versions
37+
dmd <version?>: installs the dmd with the version 2.111.0 if version is unspecified
38+
```
39+
- Using the new compilers, use `redub use` - Redub use will also install if you don't already have it:
40+
```
41+
redub use requires 1 additional argument:
42+
opend <dmd|ldc>: uses the wanted opend compiler as the default
43+
ldc <version?>: uses the latest ldc latest if version is unspecified.
44+
dmd <version?>: uses the 2.111.0 dmd if the version is unspecified.
45+
reset: removes the default compiler and redub will set it again by the first one found in the PATH environment variable
46+
```
47+
4948

5049
## Redub Plugins
5150

@@ -82,7 +81,7 @@ For using it on prebuild, you simply specify the module and its arguments:
8281
}
8382
```
8483

85-
### Useful links regarding plugins:
84+
**Useful links regarding plugins:**
8685
- [**GetModule plugin**](./plugins/getmodules/source/getmodules.d)
8786
- [**Example Usage**](./tests/plugin_test/dub.json)
8887

@@ -95,6 +94,41 @@ Redub has also an experimental support for building and linking C/C++ code toget
9594
}
9695
```
9796

97+
## Using its library API
98+
99+
The usage of the library APIispretty straightforward. You get mainly 2 functions
100+
1. `resolveDependencies` which will parse the project and its dependencies, after that, you got all the project information
101+
2. `buildProject` which will get the project information and build in parallel
102+
103+
```d
104+
import redub.api;
105+
import redub.logging;
106+
107+
void main()
108+
{
109+
import std.file;
110+
//Enables logging on redub
111+
setLogLevel(LogLevel.verbose);
112+
113+
//Gets the project information
114+
ProjectDetails d = resolveDependencies(
115+
invalidateCache: false,
116+
std.system.os,
117+
CompilationDetails("dmd", "arch not yet implemented", "dmd v[2.105.0]"),
118+
ProjectToParse("configuration", getcwd(), "subPackage", "path/to/dub/recipe.json (optional)")
119+
);
120+
121+
/** Optionally, you can change some project information by accessing the details.tree (a ProjectNode), from there, you can freely modify the BuildRequirements of the project
122+
* d.tree.requirements.cfg.outputDirectory = "some/path";
123+
* d.tree.requirements.cfg.dFlags~= "-gc";
124+
*/
125+
126+
//Execute the build process
127+
buildProject(d);
128+
}
129+
```
130+
131+
98132
With that, you'll be able to specify that your dependency is a C/C++ dependency. then, you'll be able to build it by calling `redub --cc=gcc`. You can also
99133
specify both D and C at the same time `redub --cc=gcc --dc=dmd`. Which will use DMD to build D and GCC to C.
100134

0 commit comments

Comments
 (0)