Find out druntime/import and phobos folder on Linux

Seb seb at wilzba.ch
Sun Jul 15 09:17:31 UTC 2018


On Saturday, 14 July 2018 at 17:19:20 UTC, Andre Pany wrote:
> Hi,
>
> The IntelliJ D Language plugin has support for D-scanner and 
> DCD. Both tools needs to know the paths to druntime/import and 
> Phobos source folder.
> In IntelliJ you set the path to the folder where dmd binary is 
> located. Based on this information on Windows and MacOS it is 
> possible to determine the paths.
>
> The code can be found here
> https://github.com/intellij-dlanguage/intellij-dlanguage/blob/develop/src/main/java/io/github/intellij/dlanguage/codeinsight/dcd/DCDCompletionServer.java#L180
>
> I want to provide a fix that the paths are also automatically 
> determined on Linux correctly but I do not have much Linux 
> experience.
>
> Is there a way to find out both paths based on the dmd 
> executable folder?
>
> What I found out so far, these paths are not always correct:
> /usr/include/dmd/druntime/import
> /usr/include/dmd/phobos
>
> Kind regards
> Andre

DMD: 
https://github.com/dlang/dmd/blob/master/src/dmd/dinifile.d#L40
LDC: https://wiki.dlang.org/Using_LDC, 
https://github.com/dlang/dmd/blob/master/src/dmd/frontend.d#L97

Once you have the config file, simply parse the config files: 
https://github.com/dlang/dmd/blob/master/src/dmd/frontend.d#L156

Anyhow as DMD is on DUB, there's no need for copy/pasting:

---
#!/usr/bin/env dub
/+dub.sdl:
dependency "dmd" version="~master"
+/
void main()
{
     import dmd.frontend;
     import std.stdio;
     findImportPaths().writeln; // will determine the currently 
active "dmd" compiler (can be LDC too)
}
---

DMD's order is a bit annoying, see: 
https://github.com/dlang/dmd/pull/7915


More information about the Digitalmars-d-learn mailing list