fab.fab_base.fab_base#
This is an OO basic interface to FAB. It allows typical applications to only modify very few settings to have a working FAB build script.
Classes
|
This is a convenience base class for writing Fab scripts. |
- class fab.fab_base.fab_base.FabBase(name, link_target='executable')#
This is a convenience base class for writing Fab scripts. It provides an extensive set of command line options that can be used to influence the build process, and can be extended by applications. It has already support for compilation modes, and allows site-specific configuration scripts to be written that can modify the initialisation and build process.
- Parameters:
- set_link_target(link_target)#
Sets the link target.
- Parameters:
link_target (
str
) – what target should be created. Must be one of “executable”s, “static-library”, or “shared-library”.- Raises:
ValueError – if the link_target is invalid
- Return type:
- define_project_name(name)#
This method defines the project name, i.e. the directory name to use in the Fab workspace. It defaults to name-profile-compiler.
- set_root_symbol(root_symbol)#
Defines the root symbol. It defaults to the name given in the constructor.
- Parameters:
name – the root symbol to use when creating a binary (unused otherwise).
- Return type:
- property target: str#
- Returns:
the target (=”site-platform”), or “default” if nothing was specified.
- property config: BuildConfig#
- Returns:
the FAB BuildConfig instance.
- Return type:
fab.BuildConfig
- property args: Namespace#
- Returns:
the arg parse objects containing the user’s command line information.
- property fortran_compiler_flags_commandline: List[str]#
- Returns:
the list of flags specified through –fflags.
- property c_compiler_flags_commandline: List[str]#
- Returns:
the list of flags specified through –cflags.
- property linker_flags_commandline: List[str]#
- Returns:
the list of flags specified through –ldflags.
- setup_site_specific_location()#
This method adds the required directories for site-specific configurations to the Python search path. This implementation will search the call tree to find the first call that’s not from Fab, i.e. the user script. It then adds
site_specific
andsite_specific/default
to the directory in which the user script is located. An application can overwrite this method to change this behaviour and point at site-specific directories elsewhere.- Return type:
- define_site_platform_target()#
This method defines the attributes site, platform (and target=site-platform) based on the command line option –site and –platform (using $SITE and $PLATFORM as a default). If site or platform is missing and the corresponding environment variable is not set, ‘default’ will be used.
- Return type:
- site_specific_setup()#
Imports a site-specific config file. The location is based on the attribute
target
(which is set to be{site}_{platform}" based on the command line options, and the path is specified in ``setup_site_specific_location
).- Return type:
- define_command_line_options(parser=None)#
Defines command line options. Can be overwritten by a derived class which can provide its own instance (to easily allow for a different description).
- Parameters:
parser (
Optional
[ArgumentParser
]) – optional a pre-defined argument parser. If not, a new instance will be created. (default:None
)- Return type:
- handle_command_line_options(parser)#
Analyse the actual command line options using the specified parser. The base implementation will handle the –suite parameter, and compiler/linker parameters (including the usage of environment variables). Needs to be overwritten to handle additional options specified by a derived script.
- Parameters:
parser (argparse.ArgumentParser) – the argument parser.
- Return type:
- define_preprocessor_flags_step()#
Top level function that sets preprocessor flags. The base implementation does nothing, should be overwritten.
- Return type:
- get_linker_flags()#
Base class for setting linker flags. This base implementation for now just returns an empty list.
- add_preprocessor_flags(list_of_flags)#
This function appends a preprocessor flags to the internal list of all preprocessor flags, which will be passed to Fab’s various preprocessing steps (for C, Fortran, and X90).
Each flag can be either a str, or a path-specific instance of Fab’s AddFlags object. For the convenience of the user, this function also accepts a single flag or a list of flags.
No checking will be done if a flag is already in the list of flags.
- grab_files_step()#
This should typically be overwritten by an application to get files e.g. from a repository.
- Return type:
- find_source_files_step(path_filters=None)#
This function calls Fab’s find_source_files, to identify and add all source files to Fab’s artefact store.
- preprocess_c_step()#
Calls Fab’s preprocessing of all C files. It passes the common and path-specific flags set using add_preprocessor_flags.
- Return type:
- preprocess_fortran_step()#
Calls Fab’s preprocessing of all fortran files. It passes the common and path-specific flags set using add_preprocessor_flags.
- Return type:
- analyse_step(find_programs=False)#
Calls Fab’s analyse. It passes the config and root symbol for Fab to analyze the source code dependencies.
- Find_programs:
if set and an executable is created (see link_target), the flag will be set in Fab’s analyse step, which means it will identify all main programs automatically.
- Return type:
- compile_c_step(common_flags=None, path_flags=None)#
Calls Fab’s compile_c. It passes the config for Fab to compile all C files. Optionally, common flags, path-specific flags and alternative source can also be passed to Fab for compilation.
- Return type:
- compile_fortran_step(common_flags=None, path_flags=None)#
Calls Fab’s compile_fortran. It passes the config for Fab to compile all Fortran files. Optionally, common flags, path-specific flags and alternative source can also be passed to Fab for compilation.
- link_step()#
Calls Fab’s archive_objects for creating static libraries, or link_shared_object for creating shared libraries, or link_exe for creating executable binaries. The outputs will be placed in the Fab workspace, either using the name or root_symbol passed to the Fab build config.
- Return type: