Specify dmd or ldc compiler and version in a json dub file?
Joakim via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Aug 8 13:27:37 PDT 2017
On Tuesday, 8 August 2017 at 10:07:54 UTC, data pulverizer wrote:
> 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!
I'll note that you can specify that dub use a particular D
compiler for building all your own D packages, by creating a file
called .dub/settings.json in your home directory, and putting the
full path to the compiler you want in there, like so:
{
"defaultCompiler": "/home/datapulverizer/ldc-1.3/bin/ldc2"
}
Ldc uses a file like that to make sure the dub binary it comes
with uses ldc, not dmd, so you can look at that file for an
example.
However, it sounds like you want to ensure that all users of a
package are forced to use a particular D compiler, while this
will just make sure that your dub binary will always use the D
compiler you want.
More information about the Digitalmars-d-learn
mailing list