How to correctly deal with dmd.conf with multiple dmd installations - [ref osx, brew, digger]

aliak something at something.com
Thu Sep 27 19:53:32 UTC 2018


On Wednesday, 26 September 2018 at 01:17:24 UTC, Vladimir 
Panteleev wrote:
> On Tuesday, 25 September 2018 at 10:34:17 UTC, aliak wrote:
>> When you do `digger install` it seems to not “install” a 
>> `dmd.conf` but it does install the `dmd` binary in 
>> `/usr/local/bin/dmd` - but that wasn’t built with `SYSCONFDIR` 
>> so it doesn’t find `/usr/local/etc/dmd.conf` either, but even 
>> if it did, that’s the wrong `dmd.conf` (i.e. not the one that 
>> the build was based on - so would it even point to the right 
>> env?).
>
> The solution I'm thinking of for Digger is to attempt to detect 
> the SYSCONFDIR of the current `dmd` binary in `PATH`, and use 
> that by default when Digger builds D. Doing so would break 
> Digger's "maximally reproducible builds" policy a little, so 
> we'd need to be loud about it.

Can you explain a bit maybe how it'd break the maximally 
reproducible builds with an example? I believe you might've 
mentioned that in the issue linked but I didn't quite get it.

>
> An alternative would be to complain loudly when attempting to 
> build or (especially) install a compiler with a mismatching 
> SYSCONFDIR, but still proceed with the default.

So let's say dmd in PATH is olddmd and the one we want to build 
with digger is newdmd.

For the first option, are you suggesting:
* digger build newdmd
   1. confFileName = parseFileNameFrom(olddmd -v | grep Config)
   2. build dmd with SYSCONFDIR=pluckPathFrom(confFileName)

If yes, then that means the newdmd would use olddmd's phobos/lib 
right?

Another idea: create a $HOME/.digger dir at build time. Then 
digger build could set SYSCONFDIR=$HOME/.digger. And newdmd in 
work/result/bin/will be fine because there's a dmd.conf near the 
exe that gets priority.

digger install (assuming `which dmd` = /usr/local/bin/dmd)
- if exists(/usr/bin/local/olddmd)
   move olddmd -> $HOME/.digger/uninstall/ (with whatever else you 
need)
- if exists($HOME/dmd.conf)
   move it to $HOME/.digger/uninstall/ (with metadata saying where 
it came form)
- copy newdmd to /usr/bin/local/
- copy work/result/import to $HOME/.digger/import
- copy work/result/lib to $HOME/.digger/lib
- write a new dmd.conf to $HOME/.digger with contents:
"""
[Environment]
DFLAGS=-I$HOME/.digger/import -L-L$HOME/.digger/lib
"""

/usr/local/bin/newdmd will pick up the dmd.conf that was just 
written and point to the correct includes and lib because 
SYSCONFDIR was set at build time, and $HOME/dmd.conf was moved 
during installation (from the link Jonathan posted it seems like 
that would be necessary because it's given priority over 
SYSCONFDIR).

An uninstall will move $HOME/.digger/uninstall/olddmd and 
dmd.conf back to their places and remove contents of $HOME/.digger

In my head at least that works and keeps the current behavior as 
is. I'm not sure about Windows though because I'm not too 
familiar with paths, permissions, etc.

PS: I would be happy to help to get osx + brew working with your 
"maximal reproducibility" given time and guidance.

Cheers,
- Ali





More information about the Digitalmars-d mailing list