fab.steps.preprocess module#

Fortran and C Preprocessing.

class fab.steps.preprocess.MpCommonArgs(config, output_suffix, preprocessor, flags, name)#

Bases: object

Common args for calling process_artefact() using multiprocessing.

config: BuildConfig#
output_suffix: str#
preprocessor: Preprocessor#
flags: FlagsConfig#
name: str#
fab.steps.preprocess.pre_processor(config, preprocessor, files, output_collection, output_suffix, common_flags=None, path_flags=None, name='preprocess')#

Preprocess Fortran or C files.

Uses multiprocessing, unless disabled in the config.

Parameters:
  • config (BuildConfig) – The fab.build_config.BuildConfig object where we can read settings such as the project workspace folder or the multiprocessing flag.

  • preprocessor (Preprocessor) – The preprocessor executable.

  • files (Collection[Path]) – The files to preprocess.

  • output_collection (Union[str, ArtefactSet]) – The name of the output artefact collection.

  • output_suffix – Suffix for output files.

  • common_flags (Optional[List[str]]) – Used to construct a FlagsConfig object. (default: None)

  • path_flags (Optional[List]) – Used to construct a FlagsConfig object. (default: None)

  • name – Human friendly name for logger output, with sensible default. (default: 'preprocess')

fab.steps.preprocess.process_artefact(arg)#

Expects an input file in the source folder. Writes the output file to the output folder, with a lower case extension.

fab.steps.preprocess.preprocess_fortran(config, source=None, **kwargs)#

Wrapper to pre_processor for Fortran files.

Ensures all preprocessed files are in the build output. This means copying already preprocessed files from source to build output.

Params as per _pre_processor().

The preprocessor is taken from the FPP environment, or falls back to fpp -P.

If source is not provided, it defaults to SuffixFilter(ArtefactStore.FORTRAN_BUILD_FILES, ‘.F90’).

class fab.steps.preprocess.DefaultCPreprocessorSource#

Bases: ArtefactsGetter

A source getter specifically for c preprocessing. Looks for the default output from pragma injection, falls back to default source finder. This allows the step to work with or without a preceding pragma step.

fab.steps.preprocess.preprocess_c(config, source=None, **kwargs)#

Wrapper to pre_processor for C files.

Params as per _pre_processor(). If source is not provided, it defaults to DefaultCPreprocessorSource.