fab.tools.profile_flags#
This file contains the ProfileFlag class used to manage command line flags for tools, especially path-specific flags for compiler. A ProfileFlag manages flags for specific profiles, including inheritance.
Each tool uses a ProfileFlags instance. At runtime, the compilation steps will use the selected profile to get the Flags inProfileFlags:
Manages a set of flags for specific profiles, including inheritance.
stance to use. The function get_flags will resolve the list of AbstractFlags by converting them from left to right into a list of strings. For example, [AlwaysFlag(“-g”), ContainFlags(“-O3”, pattern=”special_file”)] will be convert to [“-g”, “-O3”] if the file contains the string special_file, and otherwise it will be [“-g”].
Classes
|
A list of flags that support a 'profile' to be used. |
- class fab.tools.profile_flags.ProfileFlags(flags=None, profile='')#
A list of flags that support a ‘profile’ to be used. If no profile is specified, it will use “” (empty string) as ‘profile’. If a profile is defined without an explicit inherit, this dummy profile “” will be used (which implies that any flags specified with a profile will eventually be used by any profile, so it’s an implicit, common base class.
All functions take an optional profile parameter, so this class can also be used for tools that do not need a profile.
- Parameters:
- classmethod define_profile(name, inherit_from=None)#
Defines a new profile name, and allows to specify if this new profile inherit settings from an existing profile. If inherit_from is specified, the newly defined profile will inherit from an existing profile (including the default profile “”).
- get_flags(config=None, file_path=None)#
This method returns the flags used for the specified file, i.e. it will support path-specific flags. The BuildConfig is added as parameter to get the profile, but also to allow flags to use templated expressions $relative and $output (the values are taken from the config object).
- add_flags(new_flags, profile=None)#
Adds the specified flags to the list of flags.
- Parameters:
new_flags (
AbstractFlags|str|list[str]) – A single string or list of strings which are the flags to be added.- Return type:
- remove_flag(remove_flag, profile=None, has_parameter=False)#
Removes all occurrences of remove_flag in flags. If has_parameter is defined, the next entry in flags will also be removed, and if this object contains this flag+parameter without space (e.g. -J/tmp), it will be correctly removed. Note that only the flag itself must be specified, you cannot remove a flag only if a specific parameter is given (i.e. remove_flag=”-J/tmp” will not work if this object contains […,”-J”, “/tmp”]).