www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - DUB: Is it possible to set release as a default build for a dub

reply BoQsc <vaidas.boqsc gmail.com> writes:
While using `dub`, you might notice that after running `dub` or 
`dub run` command you will end up with notice:

```
Starting Performing "debug" build using 
C:\D\dmd2\windows\bin64\dmd.exe for x86_64.
```

Example output:

```
C:\Users\Windows10\Documents\Dlang winsock\datatypes>dub
      Pre-gen Running commands for datatypes
              Public Domain. No rights reserved.
     Starting Performing "debug" build using 
C:\D\dmd2\windows\bin64\dmd.exe for x86_64.
     Building datatypes 0.0.0: building configuration [application]
      Linking datatypes
      Running builds/datatypes.exe
```

**Question:** is it possible to set it to release build in a 
`dub.json` or `dub.sdl` file?

Yes, it is possible using command line `dub --build=release`

```
C:\Users\Windows10\Documents\Dlang winsock\datatypes>dub 
--build=release
      Pre-gen Running commands for datatypes
              Public Domain. No rights reserved.
     Starting Performing "release" build using 
C:\D\dmd2\windows\bin64\dmd.exe for x86_64.
     Building datatypes 0.0.0: building configuration [application]
      Linking datatypes
      Running builds/datatypes.exe
```

However I would want to try to enforce this behaviour from the 
`dub.json` or `dub.sdl` file.
Nov 03 2023
next sibling parent reply Andrey Zherikov <andrey.zherikov gmail.com> writes:
On Friday, 3 November 2023 at 19:21:42 UTC, BoQsc wrote:
 However I would want to try to enforce this behaviour from the 
 `dub.json` or `dub.sdl` file.
IMHO this is not something that should be enforced from package build configuration, however there can be a way to configure it on system level (like in `dub.conf` if it exists).
Nov 03 2023
parent BoQsc <vaidas.boqsc gmail.com> writes:
On Friday, 3 November 2023 at 21:57:57 UTC, Andrey Zherikov wrote:
 On Friday, 3 November 2023 at 19:21:42 UTC, BoQsc wrote:
 However I would want to try to enforce this behaviour from the 
 `dub.json` or `dub.sdl` file.
IMHO this is not something that should be enforced from package build configuration, however there can be a way to configure it on system level (like in `dub.conf` if it exists).
Unsure what's `dub.conf` but I've found this additional settings file. [%ROOT_PACKAGE_DIR%\dub.settings.json](https://dub.pm/settings) As of now, unable to find a way to begin enforce release. Maybe there is no such setting.
Nov 04 2023
prev sibling parent Jonathan M Davis <newsgroup.d jmdavisprog.com> writes:
On Friday, November 3, 2023 1:21:42 PM MDT BoQsc via Digitalmars-d-learn 
wrote:
 While using `dub`, you might notice that after running `dub` or
 `dub run` command you will end up with notice:

 ```
 Starting Performing "debug" build using
 C:\D\dmd2\windows\bin64\dmd.exe for x86_64.
 ```

 Example output:

 ```
 C:\Users\Windows10\Documents\Dlang winsock\datatypes>dub
       Pre-gen Running commands for datatypes
               Public Domain. No rights reserved.
      Starting Performing "debug" build using
 C:\D\dmd2\windows\bin64\dmd.exe for x86_64.
      Building datatypes 0.0.0: building configuration [application]
       Linking datatypes
       Running builds/datatypes.exe
 ```

 **Question:** is it possible to set it to release build in a
 `dub.json` or `dub.sdl` file?

 Yes, it is possible using command line `dub --build=release`

 ```
 C:\Users\Windows10\Documents\Dlang winsock\datatypes>dub
 --build=release
       Pre-gen Running commands for datatypes
               Public Domain. No rights reserved.
      Starting Performing "release" build using
 C:\D\dmd2\windows\bin64\dmd.exe for x86_64.
      Building datatypes 0.0.0: building configuration [application]
       Linking datatypes
       Running builds/datatypes.exe
 ```

 However I would want to try to enforce this behaviour from the
 `dub.json` or `dub.sdl` file.
I would suggest that you just use a script to run the command that you want. AFAIK, the only way to make "dub build" do anything different would be to change the definition of the default build config in your project's dub.json file, but that's going to be _very_ surprising to anyone else using your project and might cause issues if it's a project that other projects end up depending on. - Jonathan M Davis
Nov 04 2023