make dub use my version of dmd

Steven Schveighoffer schveiguy at gmail.com
Fri Apr 17 12:19:14 UTC 2020


On 4/17/20 4:37 AM, WebFreak001 wrote:
> On Thursday, 16 April 2020 at 19:56:44 UTC, Adam D. Ruppe wrote:
>> For future reference, newer dubs (v 1.17 + i think) allow 
>> --compiler=dmd-version for example.
>>
>> You need to put the exe in your PATH and rename it yourself, but it 
>> recognizes *dmd-* (or *ldc2-* or *gdc-*) all the same so you can 
>> specifiy them.
>>
>> I was doing that in early versions of my android thing, i made a 
>> program "android-ldc" and then did "dub build --compiler=android-ldc" 
>> and it all worked.
>>
>> S o you can do that with versions too.

Sure, it does all that. But if you have a broken symlink in the same 
directory as the dub executable it tries to use that first.

> 
> Also you can use `dub --compiler=/path/to/dmd` (or ldc, or gdc) and it 
> magically know the compiler type, though maybe it knows because of the 
> filename.

Yes, I think that is what was happening. I had a broken symlink in 
~/bin/dmd, and it complained about not being able to get the version 
from it.

I mistakenly thought it couldn't find a dmd in that directory, and it 
wasn't willing to use my path DMD. Then I tried the same dub binary on a 
different machine and it successfully found the dmd in my path. Which is 
when I realized something was different between the two installations.

But one thing I DID learn, is that if you have your path set to one 
compiler's dmd, and specifically call another compiler's dub, it will 
use the dmd in that dub's directory rather than your path. So you do 
have to copy it elsewhere (or use the --compiler option).

-Steve


More information about the Digitalmars-d-learn mailing list