Files
qt-migration-legatus/qt6-after/qt6-migrated-legatus/fix_rti_conditionals.py
T
torstenandCopilot b774f4035c Qt6 Migration: DDS-Stubs, Logger-Fixes, Export-Header Korrekturen
- NGL_ADD_LIBRARY2: 87 CMakeLists.txt konvertiert für Export-Header Generierung
- 44 Export-Header Include-Pfade korrigiert (_export.h)
- 81 DDS-Stub-Header generiert (*_dtc.h, *_fts.h, *_dts.h, *_ftc.h)
- INGLLogger: Duplikat gelöscht, m_logger Member entfernt, variadische Makros
- Q_FUNC_INFO Redefinition behoben (Qt6 definiert bereits)
- FATAL_LOG Makro hinzugefügt
- InfrastructureManagement DDS-Stubs (ism.hpp, ism_enums.hpp, ism_ftc.h)
- FilterManagement DDS-Stubs (flt_ftc.h, flt_dts.h)
- AreaEffectSimulation DDS-Stubs (aes.hpp, aes_enums.hpp)
- SymbolAppearance Klasse vollständig definiert mit content() Methode
- BuildingComponentFilter Klasse definiert mit Copy-Konstruktor
- Ftc Factory: nullptr Return (abstract class)
- AesFilter Klasse in aes.hpp hinzugefügt
- Dtc Klasse in ppm.hpp mit participantChanged Signal
- AesType Enum: alle 15 At* Werte definiert
- AesEffectState_def: EsReceived hinzugefügt
- DataModification Enum: eAdded/eModified/eRemoved
- function_reply_object.h → core_types.h Include-Pfad (72 Dateien)
- Enum-Class-Streaming Template-Operator in INGLLogger.h
- ism_mounting_point.h: QImage → QtGui/QImage, QGuiApplication/QScreen
- ism_data_plugin_interface.h: QSet Include, Include-Reihenfolge
- QRegExp → QRegularExpression in tpm_js_parser.cpp
- .underlying() Aufrufe zu direktem Enum-Vergleich korrigiert
- Include-Pfade: aes.hpp in symbol_appearance_settings_impl.h und aes_display_filter_impl.h

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-08-19 06:06:24 +02:00

118 lines
4.0 KiB
Python

#!/usr/bin/env python3
"""
Automatisches Skript um BUILD_RTI conditional blocks zu CMakeLists.txt Dateien hinzuzufügen.
Findet alle Dateien die RTI::nddscpp2 referenzieren und wrappt den relevanten Code in IF(BUILD_RTI).
"""
import os
import re
import sys
def process_cmake_file(filepath):
"""Process a single CMakeLists.txt file and add BUILD_RTI conditionals if needed."""
with open(filepath, 'r', encoding='utf-8', errors='ignore') as f:
content = f.read()
# Check if file uses RTI::nddscpp2 or other RTI targets
rti_pattern = r'RTI::(nddscpp2|nddsc|ndds|rtiroutingservice)'
if not re.search(rti_pattern, content):
return False # No RTI usage, skip
# Check if already wrapped in BUILD_RTI
if re.search(r'if\s*\(\s*BUILD_RTI\s*\)', content, re.IGNORECASE):
print(f" SKIP: {filepath} - already has BUILD_RTI conditional")
return False
print(f" PROCESS: {filepath}")
# Strategy: Wrap the entire file content after initial comments/options in IF(BUILD_RTI)
# But preserve cmake_minimum_required, project(), and option() statements at the top
lines = content.split('\n')
output_lines = []
# Track state
in_header = True
header_end_index = 0
indent_level = 0
for i, line in enumerate(lines):
stripped = line.strip()
# Skip empty lines and comments at the very beginning
if in_header and (not stripped or stripped.startswith('#')):
output_lines.append(line)
continue
# Keep cmake_minimum_required, project(), option(), set() at top level
if in_header:
if (stripped.startswith('cmake_minimum_required') or
stripped.startswith('project(') or
stripped.startswith('option(') or
(stripped.startswith('set(') and 'CACHE' in stripped)):
output_lines.append(line)
continue
else:
in_header = False
header_end_index = len(output_lines)
output_lines.append(line)
# Now wrap the non-header part in IF(BUILD_RTI)
if header_end_index < len(output_lines):
# Insert IF(BUILD_RTI) after header
final_lines = output_lines[:header_end_index]
final_lines.append('')
final_lines.append('if(BUILD_RTI)')
final_lines.append('')
# Add remaining content with proper indentation
for line in output_lines[header_end_index:]:
final_lines.append(' ' + line if line.strip() else line)
final_lines.append('')
final_lines.append('endif()')
final_lines.append('')
new_content = '\n'.join(final_lines)
# Write back
with open(filepath, 'w', encoding='utf-8') as f:
f.write(new_content)
return True
return False
def main():
base_dir = sys.argv[1] if len(sys.argv) > 1 else '.'
print(f"Scanning for CMakeLists.txt files with RTI dependencies in {base_dir}...")
processed_count = 0
skipped_count = 0
for root, dirs, files in os.walk(base_dir):
# Skip .git and other hidden directories
dirs[:] = [d for d in dirs if not d.startswith('.')]
if 'CMakeLists.txt' in files:
filepath = os.path.join(root, 'CMakeLists.txt')
if process_cmake_file(filepath):
processed_count += 1
else:
# Check if it has RTI but was skipped
with open(filepath, 'r', encoding='utf-8', errors='ignore') as f:
content = f.read()
if re.search(r'RTI::', content):
skipped_count += 1
print(f"\n=== Summary ===")
print(f"Processed (added BUILD_RTI): {processed_count} files")
print(f"Skipped (already conditional or no RTI): {skipped_count} files")
return 0
if __name__ == '__main__':
sys.exit(main())