What's the D way of application version numbers?

Dejan Lekic dejan.lekic at gmail.com
Mon Jan 13 07:05:54 PST 2014


On Sunday, 12 January 2014 at 18:36:19 UTC, Russel Winder wrote:
> With C++ and Python, it is idiomatic to put the application 
> version
> number in a separate file that can then be processed by the 
> build
> system. For C++ a config file is constructed defining a macro 
> that is
> then used in the rest of the course. For Python the file is 
> read at
> runtime to define a variable. The build system itself uses the 
> version
> number for creating deb, RPM, egg, wheel, etc. packages.
>
> D has no macro processing so C++ idioms are not useful. D does 
> create a
> standalone executable and so the Python approach of reading the 
> file at
> initialization time seems inappropriate.
>
> Is there a known D idiom for this?
>
> Thanks.

I simply define version in my main module (module which contains 
the main() function). I am planning to submit a DIP about 
something that is related to this. - I think we really need a way 
to specify version of package, and maybe even version of a module 
(similar to how the new Java module system works - see project 
Jigsaw). D does not offer this. I humbly believe it should be 
part of the language as it could be used also for building 
versions of dynamic libraries.

Anyway, back to the topic.
Say my main() function is in the org.dlang.myapp module.
If I want to have information about version of the artifact, my 
myapp.d starts with the following two lines of D code:
module org.dlang.myapp;
version = 1_3_21_4; // major_minor_micro_qualifier

Naturally, build tool looks for the version line when I need it.


More information about the Digitalmars-d-learn mailing list