fab.build_config module#

Contains the BuildConfig and helper classes.

class fab.build_config.BuildConfig(project_label, tool_box, multiprocessing=True, n_procs=None, reuse_artefacts=False, fab_workspace=None, two_stage=False, verbose=False)#

Bases: object

Contains and runs a list of build steps.

The user is not expected to instantiate this class directly, but rather through the build_config() context manager.

Parameters:
  • project_label (str) – Name of the build project. The project workspace folder is created from this name, with spaces replaced by underscores.

  • tool_box (ToolBox) – The ToolBox with all tools to use in the build.

  • multiprocessing (bool) – An option to disable multiprocessing to aid debugging. (default: True)

  • n_procs (Optional[int]) – The number of cores to use for multiprocessing operations. Defaults to the number of available cores. (default: None)

  • reuse_artefacts (bool) – A flag to avoid reprocessing certain files on subsequent runs. WARNING: Currently unsophisticated, this flag should only be used by Fab developers. The logic behind flag will soon be improved, in a work package called “incremental build”. (default: False)

  • fab_workspace (Optional[Path]) – Overrides the FAB_WORKSPACE environment variable. If not set, and FAB_WORKSPACE is not set, the fab workspace defaults to ~/fab-workspace. (default: None)

  • two_stage – Compile .mod files first in a separate pass. Theoretically faster in some projects.. (default: False)

  • verbose – DEBUG level logging. (default: False)

property tool_box: ToolBox#
Returns:

the tool box to use.

property artefact_store: ArtefactStore#
Returns:

the Artefact instance for this configuration.

property build_output: Path#
Returns:

the build output path.

add_current_prebuilds(artefacts)#

Mark the given file paths as being current prebuilds, not to be cleaned during housekeeping.

class fab.build_config.AddFlags(match, flags)#

Bases: object

Add command-line flags when our path filter matches. Generally used inside a FlagsConfig.

Parameters:
  • match (str) – The string to match against each file path.

  • flags (List[str]) – The command-line flags to add for matching files.

Both the match and flags arguments can make use of templating:

  • $source for <project workspace>/source

  • $output for <project workspace>/build_output

  • $relative for <the source file’s folder>

For example:

# For source in the um folder, add an absolute include path
AddFlags(match="$source/um/*", flags=['-I$source/include']),

# For source in the um folder, add an include path relative to each source file.
AddFlags(match="$source/um/*", flags=['-I$relative/include']),
run(fpath, input_flags, config)#

Check if our filter matches a given file. If it does, add our flags.

Parameters:
  • fpath (Path) – Filepath to check.

  • input_flags (List[str]) – The list of command-line flags Fab is building for this file.

  • config – Contains the folders for templating $source and $output.

class fab.build_config.FlagsConfig(common_flags=None, path_flags=None)#

Bases: object

Return command-line flags for a given path.

Simply allows appending flags but may evolve to also replace and remove flags.

Parameters:
  • common_flags (Optional[List[str]]) – List of flags to apply to all files. E.g [‘-O2’]. (default: None)

  • path_flags (Optional[List[AddFlags]]) – List of AddFlags objects which apply flags to selected paths. (default: None)

flags_for_path(path, config)#

Get all the flags for a given file, in a reproducible order.

Parameters:
  • path (Path) – The file path for which we want command-line flags.

  • config – The config contains the source root and project workspace.