How add "version.txt" Version File by Command Line or by resources.res using dmd.exe

mipri mipri at minimaltype.com
Sun Dec 8 20:56:05 UTC 2019


On Sunday, 8 December 2019 at 20:50:05 UTC, Marcone wrote:
> I want to add version to my program.
> I have configurated my version file "version.txt",  but I dont 
> know how link this file to my program. If Need spec file, 
> please send the exemple code of spec. Or is is possible add 
> version file by dmd command line or resources. Thank you.

I'm not sure I know what you're asking, but maybe this is
the answer.

In version.txt:

   0.1.0 - a version example

In version.d:

   import std.string : chomp;

   immutable Version = import("version.txt").chomp;

   void main() {
       import std.stdio : writeln;
       writeln("Version: ", Version);
   }

To compile and run with both files in the current directory:

   dmd -J. -run version

With output:

   Version: 0.1.0 - a version example

The corresponding dub setting is probably stringImportPaths


More information about the Digitalmars-d-learn mailing list