Am 15.06.2015 um 09:01 schrieb Rory:

On Wed, 23 Jul 2014 09:53:09 GMT, Sönke Ludwig wrote:
...

Is there a field for specifying the compiler to use in dub.json? I'd basically like to have separate configurations for compiling with dmd and gdc (because one is 64bit and the other 32) and I was wondering if this option is available. For now I'll just batch file it, but I was curious as I can't find anything.

This is something that is only controllable from the outside. So having a batch file that runs something like dub build --arch=x86_64 --compiler=GDC would be about the only solution so far.

If this turns out to be a more frequent need, we could think about adding a new feature for that - either something in dub.json, or maybe in a separate dub-build-list.json (or similar) file.

Hi Sonke,

I'm finding using gdc useful to avoid bugs in the dmd compiler, why do you have compiler agnostic config options but no way to define a specific compiler?

Would be great to have different configs set up for each compiler in my dub.json file.

Does this exist now?

Cheers,
Rory

You can use the "platforms" field in a configuration section to create
configurations for specific compilers:

{
   "name": "my-package",
   "configurations": [
     {
       "name": "gdc-stuff",
       "platforms": ["gdc"]
     }
   ]
}

However, usually you'd just use platform suffixes for compiler specific
settings (e.g. "buildOptions-gdc": [...]), as it keeps things closer
together and produces less redundant package descriptions.

The thing with both of these approaches is that the user will still have
to select the compiler used. So even if there is only a single
configuration for "gdc", DUB will try the default compiler and just
errors out if that doesn't happen to be GDC.

The design goal has always been to try to make packages automatically
cross-platform and cross-compiler compatible if possible, so
artificially forcing a package to a particular compiler would probably
go a little too far. But I see at least two possible approaches that
would still make sense to implement:

  • Having a "preferredCompilers" field in the build description, which
    contains a priority ordered list of compiler binary names
  • Letting the list of installed compilers participate in the
    configuration resolution process, thus automatically choosing a matching
    compiler instead of the default one if the choices are limited.