Configurator Class

The configurator class contains miscellaneous functions to populate the CCT. The class should inherit from QANonMSVSConfigurator in most cases.

For more information on using CCT filters, see Working with Auto CCT Scripts.
Member Variables

_generates_cip_includes

This should be set to True if the compiler include files are being found by the read_includes function. See The filter_init Function and Filter Setup for more information.

compiler_name

The name of the compiler binary. This is used to populate the COMPILER_NAME setting in the CCT.

conf

An instance of the Config class which contains various information about the compiler. See below for some examples that use it. It is also used indirectly to implement the functions compiler_name, defines, include_dirs and language.

_defines_dict

Simply a dictionary of predefined compiler macros created from self.conf.defines. It is accessed via the defines_dict property.

Overridable Functions

The following functions or properties can be overridden for a given filter.

target

The string returned by target is used to set the TARGET setting in the CCT.

For example, this function returns the setting for the --chip argument as the value for the target:

def target(self):
    return qa_util.get_option(r'--chip=([a-zA-Z0-9_]+)', self.conf.path)

This one uses the value of a predefined compiler macro:

def target(self):
    return self.defines_dict.get("__TID__", "icc")

This one uses the compiler name:

def target(self):
    return self.compiler_name.replace('CL', '')

hierarchy

The return string is used to specify the COMPILER_HIERARCHY in the CCT.

user_visible_name

If the exact compiler name is not known when the filter is initialised (because the filter may deal with more than one compiler), this property will give the compiler name. It usually just returns self.compiler_name. If the property is not declared in the configurator, the name passed to the filter_init function is used.

custom_intrinsic_types

The types such as size_t or ptrdiff_t are often found by looking up a particular predefined macro. If this is not the case, the configurator can declare this function and perform more complicated calculations. For example:

def custom_intrinsic_types(self, intrinsic_types_dict):
    debug("custom_intrinsic_types called " + self.language_standard_version)
    if '__LP64__' in self.defines_dict:
        intrinsic_types_dict['ptrdiff_t'] = 'long'
        intrinsic_types_dict['size_t'] = 'unsigned long'
    else:
        intrinsic_types_dict['ptrdiff_t'] = 'int'
        intrinsic_types_dict['size_t'] = 'unsigned int'
    if '__cplusplus' not in self.defines_dict:
        intrinsic_types_dict['wchar_t'] = 'unsigned short'
    return intrinsic_types_dict

custom_size_map

A typical value returned would be:

{
    "char": "__CHAR_BIT__",
    "short": "__SIZEOF_SHORT__",
    "int": "__SIZEOF_INT__",
    "long": "__SIZEOF_LONG__",
    "longlong": "__SIZEOF_LONG_LONG__",
    "float": "__SIZEOF_FLOAT__",
    "double": "__SIZEOF_DOUBLE__",
    "ldouble": "__SIZEOF_LONG_DOUBLE__",
}

This would set the sizes of the various types to a value based on the given predefined compiler variables. These values are used to set the -s values in the CCT.

custom_align

Usually, the alignment is calculated from the size settings for the various types. There may be a situation where the calculation doesn't match what the compiler expects. This function allows for that. For example, if the longlong type really has an alignment of 4, the following function could be declared:

def custom_align(self, typename):
    return 4 if typename == 'longlong' else 0

Returning zero indicates that the usual calculations should be used.

custom_parser_extensions

A list of anything that doesn't fit into other categories can be returned here. For example, one filter uses it to implement the compiler option to include a header file (a forced include).

generate_headers

If a header must be generated, this is where it can be done. Note that the environment variable QAC_CCT_LOCATION is set to the directory for the CCT by the calling cctgen.py script. This can be used to locate the header directories.