diff --git a/src/dlangide/builders/builder.d b/src/dlangide/builders/builder.d index f13213e..dc0ada7 100644 --- a/src/dlangide/builders/builder.d +++ b/src/dlangide/builders/builder.d @@ -171,3 +171,52 @@ class Builder : BackgroundOperationWatcher { } } +string[] splitByLines(string s) { + string[] res; + int start = 0; + for(int i = 0; i <= s.length; i++) { + if (i == s.length) { + if (start < i) + res ~= s[start .. i]; + break; + } + if (s[i] == '\r' || s[i] == '\n') { + if (start < i) + res ~= s[start .. i]; + start = i + 1; + } + } + return res; +} + +string[] detectImportPathsForCompiler(string compiler) { + string[] res; + import std.process : executeShell; + import std.string : startsWith, indexOf; + import std.path : buildNormalizedPath; + import std.file : write, remove; + import dlangui.core.files; + try { + string sourcefilename = appDataPath(".dlangide") ~ PATH_DELIMITER ~ "tmp_dummy_file_to_get_import_paths.d"; + write(sourcefilename, "import module_that_does_not_exist;\n"); + auto ls = executeShell("\"" ~ compiler ~ "\" \"" ~ sourcefilename ~ "\""); + remove(sourcefilename); + string s = ls.output; + string[] lines = splitByLines(s); + debug Log.d("compiler output:\n", s); + foreach(line; lines) { + if (line.startsWith("import path[")) { + auto p = line.indexOf("] = "); + if (p > 0) { + line = line[p + 4 .. $]; + string path = line.buildNormalizedPath; + debug Log.d("import path found: `", line, "`"); + res ~= line; + } + } + } + return res; + } catch (Exception e) { + return null; + } +} diff --git a/src/dlangide/ui/frame.d b/src/dlangide/ui/frame.d index f22ea9d..b29dc7e 100644 --- a/src/dlangide/ui/frame.d +++ b/src/dlangide/ui/frame.d @@ -682,6 +682,14 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL _logPanel = new OutputPanel("output"); _logPanel.compilerLogIssueClickHandler = &onCompilerLogIssueClick; _logPanel.appendText(null, "DlangIDE is started\nHINT: Try to open some DUB project\n"d); + dumpCompilerPaths(); + + _dockHost.addDockedWindow(_logPanel); + + return _dockHost; + } + + private void dumpCompilerPaths() { string dubPath = findExecutablePath("dub"); string rdmdPath = findExecutablePath("rdmd"); string dmdPath = findExecutablePath("dmd"); @@ -690,12 +698,24 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL _logPanel.appendText(null, dubPath ? ("dub path: "d ~ toUTF32(dubPath) ~ "\n"d) : ("dub is not found! cannot build projects without DUB\n"d)); _logPanel.appendText(null, rdmdPath ? ("rdmd path: "d ~ toUTF32(rdmdPath) ~ "\n"d) : ("rdmd is not found!\n"d)); _logPanel.appendText(null, dmdPath ? ("dmd path: "d ~ toUTF32(dmdPath) ~ "\n"d) : ("dmd compiler is not found!\n"d)); + dumpCompilerPath("DMD", dmdPath); _logPanel.appendText(null, ldcPath ? ("ldc path: "d ~ toUTF32(ldcPath) ~ "\n"d) : ("ldc compiler is not found!\n"d)); + dumpCompilerPath("LDC", ldcPath); _logPanel.appendText(null, gdcPath ? ("gdc path: "d ~ toUTF32(gdcPath) ~ "\n"d) : ("gdc compiler is not found!\n"d)); - - _dockHost.addDockedWindow(_logPanel); - - return _dockHost; + dumpCompilerPath("GDC", gdcPath); + } + private void dumpCompilerPath(dstring compilerName, string compiler) { + if (!compiler) + return; + if (compiler) { + string[] imports = detectImportPathsForCompiler(compiler); + if (imports.length > 0) { + Log.d(compilerName, " imports:", imports); + _logPanel.appendText(null, compilerName ~ " imports:\n"d); + foreach(s; imports) + _logPanel.appendText(null, " "d ~ to!dstring(s) ~ "\n"d); + } + } } private MenuItem _projectConfigurationMenuItem;