3.1.25.2.4. waf_tools.hcg.hcg_compiler

class waf_tools.hcg.hcg_compiler(*k, **kw)

Bases: Task

Task that executes the HALCoGen code generator.

Copies the .hcg and .dil input files to the build directory, invokes HALCoGen to generate the HAL sources, extracts the CPU clock frequency from the generated FreeRTOSConfig.h, validates the HL_sys_startup.c hash, removes unwanted files, and synchronizes timestamps.

Task attributes (set by process_hcg()):
  • remove (list[str]): File paths to delete after generation.

  • uses_freertos (bool): Whether to extract the CPU clock define.

run() → int

Execute the HALCoGen code generator and post-process outputs.

Performs the following steps:

  1. Copy the .hcg and .dil sources into the build directory.

  2. Run HALCoGen to generate HAL source files.

  3. If FreeRTOS is enabled, extract configCPU_CLOCK_HZ from the generated FreeRTOSConfig.h and write it into config_cpu_clock_hz.h.

  4. Validate the hash of HL_sys_startup.c against the expected hash stored in self.generator.startup_hash.

  5. Remove unwanted generated files listed in self.remove.

  6. Re-copy the original .hcg/.dil files to overwrite the timestamps that HALCoGen modified during generation, keeping the source and build directories synchronized.

Returns:

0 on success, 1 if the startup file hash validation fails.