Bud Utility © 2006, Derek Parnell, Melbourne
(table of contents)

Topic: Automatic build number

Automatically incremented build numbering for Modules You can optionally specify that the build utility automatically increments a build number for any module. You do this by supplying a single line in your source code in the form ...
private import <modulename>_bn;
Typically this line is placed immediately after the source file's module statement, but that is not strictly necessary. By having this line in your code, build then uses a file with the suffix "_bn.d" to maintain the current build number for the <modulename>. Note that build will create this file if it doesn't exist. Also note that build will update this file whenever the module file has been updated or its object file needs to be rebuilt, so you really shouldn't modify it manually. Any manual changes will be deleted by build.

Example: If your module is called "parser.d" you would have the lines ...

module parser;
private import parser_bn;
You can access the build number from within the module thus ...
writefln("The application build number is %d", auto_build_number);
You can access the build numbers of other modules in you application by importing the appropriate file and prefixing the references with the module names.

Example:

module parser;  /// This module's name.
private import parser_bn;   /// This module's B/N
private import tokenizer_bn; /// Another module's B/N
. . .
writefln("Builds...");
writefln("  Parser %d", parser_bn.auto_build_number);
writefln("  Tokens %d", tokenizer_bn.auto_build_number);
The "_bn.d" file created by build for this module would look like ...
module parser_bn;
/// This file is automatically maintained by the Bud utility,
/// Please refrain from manually editing it.
long auto_build_number = 77;
Of course the number 77 is just an example. This number would actually start at 1 and increment whenever Bud needed to create a new object file for the module.

Generated by Ddoc, Mon Oct 16 11:03:25 2006