Skip to content

Commit 34aa0e7

Browse files
committed
rdmd.d: Capture stderr when calculating dependencies
When invoking the compiler to calculate dependencies capture both stdout and stderr since gdc's verbose output goes to stderr. Signed-off-by: Andrei Horodniceanu <a.horodniceanu@proton.me>
1 parent 1a8c1a9 commit 34aa0e7

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

rdmd.d

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ int main(string[] args)
140140
string[] eval; // set by --eval
141141
bool makeDepend;
142142
string makeDepFile;
143-
143+
144144
try
145145
{
146146
getopt(argsBeforeProgram,
@@ -182,7 +182,7 @@ int main(string[] args)
182182
if (!compiler)
183183
{
184184
compiler = defaultCompiler;
185-
185+
186186
// Look for the D compiler rdmd invokes automatically in the same directory as rdmd
187187
// and fall back to using the one in your path otherwise.
188188
string compilerPath = buildPath(dirName(thisExePath()), compiler ~ binExt);
@@ -576,7 +576,7 @@ private int rebuild(string root, string fullExe,
576576
// Run a program optionally writing the command line first
577577
// If "replace" is true and the OS supports it, replace the current process.
578578

579-
private int run(string[] args, string output = null, bool replace = false)
579+
private int run(string[] args, string output = null, bool replace = false, bool captureStderr = false)
580580
{
581581
import std.conv;
582582
yap(replace ? "exec " : "spawn ", args.text);
@@ -599,7 +599,7 @@ private int run(string[] args, string output = null, bool replace = false)
599599
outputFile = File(output, "wb");
600600
else
601601
outputFile = stdout;
602-
auto process = spawnProcess(args, stdin, outputFile);
602+
auto process = spawnProcess(args, stdin, outputFile, captureStderr ? outputFile : stderr);
603603
return process.wait();
604604
}
605605

@@ -744,7 +744,9 @@ private string[string] getDependencies(string rootModule, string workDir,
744744
collectException(Filesystem.remove(depsFilename));
745745
}
746746

747-
immutable depsExitCode = run(depsGetter, depsFilename);
747+
// gdc prints -v on stderr, ldc2 and dmd use stdout
748+
immutable depsExitCode = run(depsGetter, depsFilename,
749+
/*replace=*/false, /*captureStderr=*/true);
748750
if (depsExitCode)
749751
{
750752
stderr.writefln("Failed: %s", depsGetter);

0 commit comments

Comments
 (0)