www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Find out druntime/import and phobos folder on Linux

reply Andre Pany <andre s-e-a-p.de> writes:
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
Jul 14 2018
next sibling parent reply Anonymouse <asdf asdf.net> writes:
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.
Jul 14 2018
parent reply Andre Pany <andre s-e-a-p.de> writes:
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é
Jul 14 2018
next sibling parent Mike Franklin <slavo5150 yahoo.com> writes:
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
Jul 14 2018
prev sibling parent Timoses <timosesu gmail.com> writes:
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
Jul 15 2018
prev sibling parent reply Seb <seb wilzba.ch> writes:
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: --- /+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
Jul 15 2018
parent Andre Pany <andre s-e-a-p.de> writes:
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: --- /+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
Jul 15 2018