Header-Only Library - pragma(root)

Mathias LANG geod24 at gmail.com
Tue Jun 16 13:27:00 UTC 2020


On Monday, 15 June 2020 at 00:55:59 UTC, Adam D. Ruppe wrote:
>
> The other semi-tricky thing is dub's default source layout 
> doesn't follow the convention -i expects due to having the 
> extra source/ directory. So you need to add it with 
> -Iproject/source each time. Or you can automatically rearrange 
> files from a package upon downloading it (just read the 
> `module` declaration and sort it into directories from that 
> under a common `lib` top-level thing. This is actually what I 
> do on my computer and why my arsd repo has most its files at 
> top-level - if you clone the repo in your lib dir, the files 
> are now right at `arsd/cgi.d` etc... which automatically works 
> with the compiler. Zero extra config needed, it all just works. 
> I get a lot of complaints about that layout but this is an 
> objective advantage I don't think a lot of people really 
> realize!)

On the other hand, you rely on the person checking out the 
repository with a specific directory name, which is IMO much 
worse than the dub approach. If I check it out as "arsd-v1.1.1", 
suddenly it breaks, unless I use two DMD flags to solve the 
situation (-I and -mv).
Additionally, many people want to separate their code and their 
diet files / config file / scripts / whatever and having the 
project's source file at the root make this impossible.
So yeah I'll take the dub approach over this any day of the week, 
I just would like dub to generate source/projectname/ and not 
just source/




More information about the Digitalmars-d mailing list