DUB doesn't seem to respect my config, am I doing something wrong?

Steven Schveighoffer schveiguy at gmail.com
Sun May 23 15:00:37 UTC 2021


On 5/23/21 3:17 AM, rempas wrote:
> On Sunday, 23 May 2021 at 04:56:18 UTC, Mike Parker wrote:
>> I just looked in the dub documentation for "build" and "compiler" 
>> entries, which I had never heard of, and I see none now. As Jordan 
>> said, those have always been configured on the command line. Did you 
>> perhaps see something about those somewhere else?
>>
>> FYI, the first configuration you define is always the default, so you 
>> don't need to specify it on the command line unless you really want to.
> 
> I've saw the SDL format config documentation 
> [here](https://dub.pm/package-format-sdl.html#configurations). Maybe I'm 
> wrong idk...
> 

The "build types" section is saying what the EQUIVALENT build types are 
when passing on command line.

In your recipe file, you seem to be mixing build types and 
configurations (it's confusing, I agree). I look at configs like setting 
up which files to compile, which versions to use, which dependencies to 
use, etc. build types have more to do with flags to send to the compiler 
(like optimization flags, or whether to include bounds checks). dub uses 
the base build type, and then configurations may also alter those 
settings. You can think of the two options as orthogonal (build type and 
configuration).

I think most of your file can be removed, what you seem to want is 2 
things: set the compiler to ldc and set some flags based on configuration

Here's how I would do it:

```sdl
name "test"
description "Testing dub"
authors "rempas"
copyright "Copyright © 2021, rempas"
license "AGPL-3.0"
toolchainRequirements dmd="no" gdc="no" // only allow ldc

buildType "release" {
    dflags "-Oz"
}
```

Note that you don't use the "release" build type using "--config", you 
use -b release

-Steve


More information about the Digitalmars-d-learn mailing list