Classes related to the build phase (build, clean, install, step, etc)
The inheritance tree is the following:
Name of the cache directory
ConfigSet cache files for variants are written under :py:attr:´waflib.Build.CACHE_DIR´ in the form ´variant_name´_cache.py
Positive value ‘->’ install, see waflib.Build.BuildContext.is_install
Negative value ‘<-‘ uninstall, see waflib.Build.BuildContext.is_install
Build class members to save between the runs; these should be all dicts except for root which represents a waflib.Node.Node instance
Files from the build directory to hash before starting the build (config.h written during the configuration)
Post mode: all task generators are posted before any task executed
Post mode: post the task generators group after group, the tasks in the next group are created when the tasks in the previous groups are done
Bases: waflib.Context.Context
executes the build
Non-zero value when installing or uninstalling file
See waflib.Context.top_dir; prefer waflib.Build.BuildContext.srcnode
See waflib.Context.out_dir; prefer waflib.Build.BuildContext.bldnode
See waflib.Context.out_dir; prefer waflib.Build.BuildContext.launch_node()
Whether to post the task generators at once or group-by-group (default is group-by-group)
Map names to waflib.ConfigSet.ConfigSet, the empty string must map to the default environment
Dict mapping build nodes to task identifier (uid), it indicates whether a task created a particular file (persists across builds)
Dict mapping task identifiers (uid) to task signatures (persists across builds)
Dict mapping task identifiers (uid) to implicit task dependencies used for scanning targets (persists across builds)
Dict mapping task identifiers (uid) to node dependencies found by waflib.Task.Task.scan() (persists across builds)
Dict mapping task identifiers (uid) to custom data returned by waflib.Task.Task.scan() (persists across builds)
Amount of jobs to run in parallel
List of targets to build (default: *)
Whether the build should continue past errors
Level of progress status:
Manual dependencies set by waflib.Build.BuildContext.add_manual_dependency()
Current build group
List containing lists of task generators
Map group names to the group lists. See waflib.Build.BuildContext.add_group()
Getter for the variant_dir attribute
Create a task generator and add it to the current build group. The following forms are equivalent:
def build(bld):
tg = bld(a=1, b=2)
def build(bld):
tg = bld()
tg.a = 1
tg.b = 2
def build(bld):
tg = TaskGen.task_gen(a=1, b=2)
bld.add_to_group(tg, None)
Parameters: | group (string) – group name to add the task generator to |
---|
Build contexts cannot be copied
Raises : | waflib.Errors.WafError |
---|
The configuration command creates files of the form build/c4che/NAMEcache.py. This method creates a waflib.ConfigSet.ConfigSet instance for each NAME by reading those files and stores them in waflib.Build.BuildContext.allenvs.
Initialize the project directory and the build directory by creating the nodes waflib.Build.BuildContext.srcnode and waflib.Build.BuildContext.bldnode corresponding to top_dir and variant_dir respectively. The bldnode directory is created if necessary.
Restore data from previous builds and call waflib.Build.BuildContext.execute_build(). Overrides from waflib.Context.Context.execute()
Execute the build by:
Load data from a previous run, sets the attributes listed in waflib.Build.SAVED_ATTRS
Store data for next runs, set the attributes listed in waflib.Build.SAVED_ATTRS. Uses a temporary file to avoid problems on ctrl+c.
Run the build by creating an instance of waflib.Runner.Parallel The cache file is written when at least a task was executed.
Raises : | waflib.Errors.BuildError in case the build fails |
---|
Import waf tools defined during the configuration:
def configure(conf):
conf.load('glib2')
def build(bld):
pass # glib2 is imported implicitly
Parameters: |
|
---|
Getter for the env property
Adds a dependency from a node object to a value:
def build(bld):
bld.add_manual_dependency(
bld.path.find_resource('wscript'),
bld.root.find_resource('/etc/fstab'))
Parameters: |
|
---|
Returns the launch directory as a waflib.Node.Node object (cached)
Hashes configuration set variables:
def build(bld):
bld.hash_env_vars(bld.env, ['CXX', 'CC'])
This method uses an internal cache.
Parameters: |
|
---|
Fetches a task generator by its name or its target attribute; the name must be unique in a build:
def build(bld):
tg = bld(name='foo')
tg == bld.get_tgen_by_name('foo')
This method use a private internal cache.
Parameters: | name – Task generator name |
---|---|
Raises : | waflib.Errors.WafError in case there is no task genenerator by that name |
Computes a progress bar line displayed when running waf -p
Returns: | progress bar line |
---|---|
Return type: | string |
Wraps waflib.TaskGen.declare_chain() for convenience
Executes user-defined methods before the build starts, see waflib.Build.BuildContext.add_pre_fun()
Executes user-defined methods after the build is successful, see waflib.Build.BuildContext.add_post_fun()
Binds a callback method to execute after the scripts are read and before the build starts:
Binds a callback method to execute immediately after the build is successful:
Returns the build group named x, or the current group if x is None
Parameters: | x (string, int or None) – name or number or None |
---|
Adds a task or a task generator to the build; there is no attempt to remove it if it was already added.
Returns the name of the input build group
Parameters: | g (integer or list) – build group object or build group index |
---|---|
Returns: | name |
Return type: | string |
Returns the index of the group containing the task generator given as argument:
def build(bld):
tg = bld(name='nada')
0 == bld.get_group_idx(tg)
Parameters: | tg (waflib.TaskGen.task_gen) – Task generator object |
---|---|
Return type: | int |
Adds a new group of tasks/task generators. By default the new group becomes the default group for new task generators (make sure to create build groups in order).
Parameters: |
|
---|---|
Raises : | waflib.Errors.WafError if a group by the name given already exists |
Sets the build group at position idx as current so that newly added task generators are added to this one by default:
def build(bld):
bld(rule='touch ${TGT}', target='foo.txt')
bld.add_group() # now the current group is 1
bld(rule='touch ${TGT}', target='bar.txt')
bld.set_group(0) # now the current group is 0
bld(rule='touch ${TGT}', target='truc.txt') # build truc.txt before bar.txt
Parameters: | idx (string or int) – group name or group index |
---|
Approximate task count: this value may be inaccurate if task generators are posted lazily (see waflib.Build.BuildContext.post_mode). The value waflib.Runner.Parallel.total is updated during the task execution.
Return type: | int |
---|
This method returns a pair containing the index of the last build group to post, and the list of task generator objects corresponding to the target names.
This is used internally by waflib.Build.BuildContext.get_build_iterator() to perform partial builds:
$ waf --targets=myprogram,myshlib
Returns: | the minimum build group index, and list of task generators |
---|---|
Return type: | tuple |
Post task generators from the group indexed by self.current_group; used internally by waflib.Build.BuildContext.get_build_iterator()
Returns all task instances for the build group at position idx, used internally by waflib.Build.BuildContext.get_build_iterator()
Return type: | list of waflib.Task.Task |
---|
Creates a Python generator object that returns lists of tasks that may be processed in parallel.
Returns: | tasks which can be executed immediately |
---|---|
Return type: | generator returning lists of waflib.Task.Task |
Creates a task generator to install files on the system:
def build(bld):
bld.install_files('${DATADIR}', self.path.find_resource('wscript'))
Parameters: |
|
---|
Creates a task generator to install a file on the system with a different name:
def build(bld):
bld.install_as('${PREFIX}/bin', 'myapp', chmod=Utils.O755)
Parameters: |
|
---|
Creates a task generator to install a symlink:
def build(bld):
bld.symlink_as('${PREFIX}/lib/libfoo.so', 'libfoo.so.1.2.3')
Parameters: |
|
---|
Task generator method
feature: | install_task |
---|
Task generator method
Creates the installation task for the current task generator, and executes it immediately if necessary
Returns: | An installation task |
---|---|
Return type: | waflib.Build.inst |
Task generator method
Creates an installation task for files
Returns: | An installation task |
---|---|
Return type: | waflib.Build.inst |
Task generator method
Creates an installation task for a single file
Returns: | An installation task |
---|---|
Return type: | waflib.Build.inst |
Task generator method
Creates an installation task for a symbolic link
Returns: | An installation task |
---|---|
Return type: | waflib.Build.inst |
Bases: waflib.Task.Task
Task that installs files or symlinks; it is typically executed by waflib.Build.InstallContext and waflib.Build.UnInstallContext
Installation tasks are always executed, so this method returns either waflib.Task.ASK_LATER or waflib.Task.RUN_ME.
Returns the destination path where files will be installed, pre-pending destdir.
Return type: | string |
---|
Copies a file from src to tgt, preserving permissions and trying to work around path limitations on Windows platforms. On Unix-like platforms, the owner/group of the target file may be set through install_user/install_group
Parameters: |
|
---|
Removes empty folders recursively when uninstalling.
Parameters: | tgt (string) – absolute path |
---|
Try executing the installation task right now
Raises : | waflib.Errors.TaskNotReady |
---|
Copies a file from src to tgt with given file permissions. The actual copy is only performed if the source and target file sizes or timestamps differ. When the copy occurs, the file is always first removed and then copied so as to prevent stale inodes.
Parameters: |
|
---|---|
Raises : | waflib.Errors.WafError if the file cannot be written |
Change the ownership of the file/folder/link pointed by the given path This looks up for install_user or install_group attributes on the task or on the task generator:
def build(bld):
bld.install_as('${PREFIX}/wscript',
'wscript',
install_user='nobody', install_group='nogroup')
bld.symlink_as('${PREFIX}/wscript_link',
Utils.subst_vars('${PREFIX}/wscript', bld.env),
install_user='nobody', install_group='nogroup')
Creates a symlink from tgt to src.
Parameters: |
|
---|
Bases: waflib.Build.BuildContext
installs the targets on the system
Bases: waflib.Build.InstallContext
removes the targets installed
Bases: waflib.Build.BuildContext
cleans the project
Bases: waflib.Build.BuildContext
lists the targets to execute
Bases: waflib.Build.BuildContext
executes tasks in a step-by-step fashion, for debugging
Overrides waflib.Build.BuildContext.compile() to perform a partial build on tasks matching the input/output pattern given (regular expression matching):
$ waf step --files=foo.c,bar.c,in:truc.c,out:bar.o
$ waf step --files=in:foo.cpp.1.o # link task only
Bases: waflib.Build.BuildContext
Subclass EnvContext to create commands that require configuration data in ‘env’