|
1 | 1 | module served.utils.stdlib_detect;
|
2 | 2 |
|
3 | 3 | import std.algorithm : countUntil, splitter, startsWith;
|
4 |
| -import std.array : appender, replace; |
| 4 | +import std.array : Appender, appender, replace; |
5 | 5 | import std.ascii : isWhite;
|
6 | 6 | import std.conv : to;
|
7 | 7 | import std.experimental.logger : trace, warning;
|
@@ -359,9 +359,39 @@ bool parseDmdConfImports(R)(R confPath, scope const(char)[] confDirPath, out str
|
359 | 359 |
|
360 | 360 | bool parseLdcConfImports(string confPath, scope const(char)[] binDirPath, out string[] paths)
|
361 | 361 | {
|
362 |
| - import external.ldc.config; |
| 362 | + Appender!(string[]) ret; |
| 363 | + scope(exit) paths = ret.data; |
363 | 364 |
|
364 |
| - auto ret = appender!(string[]); |
| 365 | + import std.algorithm; |
| 366 | + import std.array; |
| 367 | + import std.file; |
| 368 | + |
| 369 | + if (confPath.isDir) |
| 370 | + { |
| 371 | + auto configFiles = confPath.dirEntries(SpanMode.shallow) |
| 372 | + .filter!`a.isFile` |
| 373 | + .map!`a.name` |
| 374 | + // FIXME this should be numeric sort |
| 375 | + .array |
| 376 | + .sort; |
| 377 | + |
| 378 | + import std.conv; |
| 379 | + trace("the config files are: ", text(configFiles)); |
| 380 | + |
| 381 | + foreach (file; configFiles) |
| 382 | + parseLdcConfImportsSingleFile(file, binDirPath, ret); |
| 383 | + } |
| 384 | + else |
| 385 | + parseLdcConfImportsSingleFile(confPath, binDirPath, ret); |
| 386 | + |
| 387 | + if (!ret.data.length) |
| 388 | + warning("failed to find phobos/druntime paths in ldc conf ", confPath, " - going to continue looking elsewhere..."); |
| 389 | + return ret.data.length > 0; |
| 390 | +} |
| 391 | + |
| 392 | +void parseLdcConfImportsSingleFile(string confPath, scope const(char)[] binDirPath, ref Appender!(string[]) ret) |
| 393 | +{ |
| 394 | + import external.ldc.config; |
365 | 395 |
|
366 | 396 | binDirPath = binDirPath.replace('\\', '/');
|
367 | 397 |
|
@@ -401,11 +431,6 @@ bool parseLdcConfImports(string confPath, scope const(char)[] binDirPath, out st
|
401 | 431 | parseSection(cast(GroupSetting) s);
|
402 | 432 | }
|
403 | 433 | }
|
404 |
| - |
405 |
| - paths = ret.data; |
406 |
| - if (!ret.data.length) |
407 |
| - warning("failed to find phobos/druntime paths in ldc conf ", confPath, " - going to continue looking elsewhere..."); |
408 |
| - return ret.data.length > 0; |
409 | 434 | }
|
410 | 435 |
|
411 | 436 | deprecated string[] parseDflagsImports(scope const(char)[] options, bool windows)
|
|
0 commit comments