Skip to content

Commit

Permalink
Merge pull request #149 from andralex/master
Browse files Browse the repository at this point in the history
Issue 13603 - rdmd: if dmd.conf is missing, always rebuilds the target
  • Loading branch information
MartinNowak committed Oct 15, 2014
2 parents b405e0d + 8962f61 commit 3d87339
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions rdmd.d
Expand Up @@ -270,13 +270,15 @@ int main(string[] args)
// Both exe and buildWitness exist, and exe is older than
// buildWitness. This is the only situation in which we
// may NOT need to recompile.
yap("stat ", buildWitness);
lastBuildTime = buildWitness.timeLastModified(SysTime.min);
}
}
else
{
exe = buildPath(workDir, exeBasename) ~ outExt;
buildWitness = exe;
yap("stat ", buildWitness);
lastBuildTime = buildWitness.timeLastModified(SysTime.min);
}

Expand Down Expand Up @@ -325,18 +327,15 @@ size_t indexOfProgram(string[] args)

void writeDeps(string exe, string root, in string[string] myDeps, File fo)
{
fo.writeln(exe, r": \");
fo.writeln(" ", root, r" \");
fo.writeln(exe, ": \\\n ", root, " \\\n");
foreach (mod, _; myDeps)
{
fo.writeln(" ", mod, r" \");
fo.writeln(" ", mod, " \\");
}
fo.writeln();
fo.writeln(root, ":");
fo.writeln('\n', root, ":");
foreach (mod, _; myDeps)
{
fo.writeln();
fo.writeln(mod, ":");
fo.writeln('\n', mod, ":");
}
}

Expand Down Expand Up @@ -448,7 +447,7 @@ private int rebuild(string root, string fullExe,
{
version (Windows)
fullExe = fullExe.defaultExtension(".exe");

// Delete the old executable before we start building.
yap("stat ", fullExe);
if (!dryRun && exists(fullExe))
Expand Down Expand Up @@ -639,7 +638,14 @@ private string[string] getDependencies(string rootModule, string workDir,
break;

case "config":
result[captures[2].strip()] = null;
auto confFile = captures[2].strip;
// The config file is special: if missing, that's fine too. So
// add it as a dependency only if it actually exists.
yap("stat ", confFile);
if (confFile.exists)
{
result[confFile] = null;
}
break;

case "library":
Expand All @@ -662,12 +668,13 @@ private string[string] getDependencies(string rootModule, string workDir,
if (!force)
{
yap("stat ", depsFilename);
if (exists(depsFilename))
auto depsT = depsFilename.timeLastModified(SysTime.min);
if (depsT > SysTime.min)
{
// See if the deps file is still in good shape
auto deps = readDepsFile();
auto allDeps = chain(rootModule.only, deps.byKey).array;
bool mustRebuildDeps = allDeps.anyNewerThan(timeLastModified(depsFilename));
bool mustRebuildDeps = allDeps.anyNewerThan(depsT);
if (!mustRebuildDeps)
{
// Cool, we're in good shape
Expand Down Expand Up @@ -730,6 +737,7 @@ bool anyNewerThan(in string[] files, SysTime t)
bool result;
foreach (source; taskPool.parallel(files))
{
yap("stat ", source);
if (!result && source.newerThan(t))
{
result = true;
Expand All @@ -748,7 +756,7 @@ private bool newerThan(string source, string target)
{
if (force) return true;
yap("stat ", target);
return source.newerThan(timeLastModified(target, SysTime(0)));
return source.newerThan(target.timeLastModified(SysTime.min));
}

private bool newerThan(string source, SysTime target)
Expand Down Expand Up @@ -832,6 +840,7 @@ string makeEvalFile(string todo)
yap("dirEntries ", pathname);
foreach (DirEntry d; dirEntries(pathname, SpanMode.shallow))
{
yap("stat ", d.name);
if (d.timeLastModified < cutoff)
{
collectException(std.file.remove(d.name));
Expand Down

0 comments on commit 3d87339

Please sign in to comment.