def test_vanilla(self): getter = CollectionConcat(collections=[ 'fooz', SuffixFilter('barz', '.c') ]) result = getter(artefact_store={ 'fooz': ['foo1', 'foo2'], 'barz': [Path('bar.a'), Path('bar.b'), Path('bar.c')], }) assert result == ['foo1', 'foo2', Path('bar.c')]
def psyclone_preprocessor(set_um_physics=False): um_physics = ['-DUM_PHYSICS'] if set_um_physics else [] return PreProcessor( preprocessor='cpp -traditional-cpp', source=SuffixFilter('all_source', '.x90'), output_collection='preprocessed_x90', output_suffix='.x90', name='preprocess x90', common_flags=[ '-P', '-DRDEF_PRECISION=64', '-DUSE_XIOS', '-DCOUPLED', *um_physics, ], )
def c_preprocessor(preprocessor=None, source=None, output_collection='preprocessed_c', output_suffix='.c', name='preprocess c', **pp_kwds): """ Return a step to preprocess C files with multiprocessing. Params as per :class:`~fab.steps.preprocess.PreProcessor`. """ return PreProcessor(preprocessor=preprocessor or os.getenv('CPP', 'cpp -P'), source=source or SuffixFilter('all_source', '.c'), output_collection=output_collection, output_suffix=output_suffix, name=name, **pp_kwds)
def test_constructor_suffix_vector(self): getter = SuffixFilter('barz', ['.b', '.c']) result = getter(artefact_store={'barz': [Path('bar.a'), Path('bar.b'), Path('bar.c')]}) assert result == [Path('bar.b'), Path('bar.c')]
# (c) Crown copyright Met Office. All rights reserved. # For further details please refer to the file COPYRIGHT # which you should have received as part of this distribution ############################################################################## """ Add custom pragmas to C code which identify user and system include regions. """ from pathlib import Path from typing import Dict from fab.steps import Step from fab.tasks.c import CTextReaderPragmas from fab.artefacts import ArtefactsGetter, SuffixFilter DEFAULT_SOURCE_GETTER = SuffixFilter('all_source', '.c') # todo: test class CPragmaInjector(Step): """ A build step to inject custom pragmas to mark blocks of user and system include statements. By default, reads .c files from the *all_source* artefact and creates the *pragmad_c* artefact. """ def __init__(self, source: ArtefactsGetter = None, output_name="pragmad_c", name="c pragmas"): """
from pathlib import Path from typing import Dict, List, Tuple, Iterable, Set, Optional, Union from fab.constants import BUILD_TREES from fab.dep_tree import AnalysedFile, add_mo_commented_file_deps, extract_sub_tree, EmptySourceFile, \ validate_dependencies from fab.steps import Step from fab.tasks.c import CAnalyser from fab.tasks.fortran import FortranAnalyser from fab.util import HashedFile, do_checksum, log_or_dot_finish, TimerLogger from fab.artefacts import ArtefactsGetter, CollectionConcat, SuffixFilter logger = logging.getLogger(__name__) DEFAULT_SOURCE_GETTER = CollectionConcat([ SuffixFilter('all_source', '.f90'), 'preprocessed_c', 'preprocessed_fortran', # todo: this is lfric stuff so might be better placed with the lfric run configs SuffixFilter('psyclone_output', '.f90'), 'preprocessed_psyclone', 'configurator_output', ]) # todo: split out c and fortran? this class is still a bit big # This has all been done as a single step, for now, because we don't have a simple mp pattern # (i.e we don't have a list of artefacts and a function to feed them through). class Analyse(Step): """