Build Flags

class sbuildr.BuildFlags

Abstract description of compiler and linker flags. These are interpreted by SBuildr’s compiler and linker interfaces and converted to concrete command-line flags.

It is possible to add two BuildFlags, in which case the right-hand side takes precedence when flags are set for both instances. For example, BuildFlags.O(3).fpic() + BuildFlags.O(0) would result in a value equivalent to: BuildFlags.O(0).fpic()

O(level: Union[int, str]) → sbuildr.tools.flags.BuildFlags

Sets the optimization level.

Parameters:level – An integer or string indicating the optimization level. For example, to disable optimization, this would be set to 0 or "0".
Returns:self
debug(use=True) → sbuildr.tools.flags.BuildFlags

Enables or disables generation of debug information.

Parameters:use – Whether to generate debug information.
Returns:self
define(macro) → sbuildr.tools.flags.BuildFlags

Defines the specified macro during compilation. This can be useful to enable/disable code paths using #ifdefs.

Parameters:macro – The macro to define.
Returns:self
fpic(use=True) → sbuildr.tools.flags.BuildFlags

Enables or disables generation of position independent code.

Parameters:use – Whether to generate position independent code.
Returns:self
march(type: str) → sbuildr.tools.flags.BuildFlags

Sets the microarchitecture.

Parameters:type – A string describing the CPU microarchitecture.
Returns:self
raw(opts: List[str]) → sbuildr.tools.flags.BuildFlags

Allows for providing raw options.

Parameters:opts – A list of options, as strings. These are passed on to the compiler and linker without modification.
Returns:self
std(year: Union[int, str]) → sbuildr.tools.flags.BuildFlags

Sets the C++ standard.

Parameters:year – An integer or string indicating the last two digits of the year of the corresponding C++ standard. For example, to use C++11, this would be set to 11 or "11".
Returns:self