1
1
module book.build ;
2
2
import std;
3
- void compileToPath (string compileThis, string outputPath)
3
+ void compileToPath (string compileThis, string outputPath, bool loud = false )
4
4
{
5
5
import core.stdc.stdlib ;
6
6
if (outputPath.indexOf(" cozum" ) == - 1 )
7
7
{
8
- writeln( " wow " );
9
- writeln(outputPath.replace(" .html" , " .cozum.html" ));
8
+ if (loud)
9
+ writeln(outputPath.replace(" .html" , " .cozum.html" ));
10
10
// exit(0);
11
11
}
12
12
13
13
const compileString = format! " dmd -revert=markdown -D macros.ddoc html.ddoc dlang.org.ddoc doc.ddoc aliBook.ddoc %s -Df%s " (compileThis, outputPath);
14
- writefln! " %s:%s |> %s" (compileThis, outputPath, compileString);
14
+ if (loud)
15
+ writefln! " %s:%s |> %s" (compileThis, outputPath, compileString);
15
16
const res = executeShell(compileString);
16
- writeln(" \t\t " , res.status);
17
17
18
18
if (res.status != 0 ) {
19
19
write(res.output);
20
20
21
21
exit(0 );
22
22
}
23
23
}
24
- int main ()
24
+ int main (string [] args )
25
25
{
26
+ const jobs = args.length == 2 ? args[1 ].to! ubyte : 1 ;
26
27
const outDir = " ../web/book" ;
27
28
writeln(" Building the book at " , outDir);
28
29
// scope(failure) return 1;
@@ -31,13 +32,11 @@ int main()
31
32
if (outDir.exists) {
32
33
executeShell(" rm -rf " ~ outDir);
33
34
}
34
- writeln(" Building book files" );
35
35
auto rng = dirEntries(" d.en" , " *.d" , SpanMode.shallow)
36
36
.map! (dFile => tuple(dFile.name, buildPath(outDir, baseName(dFile).setExtension(" html" ))))
37
- // .parallel(1 )
37
+ .parallel(jobs )
38
38
.each! (elem => compileToPath(elem.tupleof));
39
39
dirEntries(" d.en" , " *.png" , SpanMode.shallow)
40
40
.each! (p => copy(p, buildPath(outDir, baseName(p).setExtension(" png" ))));
41
- writeln(" Finished" );
42
41
return 0 ;
43
42
}
0 commit comments