Thread overview
Find out druntime/import and phobos folder on Linux
Jul 14, 2018
Andre Pany
Jul 14, 2018
Anonymouse
Jul 14, 2018
Andre Pany
Jul 14, 2018
Mike Franklin
Jul 15, 2018
Timoses
Jul 15, 2018
Seb
Jul 15, 2018
Andre Pany
July 14, 2018
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
July 14, 2018
On Saturday, 14 July 2018 at 17:19:20 UTC, Andre Pany wrote:
> 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

Arch Linux and derivatives keep them under /usr/include/dlang/{dmd,gdc,ldc}/*

You may have to hardcode some common paths and try them in each in turn. I'm happy to be proven wrong here though.
July 14, 2018
On Saturday, 14 July 2018 at 19:00:56 UTC, Anonymouse wrote:
> On Saturday, 14 July 2018 at 17:19:20 UTC, Andre Pany wrote:
>> 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
>
> Arch Linux and derivatives keep them under /usr/include/dlang/{dmd,gdc,ldc}/*
>
> You may have to hardcode some common paths and try them in each in turn. I'm happy to be proven wrong here though.

Somehow also the DMD executable needs to know which Phobos/DRuntime it should use.
How does DMD is working here? Maybe I can do the same...

Kind regards
André
July 14, 2018
On Saturday, 14 July 2018 at 19:04:01 UTC, Andre Pany wrote:

> Somehow also the DMD executable needs to know which Phobos/DRuntime it should use.
> How does DMD is working here? Maybe I can do the same...

DMD determines default import and library paths from the dmd.conf file typically at /etc/dmd.conf.

Mike

July 15, 2018
On Saturday, 14 July 2018 at 19:04:01 UTC, Andre Pany wrote:
> On Saturday, 14 July 2018 at 19:00:56 UTC, Anonymouse wrote:
>> On Saturday, 14 July 2018 at 17:19:20 UTC, Andre Pany wrote:
>>> 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
>>
>> Arch Linux and derivatives keep them under /usr/include/dlang/{dmd,gdc,ldc}/*
>>
>> You may have to hardcode some common paths and try them in each in turn. I'm happy to be proven wrong here though.
>
> Somehow also the DMD executable needs to know which Phobos/DRuntime it should use.
> How does DMD is working here? Maybe I can do the same...
>
> Kind regards
> André

Maybe this helps?
https://github.com/dlang/installer/blob/master/linux/dmd_deb.sh#L331
Or check th
July 15, 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
July 15, 2018
On Sunday, 15 July 2018 at 09:17:31 UTC, Seb wrote:
> On Saturday, 14 July 2018 at 17:19:20 UTC, Andre Pany wrote:
>> [...]
>
> 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

Thank you all for the answers. That was exactly the answers I searched for.
The IntelliJ D plugin is written in java/Kotlin so I cannot use dmd here but simple rewrite the logic in java.

Kind regards
Andre