Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rdmd.d: Capture stderr when calculating dependencies #469

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions rdmd.d
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ int main(string[] args)
string[] eval; // set by --eval
bool makeDepend;
string makeDepFile;

try
{
getopt(argsBeforeProgram,
Expand Down Expand Up @@ -182,7 +182,7 @@ int main(string[] args)
if (!compiler)
{
compiler = defaultCompiler;

// Look for the D compiler rdmd invokes automatically in the same directory as rdmd
// and fall back to using the one in your path otherwise.
string compilerPath = buildPath(dirName(thisExePath()), compiler ~ binExt);
Expand Down Expand Up @@ -576,7 +576,7 @@ private int rebuild(string root, string fullExe,
// Run a program optionally writing the command line first
// If "replace" is true and the OS supports it, replace the current process.

private int run(string[] args, string output = null, bool replace = false)
private int run(string[] args, string output = null, bool replace = false, bool captureStderr = false)
{
import std.conv;
yap(replace ? "exec " : "spawn ", args.text);
Expand All @@ -599,7 +599,7 @@ private int run(string[] args, string output = null, bool replace = false)
outputFile = File(output, "wb");
else
outputFile = stdout;
auto process = spawnProcess(args, stdin, outputFile);
auto process = spawnProcess(args, stdin, outputFile, captureStderr ? outputFile : stderr);
return process.wait();
}

Expand Down Expand Up @@ -744,7 +744,9 @@ private string[string] getDependencies(string rootModule, string workDir,
collectException(Filesystem.remove(depsFilename));
}

immutable depsExitCode = run(depsGetter, depsFilename);
// gdc prints -v on stderr, ldc2 and dmd use stdout
immutable depsExitCode = run(depsGetter, depsFilename,
/*replace=*/false, /*captureStderr=*/true);
if (depsExitCode)
{
stderr.writefln("Failed: %s", depsGetter);
Expand Down
Loading