3.1.31. waf_tools.preprocess

Utility functions and waf tasks to generate cleaned header files from preprocessed headers.

This waf tool provides the preprocessing pipeline required by the mock tool. It takes raw C header files, runs them through the C preprocessor (cc -E), and then extracts only the lines that belong to the original header - stripping all content pulled in via transitive #include directives. The result is a “clean” header suitable for consumption by CMock.

3.1.31.1. Usage

This module is not loaded directly via ctx.load(). Instead it is imported by the mock tool:

import preprocess

preprocessed_nodes = preprocess.create_preprocessed_files(self, headers, test_file)
for node in preprocessed_nodes:
    clean_node = preprocess.create_clean_header(self, node)

3.1.31.2. Dependencies

  • Host C compiler (env.CC) capable of -E preprocessing

  • Used exclusively by the mock tool in this toolchain

Functions

clean_encoding(line)

Normalize a text line to UTF-8, ignoring invalid byte sequences.

create_clean_header(self, prep_node)

Create a clean_header waf task for the given preprocessed node and return its output node.

create_preprocessed_files(self, nodes, test_file)

Create preprocessing tasks for the given nodes, ensuring they run after the appropriate HAL build tasks, and return the resulting preprocessed output nodes.

extract_file_as_array_from_expansion(prep_node)

Extract logical source lines for the given header from a preprocessed file.

Classes

HPreproc(*k, **kw)

Task that preprocesses header files.

clean_header(*k, **kw)

Waf task that creates a cleaned header file from a preprocessed header input.