diff --git a/source/served/utils/stdlib_detect.d b/source/served/utils/stdlib_detect.d index f9d81dd..c6a92a4 100644 --- a/source/served/utils/stdlib_detect.d +++ b/source/served/utils/stdlib_detect.d @@ -1,7 +1,7 @@ module served.utils.stdlib_detect; import std.algorithm : countUntil, splitter, startsWith; -import std.array : appender, replace; +import std.array : Appender, appender, replace; import std.ascii : isWhite; import std.conv : to; import std.experimental.logger : trace, warning; @@ -259,8 +259,8 @@ private string getUserHomeDirectoryLDC() { version (Windows) { - import core.sys.windows.windows; import core.sys.windows.shlobj; + import core.sys.windows.windows; wchar[MAX_PATH] buf; HRESULT res = SHGetFolderPathW(null, CSIDL_FLAG_CREATE | CSIDL_APPDATA, null, SHGFP_TYPE @@ -359,9 +359,39 @@ bool parseDmdConfImports(R)(R confPath, scope const(char)[] confDirPath, out str bool parseLdcConfImports(string confPath, scope const(char)[] binDirPath, out string[] paths) { - import external.ldc.config; + Appender!(string[]) ret; + scope(exit) paths = ret.data; - auto ret = appender!(string[]); + import std.algorithm; + import std.array; + import std.file; + + if (confPath.isDir) + { + auto configFiles = confPath.dirEntries(SpanMode.shallow) + .filter!`a.isFile` + .map!`a.name` + // FIXME this should be numeric sort + .array + .sort; + + import std.conv; + trace("the config files are: ", text(configFiles)); + + foreach (file; configFiles) + parseLdcConfImportsSingleFile(file, binDirPath, ret); + } + else + parseLdcConfImportsSingleFile(confPath, binDirPath, ret); + + if (!ret.data.length) + warning("failed to find phobos/druntime paths in ldc conf ", confPath, " - going to continue looking elsewhere..."); + return ret.data.length > 0; +} + +void parseLdcConfImportsSingleFile(string confPath, scope const(char)[] binDirPath, ref Appender!(string[]) ret) +{ + import external.ldc.config; binDirPath = binDirPath.replace('\\', '/'); @@ -394,18 +424,13 @@ bool parseLdcConfImports(string confPath, scope const(char)[] binDirPath, out st catch (Exception e) throw new Exception("Could not read ldc2 config file: " ~ confPath ~ ": " ~ e.msg); - foreach (s; parseConfigFile(confPath)) + foreach (s; settings) { if (s.type == Setting.Type.group && s.name == "default") { parseSection(cast(GroupSetting) s); } } - - paths = ret.data; - if (!ret.data.length) - warning("failed to find phobos/druntime paths in ldc conf ", confPath, " - going to continue looking elsewhere..."); - return ret.data.length > 0; } deprecated string[] parseDflagsImports(scope const(char)[] options, bool windows)