Skip to content

Repository files navigation

CodeGen Compare Tool

Test Python 3.8+ License: MIT Release

🇻🇳 Tiếng Việt: README · Hướng dẫn · Kiến trúc

CodeGen Compare Tool

See what actually changed after AUTOSAR code generation.

Regenerating a Simulink/AUTOSAR project can produce thousands of changed lines caused by timestamps, UUIDs, generated identifiers and other generator churn.

CodeGen Compare Tool compares two generated-code snapshots, filters out changes that can be proven to be generator noise, and highlights the changes that matter.

It compares not only generated C/C++ and XML, but also the AUTOSAR and A2L objects behind them.


Why CodeGen Compare?

General-purpose diff tools compare text. They cannot tell whether a changed UUID is noise, whether a generated identifier was safely renamed, or whether ARXML and generated C are no longer consistent.

CodeGen Compare is designed specifically for generated automotive software.

General diff tools CodeGen Compare
Generator timestamps / UUIDs Show as changes Filtered automatically
Generated identifier renames Look like changes everywhere Recognised when safely explainable
AUTOSAR changes Text only SWCs, ports, runnables, events, RTE access
A2L changes Text only Characteristics / measurements
Incomplete regeneration Usually invisible Cross-file consistency check
CI build gate Manual Exit codes + JSON + SARIF

Rule: if a difference cannot be proven to be noise, it remains a real change.

For ordinary text files, use a general-purpose diff tool. For AUTOSAR code generation, use CodeGen Compare.


Quick Start

Compare two generated folders

python -m compare_tool old_gen_folder new_gen_folder --report report.html

The result is a self-contained HTML report that can be opened in any browser or published as a CI artifact.

ZIP files can be compared directly:

python -m compare_tool baseline.zip current.zip --report report.html

Open the desktop viewer

python -m compare_tool

With no folders supplied, the interactive viewer opens.

Install

Run directly from a clone:

git clone https://github.com/longvo92/codegen-compare-tool.git
cd codegen-compare-tool
python -m compare_tool --help

Or install as a command:

pip install git+https://github.com/longvo92/codegen-compare-tool.git

A single-file build is also available for machines where installing software is restricted.

See the Usage Guide for installation, packaging and all command-line options.


Viewer or CLI?

Both use the same comparison engine, so they always produce the same comparison result.

Desktop Viewer CLI
Best for Interactive review CI / automation
Input Folders / ZIP Folders / ZIP
Output Interactive diff HTML / JSON / SARIF
Build gate Exit code

Key Features

1. Generator-noise filtering

Automatically identifies common code-generation churn:

  • UUIDs and timestamps
  • Generated version stamps
  • Comments and formatting
  • Generated identifier renames
  • Safe statement reordering
  • Configurable custom noise rules

Changes that cannot be safely explained remain visible as real changes.

One opt-in exception: --skip-var-renames folds variable renames it cannot prove are noise, so a fresh regenerate can be swept for what is not a rename. It trades away real changes that look the same, announces itself everywhere it was used, and is never on by default.

See What Counts as Noise.


2. AUTOSAR-level change summary

See what changed in AUTOSAR terms, not only as changed lines of C or XML.

The tool extracts changes to:

  • SWCs
  • Ports and port interfaces
  • Runnables
  • Events
  • Rte_* access points
  • A2L CHARACTERISTIC / MEASUREMENT objects

Changes are grouped by the Simulink model they belong to.

A timing change such as:

TIMING-EVENT: 0.01 s → 0.02 s

is reported as a semantic AUTOSAR change instead of forcing you to find it in generated XML.

See AUTOSAR Semantic Summary.


3. Detect incomplete regeneration

Generated artifacts should agree with each other.

CodeGen Compare cross-checks ARXML, A2L and generated C to detect suspicious inconsistencies.

For example:

ARXML changed + C unchanged
→ possible incomplete regeneration

A2L changed + C unchanged
→ possible incomplete regeneration

Model A gains an Rte_* call
while Model B remains unchanged
→ possible partial regeneration

These checks are advisory and do not change the file verdict or CI exit code.

See Consistency Check.


Desktop Viewer

Side-by-side viewer

The viewer provides:

  • Folder tree
  • Side-by-side diff
  • Minimap and syntax highlighting
  • Change navigation
  • Review notes
  • Git history comparison
  • Offline user guide

It is designed for manually reviewing large generated-code changes without losing context.

See Side-by-side Viewer.


HTML Report

Report viewer

Every comparison can produce a self-contained HTML report containing:

  • File and change summaries
  • Filtering and collapsible diffs
  • Context around each change
  • Function-level change information
  • Dark / light themes
  • AUTOSAR semantic summaries
  • Consistency advisories

The report requires no server, database or internet connection and can be published directly as a CI artifact.

See HTML Report.


CI Integration

Use the exit code as a build gate:

Code Meaning
0 No real changes
1 Real changes found
2 Compare incomplete or failed

Example:

python -m compare_tool old_dir new_dir \
    --report compare_report.html \
    --exit-zero

Available machine-readable outputs:

  • --json — complete comparison data
  • --sarif — SARIF 2.1.0 for code-scanning systems

Publish the HTML report as a build artifact for every comparison.

See CI Integration.


What does it require?

The compare engine uses only the Python standard library.

No:

  • Database
  • Server
  • Network connection
  • pip install required for CLI comparison

The desktop viewer uses PySide6, loaded only when the viewer is opened.

This makes the CLI suitable for locked-down build environments.


Documentation


Contributing

Run the test suite:

python -m unittest discover -s tests

The compare core must remain standard-library-only.

See Architecture before making changes.

Issues and pull requests are welcome.


Author

Long Vo Thien

License

Released under the MIT License © 2026 Long Vo Thien.

About

Diff two AUTOSAR/Simulink codegen folders and see only the real changes — noise filtered, self-contained HTML report, zero dependencies

Topics

Resources

Contributing

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages