system is an interface for specifying and executing a build process with concurrent semantics. It provides abstractions for running build processes that are BuildSequence() and BuildStage() objects.
BuildSystemGenerator() uses the tools in stages to produce a build system and provide the foundation of the command-line build system tool buildc – Command Line Build System Interface.
A representation of a multi-stage build system that combines a number build stages to be constructed in any order, and executed sequentially.
Parameters: |
|
---|---|
Raises : | InvalidStage if strict is True, otherwise, returns False. |
Parameters: | name (string) – The name of a stage. |
---|---|
Returns: | False when name already exists in the build system, and True otherwise. |
Parameters: |
|
---|---|
Raises : | InvalidStage() in strict mode if name or stage is malformed. |
Creates a new stage and optionally populates the stage with tasks. Note the following behaviors:
If name exists in the current :class:~system.BuildSystem`, strict is False, and stage is None; then :meth:~system.BuildSystem.add_stage()` adds the stage with name to the current :class:~system.BuildSystem` object. This allows you to perform the same stage multiple times in one build process.
If `name does not exist in the current :class:~system.BuildSystem`, and stage is None, :meth:~system.BuildSystem.add_stage()` adds the stage and instantiates a new :class`~stages.BuildSteps()` (either :class`~stages.BuildSequence()` or :class`~stages.BuildStage()` depending on the value of stage_type) object with name to the current :class:~system.BuildSystem` object.
:meth:~system.BuildSystem.add_stage()` must specify a stage_type if stage is None. When strict is True not doing so raises an exception.
Adds the stage with the specified :class`~stages.BuildSteps()` object to the :class:~system.BuildSystem` object. Raises an exception if stage is not a :class`~stages.BuildSteps()` object.
Returns: | True when after finalizing a :class:~system.BuildSystem` object. |
---|
Returns: | The number of stages in the :class:~system.BuildSystem` object. |
---|
Parameters: | system (BuildSystem) – A BuildSystem() object. |
---|
Takes system and grows the current BuildSystem() object to have the objects stages. If there are existing stages and job definitions that collide with stages and jobs in system, the data in system wins.
Returns: | List of names of build stages in the order they’d run. |
---|
Parameters: | stage (string) – The name of a stage in the BuildSystem. |
---|---|
Returns: | The position of the stage in the BuildSystem, or None if it doesn’t exist in the BuildSystem object. |
Parameters: | name (string) – The name of a stage. |
---|
Special case and wrapper of :meth:~system.BuildSystem.add_stage()` that adds a new stage without adding any jobs to that stage.
Boolean. If True, (and strict is True,)then it’s safe to add additional stages and execute the build
Parameters: | strict (bool) – Defaults to strict. |
---|---|
Raises : | StageRunError if strict is True and open is True. |
Calls the run() method of each stage object.
Parameters: | |
---|---|
Raises : | StageRunError if strict is True and open is True. |
Returns: | The return value of the last run() method called. |
Calls the run() method of each stage object until the idxth item of the _stages array.
Parameters: | |
---|---|
Returns: | False if name is not in the :class:~system.BuildSystem` object, and strict is False. In all other cases run_stages() returns True after the stage runs. |
Raises : | StageRunError if strict is True and name does not exist. |
Runs a single stage from the :class:~system.BuildSystem` object.
Parameters: | name (string) – The name of a possible stage in the :class:~system.BuildSystem` object. |
---|---|
Returns: | True if the stage exists in :class:~system.BuildSystem` and False otherwise. |
A mapping of the names of stages to their stage objects.
A Getter and setter for the :attr:~system.BuildSystem._strict` setting.
BuildSystemGenerator objects provide a unifying interface for generating and running BuildSystem objects from easy-to-edit sources. BuildSystemGenerator is the fundamental basis of the buildc – Command Line Build System Interface tool.
Parameters: | funcs (dict) – Optional. A dictionary that maps callable objects (values), to identifiers used by build system definitions. If you do not specify. |
---|
BuildSystemGenerator is designed to parse streams of YAML documents that resemble the following:
job: <func>
args: <<arg>,<list>>
stage: <str>
---
job: <func>
args: <<arg>,<list>>
target: <str>
dependency: <<str>,<list>>
---
dir: <<path>,<list>>
cmd: <str>
args: <<arg>,<list>>
stage: <str>
---
dir: <<path>,<list>>
cmd: <str>
args: <<arg>,<list>>
dependency: <<str>,<list>>
---
tasks:
- job: <func>
args: <<arg>,<list>>
- dir: <<path>,<list>>
cmd: <str>
args <<args>,<list>>
stage: <str>
...
See Define and Run Builds With buildc for documentation of the input data format and its use.
Parameters: |
|
---|---|
Raises : | InvalidSystem if its impossible to add a task in the BuildSystemGenerator object to the finalized build system object. |
Called by _finalize_process_tree() to add and process tasks.
Loops over the _process list tree created in the main finalize() method, and adds tasks to system object, which is itself a BuildSystem object.
While constructing the system object, _finalize_process_tree() combines adjacent tasks that do not depend upon each other to increase the potential for parallel execution.
_finalize_process(), calls _add_tasks_to_stage() which may raise InvalidSystem in the case of malformed tasks.
Parameters: | spec (dict) – The task specification imported from user input. |
---|
Wraps _process_stage() and modifies the internal strucutres associated with the dependency tree.
Parameters: | spec (dict) – A dictionary of strings that describe a build job. |
---|
Processes the spec and attempts to create and add the resulting task to the build system.
Parameters: | |
---|---|
Returns: | A two item tuple, containing a function and a list of arguments. |
Raises : | InvalidJob if the schema of spec is not recognized. |
Based on the schema of the spec, creates tasks and sequences to add to a BuildSystem using, as appropriate one of the following methods:
Parameters: | |
---|---|
Raises : | InvaidJob if func is not callable. |
Adds a callable object to the funcs attribute with the identifier name.
Raises : | InvalidSystem if you call finalize() more than once on a single BuildSystemGenerator() object. |
---|
You must call finalize() before running the build system.
finalize() compiles the build system. If there are no tasks with dependencies, _stages becomes the system object. Otherwise, finalize() orders the tasks with dependencies, inserts them into a BuildSequence object before inserting the _stages tasks.
Parameters: | |
---|---|
Returns: | A tuple where the first item is a callable and the second item is either a dict or a tuple of arguments, depending on the type of the spec.args value. |
Raises : | InvalidStage if spec.args is neither a dict, list, or tuple. |
Parameters: | |
---|---|
Returns: | A BuildSequence() object. |
Raises : | An exception when spec does not have a task element or when task.spec is not a list. |
Process a job spec that describes a sequence of tasks and returns a BuildSequence() object for inclusion in a BuildSystem() object.
Parameters: | spec (dict) – A job specification. |
---|---|
Returns: | A tuple where the first element is subprocess call(), and the second item is a dict args, a dir, and cmd keys. |
Takes a spec dict and returns a tuple to define a task.
Parameters: | spec (dict) – A specification of a build task with a target, to process. |
---|---|
Returns: | A list that specifies all specified dependencies of that task. |
Parameters: |
|
---|---|
Returns: | The number of jobs added to the build system. |
For every document
Wraps ingest().
Parameters: |
---|
For every document in the JSON file specified by filename, calls _process_job() to add that job to the system object.
Wraps ingest().
Parameters: |
---|
For every document in the YAML file specified by filename, calls _process_job() to add that job to the system object.
Parameters: | |
---|---|
Raises : | TypeError if strings is not a dict and there may be a replacement string. |
Mapping of job specs targets to specs.