Thread overview
DUB doesn't seem to respect my config, am I doing something wrong?
May 22, 2021
rempas
May 23, 2021
Jordan Wilson
May 23, 2021
rempas
May 23, 2021
Mike Parker
May 23, 2021
rempas
May 23, 2021
rempas
May 23, 2021
Guillaume Piolat
May 23, 2021
rempas
May 22, 2021

I've read the documentation about DUB's config (I'm using the SDL format) and it seems that DUB completely ignores my config. My config file is:

name "test"
description "Testing dub"
authors "rempas"
copyright "Copyright © 2021, rempas"
license "AGPL-3.0"
compiler "ldc2"

configuration "development" {
  platforms "linux"
  build "dubug"
  compiler "ldc2"
  targetType "executable"
}

configuration "release" {
  platforms "linux"
  dflags "-Oz" platform="/bin/ldc2"
  build "release"
  compiler "ldc2"
  targetType "executable"
}

I'm compiling using dub --config=development and I'm getting the following line: Performing "debug" build using /usr/bin/dmd for x86_64. The same exactly happens when I'm trying to do the release config. If I disable the targetType option, it seems that it's creating a library and I can also manually change the compiler and the build-type so I don't know what's going on....

May 23, 2021

On Saturday, 22 May 2021 at 20:28:56 UTC, rempas wrote:

>

I've read the documentation about DUB's config (I'm using the SDL format) and it seems that DUB completely ignores my config. My config file is:

name "test"
description "Testing dub"
authors "rempas"
copyright "Copyright © 2021, rempas"
license "AGPL-3.0"
compiler "ldc2"

configuration "development" {
  platforms "linux"
  build "dubug"
  compiler "ldc2"
  targetType "executable"
}

configuration "release" {
  platforms "linux"
  dflags "-Oz" platform="/bin/ldc2"
  build "release"
  compiler "ldc2"
  targetType "executable"
}

I'm compiling using dub --config=development and I'm getting the following line: Performing "debug" build using /usr/bin/dmd for x86_64. The same exactly happens when I'm trying to do the release config. If I disable the targetType option, it seems that it's creating a library and I can also manually change the compiler and the build-type so I don't know what's going on....

Ignoring the "dubug" typo...normally, I think you pass compiler values directly to dub via the --compiler flag. For example:

dub --config=development --compiler=ldc2

Note: you can also pass "debug" and "release" builds (among others), like so:

dub -b "debug" --compiler=ldc2

Passing in the compiler allows any end user building your code to use whatever compiler they want. Otherwise, something like toolchainRequirements dmd="no" ldc=">=1.21.0" may achieve what you want.

Thanks,

Jordan

May 23, 2021

On Saturday, 22 May 2021 at 20:28:56 UTC, rempas wrote:

>

I'm compiling using dub --config=development and I'm getting the following line: Performing "debug" build using /usr/bin/dmd for x86_64. The same exactly happens when I'm trying to do the release config. If I disable the targetType option, it seems that it's creating a library and I can also manually change the compiler and the build-type so I don't know what's going on....

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.

May 23, 2021

On Sunday, 23 May 2021 at 00:36:48 UTC, Jordan Wilson wrote:

>

On Saturday, 22 May 2021 at 20:28:56 UTC, rempas wrote:

>

[...]

Ignoring the "dubug" typo...normally, I think you pass compiler values directly to dub via the --compiler flag. For example:

dub --config=development --compiler=ldc2

Note: you can also pass "debug" and "release" builds (among others), like so:

dub -b "debug" --compiler=ldc2

Passing in the compiler allows any end user building your code to use whatever compiler they want. Otherwise, something like toolchainRequirements dmd="no" ldc=">=1.21.0" may achieve what you want.

Thanks,

Jordan

Hi, and thanks a lot for your time. Yes I fixed the typo. Passing values directly works like I said but I'm wondering why choosing a config won't effect things like the compiler or the build type. Anyway, have a nice day my friend!

May 23, 2021

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. Maybe I'm wrong idk...

May 23, 2021

On Saturday, 22 May 2021 at 20:28:56 UTC, rempas wrote:

>

I'm compiling using dub --config=development and I'm getting the following line: Performing "debug" build using /usr/bin/dmd for x86_64. The same exactly happens when I'm trying to do the release config. If I disable the targetType option, it seems that it's creating a library and I can also manually change the compiler and the build-type so I don't know what's going on....

Hello,

DUB has two separate concepts:

- buildTypes: default ones are debug, release, release-debug, release-nobounds
  They
  You can define custom buildTypes.
  Selected with -b
  https://dub.pm/package-format-json.html#build-types
  By default, "debug" build type.


- configurations are more often used to define software options
  You can define custom configurations.
  Selected with -c
  By default the first one in your file is taken, else it's a default configuration.

People use configurations to define example programs or platform builds (probably becase buildTypes are limited), but they are primarily intended for enabling or disabling features in software.

May 23, 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
May 23, 2021
On Sunday, 23 May 2021 at 15:00:37 UTC, Steven Schveighoffer wrote:
> The "build types" section is saying what the EQUIVALENT build types are when passing on command line.
>
> [...]

This will do it! Thanks a lot!
May 23, 2021

On Sunday, 23 May 2021 at 09:45:06 UTC, Guillaume Piolat wrote:

>

On Saturday, 22 May 2021 at 20:28:56 UTC, rempas wrote:

>

[...]

Hello,

DUB has two separate concepts:

[...]

Thanks a lot man!