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

Topic: Rule Definition File

This file holds the definitions of the rules used to create files using tools other than the D compiler.
 
This feature is not as advanced as the typical makefile abilities but is useful for simple situations. Specifically, it only caters for tools that take a single input file to create the required output file.
 
The default Rule Definition File is called "default.rdf" but this can be changed in the Configuration File. If you don't specify a full path to the file, Bud searches for it. It first first looks in the directory where Bud is installed, and if it is not found there, the scans throught the directories in the PATH environment symbol.
 
The default RDF can also be overridden by the -RDF command line switch.
 
The Rule Definition File is a text file that contains one or more rules. Each rule is defined in a set of lines. The first line in a rule must be the "rule=" line.
Keyword  Mandatory?  Usage 
rule=<name>  Yes  Defines the name of this rule. 
tool=<command pattern>  Yes  Defines the command line to use. 
in=<extension>  No  Specifies the file type (extension) of the input file 
out=<extension>  No  Specifies the file type (extension) of the output file 
in_use=<usage code>  No  Specifies what to do with the input file after the tool has run. The <usage code> can be one of "compile", "link", or "ignore". The default if not specified is "ignore"
out_use=<usage code>  No  Specifies what to do with the output file after the tool has run. The <usage code> can be one of "compile", "link", or "ignore". The default if not specified is "link"

 
Any other line in the file, not starting with one of the above keywords is simply ignored (treated as comments).
 
The "tool=<command pattern>" line can contain special tokens. These are keywords enclosed in braces. At compile time, the tokens are replaced by replacement text taken from the pragma(build) statement that invoked the rule. In addition, Bud also generates some reserved tokens.
Reserved Token  Usage 
@IN  the name of the input file 
@OUT  the name of the output file 
@IBASE  the basename* of the input file. 
@OBASE  the basename* of the output file. 
@IPATH  the path of the input file. 
@OPATH  the path of the output file. 

NOTE: *This is everything up to but not including the final '.' character in the name.

Bud ensures that the outfile's path will exist before the tool is run.

Example: Sample RDF

----- Windows Resource Compiler --------
This uses pragma( build, "<sourcefile>.rc");
----------------
rule=Resources
in=rc
out=res
tool=rc /r {@IN} /fo {@OUT}

----- DMD C linkage --------------------
This uses pragma( build, "<sourcefile>.c", "COPT=<options>", "HDR=<whatever>");
----------------
rule=DMD C/C++
in=c
out=obj
tool=dmc -c {COPT} {@IN} -o{@OUT} {HDR}

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