- Wrap FIND_PACKAGE(RTI) in IF(NOT TARGET RTI::nddsc) condition - Prevents placeholder targets from overwriting manually configured RTI:: targets - Manual configuration creates RTI:: targets when BUILD_RTI=ON and RTI found - FIND_PACKAGE only called as fallback when manual config doesn't create targets Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Entire-Checkpoint: 01M1CT3XSQXCX9RQR6WM9DG3GH
53 lines
1.7 KiB
Python
53 lines
1.7 KiB
Python
#!/usr/bin/env python3
|
|
import re
|
|
|
|
filepath = "qt-migration-legatus/qt6-after/qt6-migrated-legatus/Lts/Proxies/TrainingAreaBase/training_area_telegrams.cpp"
|
|
|
|
with open(filepath, 'r') as f:
|
|
content = f.read()
|
|
|
|
# Pattern 1: return {QJsonObject{{...}}});
|
|
# Replace with: return QJsonObject{{...}};
|
|
pattern1 = r'return \{QJsonObject\{\{([^}]+(?:\{[^}]*\}[^}]*)*)\}\}\);'
|
|
replacement1 = r'return QJsonObject{{\1}};'
|
|
|
|
# More robust approach: find all occurrences line by line
|
|
lines = content.split('\n')
|
|
new_lines = []
|
|
i = 0
|
|
while i < len(lines):
|
|
line = lines[i]
|
|
# Check for the pattern "return {QJsonObject{{"
|
|
if 'return {QJsonObject{{' in line:
|
|
# Collect all lines until we find the closing });}
|
|
block_start = i
|
|
block_lines = [line]
|
|
j = i + 1
|
|
brace_count = line.count('{') - line.count('}')
|
|
while j < len(lines) and brace_count > 0:
|
|
block_lines.append(lines[j])
|
|
brace_count += lines[j].count('{') - lines[j].count('}')
|
|
j += 1
|
|
|
|
# Now we have the full block, transform it
|
|
block_text = '\n'.join(block_lines)
|
|
# Remove "return {" at start and "});" at end
|
|
block_text = block_text.replace('return {QJsonObject{{', 'return QJsonObject{{', 1)
|
|
# Fix the ending
|
|
block_text = re.sub(r'\}\}\)\);$', '}};', block_text)
|
|
# Also handle case where there's a newline before });
|
|
block_text = re.sub(r'\n\s*\}\}\)\);', '\n}};', block_text)
|
|
|
|
new_lines.extend(block_text.split('\n'))
|
|
i = j
|
|
else:
|
|
new_lines.append(line)
|
|
i += 1
|
|
|
|
content = '\n'.join(new_lines)
|
|
|
|
with open(filepath, 'w') as f:
|
|
f.write(content)
|
|
|
|
print("Fixed return {QJsonObject{{...}}}); patterns")
|