Skip to content

Commit 9c945ed

Browse files
committed
Update: Better documentation of redub features
1 parent 46d11a9 commit 9c945ed

File tree

2 files changed

+123
-88
lines changed

2 files changed

+123
-88
lines changed

META.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Project Meta
2+
3+
4+
## Making it faster
5+
Have you ever wondered why [dub](https://github.com/dlang/dub) was slow? I tried solving it, but its codebase was fairly unreadable. After building this project, I've implemented features that dub don't use
6+
7+
- Lazy build project configuration evaluation
8+
- Parallelization on build sorted by dependency
9+
- Faster JSON parsing
10+
- Fully parallelized build when only link is waiting for dependencies
11+
12+
### Philosophy
13+
14+
- Separate build system from package manager.
15+
- Have total backward compatibility on dub for initial versions.
16+
- On initial versions, develop using phobos only
17+
- Make it less stateful.
18+
- Achieve at least 90% of what dub does.
19+
- Isolate each process. This will make easier for adding and future contributors
20+
21+
## Achieving it
22+
23+
### Legend
24+
- api -> Can be freely be imported from any module
25+
- module -> Needs to be isolated as much as possible from each module. If one needs to communicate with other, a bridge/api may be created after the initial idea
26+
27+
### How it works
28+
Here are described the modules which do most of the work if someone wants to contribute.
29+
30+
- buildapi: Defines the contents of build configurations, tree of projects and commons for them
31+
- parsers.json: Parse dub.json into a build configuration
32+
- parsers.automatic: Parse using an automatic parser identification
33+
- cli.dub + app: Parse CLI to get the build root and an initial build configuration
34+
- parsers.environment: Merge environment variables into build configuration
35+
- tree_generators.dub: Output build dependency tree while merging their configurations
36+
- command_generator.automatic: Convert build configuration into compilation flags
37+
- buildapi + building.compile: Transform build tree into dependency order tree
38+
- building.compile: Spawn build processes for the dependencies until it links
39+
40+
41+
### Contributor Attracting
42+
- Isolate module as much as possible to attract contributors working on self contained modules which only gets input and returns an output
43+
44+
### Starting small
45+
- No need to handle edge cases in the beginning. They may become even separate modules.
46+
47+
### A week project
48+
- This project had a small start. I gave one week for doing it, but since it was very succesful on its
49+
achievements, I decided to extend a little the deadline for achieving support.
50+
Right now, it has been tested with
51+
52+
### Working examples
53+
Those projects were fairly tested while building this one
54+
- dub
55+
- glui
56+
- dplug
57+
- arsd-official
58+
- Hipreme Engine

README.md

Lines changed: 65 additions & 88 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,67 +94,45 @@ Redub has also an experimental support for building and linking C/C++ code toget
9594
}
9695
```
9796

98-
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
99-
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.
100-
101-
You can see that in the example project: [**Multi Language Redub Project**](./tests/multi_lang/dub.json)
102-
103-
104-
# Project Meta
105-
106-
107-
## Making it faster
108-
Have you ever wondered why [dub](https://github.com/dlang/dub) was slow? I tried solving it, but its codebase was fairly unreadable. After building this project, I've implemented features that dub don't use
109-
110-
- Lazy build project configuration evaluation
111-
- Parallelization on build sorted by dependency
112-
- Faster JSON parsing
113-
- Fully parallelized build when only link is waiting for dependencies
97+
## Using its library API
11498

115-
### Philosophy
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
116102

117-
- Separate build system from package manager.
118-
- Have total backward compatibility on dub for initial versions.
119-
- On initial versions, develop using phobos only
120-
- Make it less stateful.
121-
- Achieve at least 90% of what dub does.
122-
- Isolate each process. This will make easier for adding and future contributors
103+
```d
104+
import redub.api;
105+
import redub.logging;
123106
124-
## Achieving it
107+
void main()
108+
{
109+
import std.file;
110+
//Enables logging on redub
111+
setLogLevel(LogLevel.verbose);
125112
126-
### Legend
127-
- api -> Can be freely be imported from any module
128-
- module -> Needs to be isolated as much as possible from each module. If one needs to communicate with other, a bridge/api may be created after the initial idea
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+
);
129120
130-
### How it works
131-
Here are described the modules which do most of the work if someone wants to contribute.
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+
*/
132125
133-
- buildapi: Defines the contents of build configurations, tree of projects and commons for them
134-
- parsers.json: Parse dub.json into a build configuration
135-
- parsers.automatic: Parse using an automatic parser identification
136-
- cli.dub + app: Parse CLI to get the build root and an initial build configuration
137-
- parsers.environment: Merge environment variables into build configuration
138-
- tree_generators.dub: Output build dependency tree while merging their configurations
139-
- command_generator.automatic: Convert build configuration into compilation flags
140-
- buildapi + building.compile: Transform build tree into dependency order tree
141-
- building.compile: Spawn build processes for the dependencies until it links
126+
//Execute the build process
127+
buildProject(d);
128+
}
129+
```
142130

143131

144-
### Contributor Attracting
145-
- Isolate module as much as possible to attract contributors working on self contained modules which only gets input and returns an output
132+
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
133+
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.
146134

147-
### Starting small
148-
- No need to handle edge cases in the beginning. They may become even separate modules.
135+
You can see that in the example project: [**Multi Language Redub Project**](./tests/multi_lang/dub.json)
149136

150-
### A week project
151-
- This project had a small start. I gave one week for doing it, but since it was very succesful on its
152-
achievements, I decided to extend a little the deadline for achieving support.
153-
Right now, it has been tested with
154137

155-
### Working examples
156-
Those projects were fairly tested while building this one
157-
- dub
158-
- glui
159-
- dplug
160-
- arsd-official
161-
- Hipreme Engine
138+
[**Project Meta**](META.md)

0 commit comments

Comments
 (0)