Chapter 27. Common Attributes

This is the first paragraph of Common Attributes.

For the "virtual" and "comment" see Chapter 25.
Attributes can be added to a node with the ":attr" command and by using them
in a dependency or rule.  Note that an assignment does not directly associate
the attribute with a node.  This only happens when the variable is used in an
":attr" command or dependency.


STICKY ATTRIBUTES

When attributes are used in a rule or dependency, most of them are only used
for that dependency.  But some attributes are "sticky": Once used for an item
they are used everywhere for that item.  Sticky attributes are:
	virtual			virtual target, not a file
	remember		virtual target that is remembered
	directory		item is a directory
	filetype		type of file
	constant		file contents never changes
	fetch			list of locations where to fetch from (first
				one that works is used)
	commit			list of locations for VCS
	publish			list of locations to publish to (they are all
				used)
	force			rebuild a target always
	depdir			directory to put an automatically generated
				dependency file in; when omitted $BDIR is used
	signfile		file used to store signatures for this target


SIGNATURES: the check attribute

The default check for a file that was changed is an md5 checksum.  Each time a
recipe is executed the checksums for the relevant items are computed and
stored in the file "aap/sign".  The next time the recipe is executed the
current and the old checksums are compared.  When they are different, the
build commands are executed.  This means that when you put back an old version
of a file, rebuilding will take place even though the timestamp of the source
might be older than the target.

Another check can be specified with {check = name}.  Example:

	foo.txt : foo.db {check = time}
		:sys db_extract $source >$target

Other types of signatures supported:

	time		Build the target when the timestamp of the source
			differs from the last time the target was build.

	newer		Build the target if its timestamp is older than the
			timestamp of the source.  This is what the good old
			"make" program uses.
	
	md5		Build the target if the md5 checksum of the source
			differs from the last time the target was build.
			This is the default.
	
	c_md5		Like "md5", but ignore changes in comments and amount
			of white space.  Appropriate for C programs. Slows
			down computations considerably.

	none		Don't check time or contents, only existence.  Used
			for directories.

When mixing "newer" with other methods, the build rules are executed if the
target is older than the source with the "newer" check, or when one of the
signatures for the other items differs.

The "aap/sign" file is normally stored in the directory of the target.  This
means it will be found even when using several recipes that produce the same
target.  But for targets that get installed in system directories (use an
absolute path), virtual targets and remote targets this is avoided.  For these
targets the "aap/sign" file is stored in the directory of the recipe that
specifies how to build the target.

To overrule the directory where "AAP/sign" is written, use the attribute
{signdirectory = name} for the target.
To overrule the file where the signatures are written, use the attribute
{signfile = name} for the target.  "name" cannot end in "sign".