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("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.
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 BUILD 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 build needed to create a new object file for the module.