Skip to content
Merged
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
45 changes: 35 additions & 10 deletions source/served/utils/stdlib_detect.d
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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('\\', '/');

Expand Down Expand Up @@ -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)
Expand Down
Loading