The D ecosystem in Debian with free-as-in-freedom DMD

Matthias Klumpp via Digitalmars-d digitalmars-d at puremagic.com
Tue Apr 11 08:17:08 PDT 2017


On Tuesday, 11 April 2017 at 14:43:15 UTC, Russel Winder wrote:
> On Tue, 2017-04-11 at 14:21 +0000, Matthias Klumpp via 
> Digitalmars-d wrote:
>> 
> […]
>> At time I am playing around with the idea of using 
>> pkg-config[1]
>> files to enlist the sources a D library consists of.
>> By doing that, we would have a very build-system agnostic way 
>> of
>> doing storing that information that can be used by Automake
>> (native), Dub, Meson and even plain Makefiles. It's also very
>> widely used (although it is commonly not used to list sources).
>
> And SCons.
>
> What about CMake? (Which is the CLion build system using Make 
> underneath, but they are rapidly moving to supporting Ninja.)

CMake supports this as well: 
https://cmake.org/cmake/help/v3.0/module/FindPkgConfig.html

The current idea is in case a library "foobar" would be packaged, 
to have a "foobar-src.pc" pkgconfig file (additionally to a 
potentially also existing "foobar.pc" file), containing something 
like this:

```
prefix=/usr/local
exec_prefix=${prefix}
includedir=${prefix}/include/d/foo

Name: foobar
Description: The foo library (sources)
Version: 1.0.0
Cflags: -I${includedir} -d-version=blahblub
Sources: ${includedir}/alpha.d ${includedir}/beta.d 
${includedir}/gamma.d
```

Build systems would then need to explicitly fetch the Sources 
field and add its expanded values to the project's sources.
(Using Cflags for this would be messy, as the build system might 
want to deal with flags and sources separately).

Alternatively dub could also define a layout and we write plugins 
for each build-system to make it work.

This will be really annoying with large libraries like GtkD 
though, which will require substantially longer to build. Maybe 
it's worth keeping some libraries precompiled (thereby locking 
all their reverse-dependencies to whatever D compiler was used to 
compile the library).

One problem with the pkg-config approach is that to support the 
precompiled case too, build systems would need to search for both 
"foobar" and "foobar-src" and only fail dependency detection if 
both of them are missing.

At least with CMake/Meson that's easy to do though (although it's 
a bit messy).


More information about the Digitalmars-d mailing list