Skip to content

Commit c8b0e89

Browse files
MoonlightSentineldlang-bot
authored andcommitted
book: Remove timestamps when building with DIFFABLE=1
Insert a custom macro to override the timestamp with a placeholder text. This is already implemented for the HTML files s.t. DAutoTest can provide a proper diff without unrelated changes.
1 parent b6a14e2 commit c8b0e89

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

book/build.d

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import std.file;
66
import std.stdio;
77
import std.exception;
88
import std.path;
9-
void compileToPath(string compileThis, string outputPath, bool loud = false)
9+
10+
void compileToPath(string compileThis, string outputPath, string extraFiles, bool loud = false)
1011
{
1112
import std.compiler;
1213
import core.stdc.stdlib;
@@ -27,7 +28,8 @@ void compileToPath(string compileThis, string outputPath, bool loud = false)
2728
macroOut.writefln!"%s = %s"(key, value);
2829
}
2930
macroOut.flush();
30-
const compileString = format!"dmd -D contextMacros.ddoc macros.ddoc html.ddoc dlang.org.ddoc doc.ddoc aliBook.ddoc %s -Df%s "(compileThis, outputPath);
31+
32+
const compileString = format!"dmd -D contextMacros.ddoc macros.ddoc html.ddoc dlang.org.ddoc doc.ddoc aliBook.ddoc %s %s -Df%s "(extraFiles, compileThis, outputPath);
3133
if(loud)
3234
writefln!"%s:%s |> %s"(compileThis, outputPath, compileString);
3335
const res = executeShell(compileString);
@@ -52,11 +54,15 @@ int main(string[] args)
5254
if(outDir.exists) {
5355
executeShell("rm -rf " ~ outDir);
5456
}
57+
58+
const diffable = environment.get("DIFFABLE", "0") == "1";
59+
const noTimestamp = diffable ? "../nodatetime.ddoc" : "";
60+
5561
dirEntries("d.en", "*.d", SpanMode.shallow)
5662
.map!(dFile => tuple(dFile.name, buildPath(outDir, baseName(dFile).setExtension("html"))))
5763
//.parallel(jobs)
58-
.each!(elem => compileToPath(elem.tupleof));
64+
.each!(elem => compileToPath(elem.tupleof, noTimestamp));
5965
dirEntries("d.en", "*.png", SpanMode.shallow)
6066
.each!(p => copy(p, buildPath(outDir, baseName(p).setExtension("png"))));
6167
return 0;
62-
}
68+
}

0 commit comments

Comments
 (0)