|
2 | 2 |
|
3 | 3 | import std.algorithm, std.array, std.c.stdlib, std.datetime,
|
4 | 4 | std.exception, std.file, std.getopt,
|
5 |
| - std.md5, std.path, std.process, std.regex, |
| 5 | + std.md5, std.parallelism, std.path, std.process, std.regex, |
6 | 6 | std.stdio, std.string, std.typetuple;
|
7 | 7 |
|
8 | 8 | version (Posix)
|
@@ -202,8 +202,7 @@ int main(string[] args)
|
202 | 202 | }
|
203 | 203 |
|
204 | 204 | // Have at it
|
205 |
| - if (isNewer(root, exe) || |
206 |
| - std.algorithm.canFind!(a => isNewer(a, exe))(myDeps.keys)) |
| 205 | + if (isNewer(root, exe) || anyNewerThan(myDeps.keys, exe)) |
207 | 206 | {
|
208 | 207 | immutable result = rebuild(root, exe, objDir, myDeps, compilerFlags,
|
209 | 208 | addStubMain);
|
@@ -455,15 +454,7 @@ private string[string] getDependencies(string rootModule, string objDir,
|
455 | 454 | {
|
456 | 455 | // See if the deps file is still in good shape
|
457 | 456 | auto deps = readDepsFile();
|
458 |
| - bool mustRebuildDeps; |
459 |
| - foreach (source, _; deps) |
460 |
| - { |
461 |
| - if (isNewer(source, depsFilename)) |
462 |
| - { |
463 |
| - mustRebuildDeps = true; |
464 |
| - break; |
465 |
| - } |
466 |
| - } |
| 457 | + bool mustRebuildDeps = anyNewerThan(deps.keys, depsFilename); |
467 | 458 | if (!mustRebuildDeps)
|
468 | 459 | {
|
469 | 460 | // Cool, we're in good shape
|
@@ -498,6 +489,32 @@ private string[string] getDependencies(string rootModule, string objDir,
|
498 | 489 | return readDepsFile();
|
499 | 490 | }
|
500 | 491 |
|
| 492 | +// Is any file newer than the given file? |
| 493 | +bool anyNewerThan(in string[] files, in string file) |
| 494 | +{ |
| 495 | + // Experimental: running isNewer in separate threads, one per file |
| 496 | + if (false) |
| 497 | + { |
| 498 | + foreach (source; files) |
| 499 | + { |
| 500 | + if (isNewer(source, file)) |
| 501 | + { |
| 502 | + return true; |
| 503 | + } |
| 504 | + } |
| 505 | + return false; |
| 506 | + } else { |
| 507 | + foreach (source; taskPool.parallel(files, 1)) |
| 508 | + { |
| 509 | + if (isNewer(source, file)) |
| 510 | + { |
| 511 | + return true; |
| 512 | + } |
| 513 | + } |
| 514 | + return false; |
| 515 | + } |
| 516 | +} |
| 517 | + |
501 | 518 | // Quote an argument in a manner conforming to the behavior of
|
502 | 519 | // CommandLineToArgvW and DMD's response-file parsing algorithm.
|
503 | 520 | // References:
|
|
0 commit comments