Specify dmd or ldc compiler and version in a json dub file?

data pulverizer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Aug 8 03:07:54 PDT 2017


On Tuesday, 8 August 2017 at 09:51:40 UTC, Moritz Maxeiner wrote:
> If your code depends on capabilities of a specific D compiler, 
> I wouldn't depend on build tools for that, I'd make it clear in 
> the source code via conditional compilation [1]:
>
> ---
> version (DigitalMars)
> {
> }
> else version (LDC)
> {
> }
> else
> {
>     static assert (0, "Unsupported D compiler");
> }
> ---
>
> There's no equivalent for the frontend version, though AFAIK.
>
> If it's not your code that needs something compiler specific, 
> but you just want to control which is used, don't use dub as a 
> build tool, use another (cmake, meson, write your own 
> compilation "script" in D), and set it's invocation as a 
> prebuildcommand in the dub package file (make sure dub's source 
> file list is empty).
>
> [1] http://dlang.org/spec/version.html#predefined-versions

Many thanks!


More information about the Digitalmars-d-learn mailing list