digitalmars.D - Finding the D compiler programatically.
- Nathan Petrelli (8/8) Mar 06 2007 My program needs to call DMD / GDC to compile a generated class. So, how...
- Charlie (4/18) Mar 06 2007 I think searching path on windows is a good idea, you could do the same
- Hasan Aljudy (8/22) Mar 06 2007 Searching %PATH% is your only option, but even that theoretically
- Andrei Alexandrescu (See Website For Email) (4/17) Mar 06 2007 The standard method is to not look in hardcoded places, but instead in
- Bill Baxter (10/30) Mar 06 2007 Speaking of which, can we have a community consensus on what to call
My program needs to call DMD / GDC to compile a generated class. So, how can I find where the user installed it's dmd.exe / gdc on windows and linux? Right now I'm checking the following paths to see if it exists: C:\dmd\bin\dmd.exe C:\Program Files\dmd\bin\dmd.exe any folder in %PATH% and similar algorithm for GDC on linux but it doesn't seems like a very good idea to check all those paths. Is there a better way? Thanks.
Mar 06 2007
Nathan Petrelli wrote:My program needs to call DMD / GDC to compile a generated class. So, how can I find where the user installed it's dmd.exe / gdc on windows and linux? Right now I'm checking the following paths to see if it exists: C:\dmd\bin\dmd.exe C:\Program Files\dmd\bin\dmd.exe any folder in %PATH% and similar algorithm for GDC on linux but it doesn't seems like a very good idea to check all those paths. Is there a better way? Thanks.I think searching path on windows is a good idea, you could do the same on linux, or 'which dmd' should report it ? Charlie
Mar 06 2007
Searching %PATH% is your only option, but even that theoretically doesn't suffice, for all you know, the user could have his dmd renamed to dlang.exe dcomp.exe or something not even remotely related to d, like euiDEfpD3dW.exe :) or, maybe dmd.exe isn't even in %PATH%; maybe the user has a python script that he invokes to compile his projects (in this case, the script will be the one that knows the real path to dmd). Nathan Petrelli wrote:My program needs to call DMD / GDC to compile a generated class. So, how can I find where the user installed it's dmd.exe / gdc on windows and linux? Right now I'm checking the following paths to see if it exists: C:\dmd\bin\dmd.exe C:\Program Files\dmd\bin\dmd.exe any folder in %PATH% and similar algorithm for GDC on linux but it doesn't seems like a very good idea to check all those paths. Is there a better way? Thanks.
Mar 06 2007
Nathan Petrelli wrote:My program needs to call DMD / GDC to compile a generated class. So, how can I find where the user installed it's dmd.exe / gdc on windows and linux? Right now I'm checking the following paths to see if it exists: C:\dmd\bin\dmd.exe C:\Program Files\dmd\bin\dmd.exe any folder in %PATH% and similar algorithm for GDC on linux but it doesn't seems like a very good idea to check all those paths. Is there a better way? Thanks.The standard method is to not look in hardcoded places, but instead in $PATH and then in the $DMD_HOME variable that your documentation publishes. Andrei
Mar 06 2007
Andrei Alexandrescu (See Website For Email) wrote:Nathan Petrelli wrote:Speaking of which, can we have a community consensus on what to call DMD_HOME (and what it should point to)? I use DMDDIR currently and set it so that $DMDDIR\dmd\bin\dmd.exe works. I think I started using ***DIR for environment variables at some point in the past because I saw other projects using it. I can't remember which now, but at least I think that's what Qt uses (QTDIR). Anyway, I don't care what it is, as long as it's a community standard and I can badger anyone who uses a different environment variable. --bbMy program needs to call DMD / GDC to compile a generated class. So, how can I find where the user installed it's dmd.exe / gdc on windows and linux? Right now I'm checking the following paths to see if it exists: C:\dmd\bin\dmd.exe C:\Program Files\dmd\bin\dmd.exe any folder in %PATH% and similar algorithm for GDC on linux but it doesn't seems like a very good idea to check all those paths. Is there a better way? Thanks.The standard method is to not look in hardcoded places, but instead in $PATH and then in the $DMD_HOME variable that your documentation publishes.
Mar 06 2007