1 module tests.json_build.rules;
2 
3 
4 import reggae;
5 import reggae.json_build;
6 import unit_threaded;
7 
8 
9 @HiddenTest
10 void testLink() {
11     immutable jsonStr = `
12         [{"type": "fixed",
13           "command": {"type": "link", "flags": "-L-M"},
14           "outputs": ["myapp"],
15           "dependencies": {
16               "type": "fixed",
17               "targets":
18               [{"type": "fixed",
19                 "command": {"type": "shell", "cmd":
20                             "dmd -I$project/src -c $in -of$out"},
21                 "outputs": ["main.o"],
22                 "dependencies": {"type": "fixed",
23                                  "targets": [
24                                      {"type": "fixed",
25                                       "command": {}, "outputs": ["src/main.d"],
26                                       "dependencies": {
27                                           "type": "fixed",
28                                           "targets": []},
29                                       "implicits": {
30                                           "type": "fixed",
31                                           "targets": []}}]},
32                 "implicits": {
33                     "type": "fixed",
34                     "targets": []}},
35                {"type": "fixed",
36                 "command": {"type": "shell", "cmd":
37                             "dmd -c $in -of$out"},
38                 "outputs": ["maths.o"],
39                 "dependencies": {
40                     "type": "fixed",
41                     "targets": [
42                         {"type": "fixed",
43                          "command": {}, "outputs": ["src/maths.d"],
44                          "dependencies": {
45                              "type": "fixed",
46                              "targets": []},
47                          "implicits": {
48                              "type": "fixed",
49                              "targets": []}}]},
50                 "implicits": {
51                     "type": "fixed",
52                     "targets": []}}]},
53           "implicits": {
54               "type": "fixed",
55               "targets": []}}]
56 `;
57 
58     const mainObj = Target("main.o", "dmd -I$project/src -c $in -of$out", Target("src/main.d"));
59     const mathsObj = Target("maths.o", "dmd -c $in -of$out", Target("src/maths.d"));
60     const app = link(ExeName("myapp"), [mainObj, mathsObj], Flags("-L-M"));
61 
62     jsonToBuild("", jsonStr).shouldEqual(
63         Build(app));
64 }