www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - DUB specify version identifier on command line?

reply XavierAP <n3minis-git yahoo.es> writes:
I'm talking about the conditional compilation keyword "version", 
not about version strings. I've looked in DUB's help and 
reference [1][2] but can't seem to find how to solve my problem. 
On the command line it seems to be possible to specify debug 
identifiers, but not version identifiers. [3]

It came up while trying to do something specific, so I'll explain 
this. I'm learning and trying things, and I was playing with 
dlib.core.memory. Before moving to the next thing I wanted to try 
printMemoryLog(). This outputs memory debugging info, only when 
compiled with version(MemoryDebug) [3].

I'm working with Visual D. However for 3rd party package 
dependencies it's simpler to compile them with dub, and have VS 
find the lib for my client project. Without the version 
identifier, my program works: compiles, links to dlib, and runs 
ok. Then I instruct VS to define version(MemoryDebug) for some 
configuration. No matter how I re-run dub to build dlib, I get 
linking errors from the additional functions defined in the 
imported dlib source which aren't found in the binary lib.

I guess it's also possible to specify this by adding to the 
dub.json file [2], but for me it's more flexible if I can leave 
it alone and compile different versions from the command line 
alone. But if the json is the only way please let me know. 
Otherwise what am I missing? Thanks in advance.


[1] http://code.dlang.org/docs/commandline#build
[2] http://code.dlang.org/package-format?lang=json#version-specs
[3] https://dlang.org/spec/version.html#DebugCondition
[4] 
https://github.com/gecko0307/dlib/blob/master/dlib/core/memory.d
Mar 07
parent reply Nicholas Wilson <iamthewilsonator hotmail.com> writes:
On Tuesday, 7 March 2017 at 22:30:30 UTC, XavierAP wrote:
 I'm talking about the conditional compilation keyword 
 "version", not about version strings. I've looked in DUB's help 
 and reference [1][2] but can't seem to find how to solve my 
 problem. On the command line it seems to be possible to specify 
 debug identifiers, but not version identifiers. [3]

 It came up while trying to do something specific, so I'll 
 explain this. I'm learning and trying things, and I was playing 
 with dlib.core.memory. Before moving to the next thing I wanted 
 to try printMemoryLog(). This outputs memory debugging info, 
 only when compiled with version(MemoryDebug) [3].

 I'm working with Visual D. However for 3rd party package 
 dependencies it's simpler to compile them with dub, and have VS 
 find the lib for my client project. Without the version 
 identifier, my program works: compiles, links to dlib, and runs 
 ok. Then I instruct VS to define version(MemoryDebug) for some 
 configuration. No matter how I re-run dub to build dlib, I get 
 linking errors from the additional functions defined in the 
 imported dlib source which aren't found in the binary lib.

 I guess it's also possible to specify this by adding to the 
 dub.json file [2], but for me it's more flexible if I can leave 
 it alone and compile different versions from the command line 
 alone. But if the json is the only way please let me know. 
 Otherwise what am I missing? Thanks in advance.


 [1] http://code.dlang.org/docs/commandline#build
 [2] http://code.dlang.org/package-format?lang=json#version-specs
 [3] https://dlang.org/spec/version.html#DebugCondition
 [4] 
 https://github.com/gecko0307/dlib/blob/master/dlib/core/memory.d
Setting version identifiers is done by the `-version=ident` command line flag (this is equivalent to `version = ident` at source level) . This should therefore be settable by the "dflags" dub configuration setting. The way I would do it would be to have a custom configuration that sets "dflags" : [ "other normal flags", "-version= MemoryDebug"] and then build the MemoryDebug dub configuration. Hope that makes sense.
Mar 07
parent XavierAP <n3minis-git yahoo.es> writes:
On Wednesday, 8 March 2017 at 02:15:00 UTC, Nicholas Wilson wrote:
 Setting version identifiers is done by the `-version=ident` 
 command line flag (this is equivalent to `version = ident` at 
 source level) .
 This should therefore be settable by the "dflags" dub 
 configuration setting.

 The way I would do it would be to have a custom configuration 
 that sets "dflags" : [ "other normal flags", "-version= 
 MemoryDebug"]

 and then build the MemoryDebug dub configuration.

 Hope that makes sense.
Yes... Although I was looking for a command line parameter for dub, not dmd, but apparently it's impossible. So thanks for pointing to the DFLAGS possibility, it has worked. :) I still prefer this for building different versions rather than changing the dub.json file every time. Thanks!
Mar 08