makefile – Makefile Buildcloth Syntax Layer

makefile provides the main interface for managing Makefile output, and is a thin wrapper around the basic functionality for BuildCloth().

class makefile.MakefileCloth(makefile=None)
append_var(variable, value, block='_all')
Parameters:
  • variable (string) – A string that specifies the name of the variable.
  • value (string) – A string that specifies the value of that variable.
  • block (string) – Optional; defaults to _all. Specify the name of the block in builder.

Declare a variable using Make’s += assignment method. These values create or append the value to the existing value of the variable of this name. Unlike Python, in Make, these you may use append_var() for previously unassigned variables.

include(filename, ignore=False, block='_all')
Parameters:
  • filename (string) – The name of the file to include.
  • ignore (boolean) – Optional; defaults to False. When True, this job will have an - prepended, which will allow Make to continue building even when this file exists.
  • block (string) – Optional; defaults to _all. Specify the name of the block in builder.
job(job, display=False, ignore=False, block='_all')
Parameters:
  • job (string,list) – The shell command that specifies a job to run to build a target. If you specify a list, job() will add a sequence of jobs to a builder.
  • display (boolean) – Optional; defaults to False. When True Make will output the command when calling it. By default all jobs have an @ prepended, setting this option reverses this behavior.
  • ignore (boolean) – Optional; defaults to False. When True, this job will have an - prepended, which will allow Make to continue building even when this job has a non-zero exit code.
  • block (string) – Optional; defaults to _all. Specify the name of the block in builder.

Creates a shell line or lines (if job is a list) in a Makefile to build a target. May raise MalformedContent job is not a string or list of strings. The display and ignore options expose underlying Make functionality.

makefile = None

An alias for buildfile.

message(message, block='_all')
Parameters:
  • message (string) – The text of a message to be output by a build process to describe the current state of builds.
  • block (string) – Optional; defaults to _all. Specify the name of the block in builder.

message() is a special wrapper around job() that makes it possible to describe the actions of a Make shell line in human-readable text. The buildcloth idiom, inspired by ninja is to suppress echoing shell lines to the user in favor of crafted messages that describe each action.

msg(message, block='_all')

An alias for message()

new_var(variable, value, block='_all')
Parameters:
  • variable (string) – A string that specifies the name of the variable.
  • value (string) – A string that specifies the value of that variable.
  • block (string) – Optional; defaults to _all. Specify the name of the block in builder.

Declare a variable using Make’s ?= assignment method. In Make, these variables do not override previous assignments of this variable, whereas other assignment methods will override existing values.

simple_var(variable, value, block='_all')
Parameters:
  • variable (string) – A string that specifies the name of the variable.
  • value (string) – A string that specifies the value of that variable.
  • block (string) – Optional; defaults to _all. Specify the name of the block in builder.

Declare a variable using Make’s := assignment method. These values of these variables are expanded once at the time of the creation. By default, the value of all other variables in Make are evaluated once upon use.

target(target, dependency=None, block='_all')
Parameters:
  • target (string,list) – The name of the build target. May be a list of strings of build targets or a single string in the form that will appear in the Makefile output.
  • dependency (string,list) – Optional. Specify dependencies for this build target as either a list of targets, or as a string a string in the form that will appear in the Makefile output.
  • block (string) – Optional; defaults to _all. Specify the name of the block in builder.

Adds a build target to a build system block. You can specify targets and dependencies as either strings or as lists of strings. May raise MalformedContent if you attempt to add non-string data to a builder, or TypeError if a list does not contain strings.

var(variable, value, block='_all')
Parameters:
  • variable (string) – The name of the variable.
  • value (string) – The value of the variable.
  • block (string) – Optional; defaults to _all. Specify the name of the block in builder.

Adds a variable assignment to a build system block.