loki.transform.build_system_transform
Transformations to be used in build-system level tasks
Classes
|
Generates a list of files to add, remove or replace in a CMake target's list of sources |
|
Write out modified source files to a select build directory |
- class CMakePlanner(rootpath, mode, build=None)
Bases:
TransformationGenerates a list of files to add, remove or replace in a CMake target’s list of sources
This is intended to be used in a
Schedulertraversal triggered during the configuration phase of a build (e.g., usingexecute_process) to generate a CMake plan file (usingwrite_planfile()). This file set variablesLOKI_SOURCES_TO_TRANSFORM,LOKI_SOURCES_TO_APPEND, andLOKI_SOURCES_TO_REMOVEthat can then be used to update a target’sSOURCESproperty viaget_target_propertyandset_property.- sources_to_append
Newly generated source files that need to be added to the target
- sources_to_remove
The source files that are replaced and must be removed from the target
- sources_to_transform
The source files that are going to be transformed by Loki transformations
- Parameters:
rootpath (
pathlib.Pathor str) – The base directory of the source treemode (str) – The name of the transformation mode (which is going to be inserted into the file name of new source files)
build (
pathlib.Pathor str) – The target directory for generate source files
- transform_subroutine(routine, **kwargs)
Insert the current subroutine into the lists of source files to process, add and remove, if part of the plan
- Parameters:
routine (
Subroutine) – The subroutine object to processitem (
Item) – The corresponding work item from theSchedulerrole (str) – The routine’s role
- write_planfile(filepath)
Write the CMake plan file at
filepath
- class FileWriteTransformation(builddir=None, mode='loki', suffix=None, cuf=False)
Bases:
TransformationWrite out modified source files to a select build directory
- Parameters:
builddir (str or path) – Directory for the output to be written to
mode (str, optional) – “Mode” identifier string to add in front of the file suffix
suffix (str, optional) – File suffix to determine file type for all written file. If omitted, it will preserve the original file type.
cuf (bool, optional) – Use CUF (CUDA Fortran) backend instead of Fortran backend.
- transform_file(sourcefile, **kwargs)
Defines the transformation to apply to
Sourcefileitems.For transformations that modify
Sourcefileobjects, this method should be implemented. It gets called via the dispatch methodapply().- Parameters:
sourcefile (
Sourcefile) – The sourcefile to be transformed.**kwargs (optional) – Keyword arguments for the transformation.