2024-05-14 8:12 AM - edited 2024-05-14 8:13 AM
TouchGFX adds a redundant line ending to .cproject file when clicking generate code even if nothing has changed.
This causes changes to show up in git and also makes merging and pull requests more complicated.
In STM32CubeIDE the line ending is removed after making any change to the project (and optionally reverting the change).
-<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
+<?fileVersion 4.0.0?>
+<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
I'm using TouchGFX 4.23.2, but the problem was also present in older versions. Using STM32CubeIDE 1.15.1, but older version had the same effect.
Please fix this.
2024-05-15 1:57 AM
Hello @unsigned_char_array ,
Thank you for informing us.
I see that you are not the only one experiencing this because there is already 2 kudos on your thread.
I have created an internal ticket and we will fix this.
Regards,
2024-06-14 7:56 AM - edited 2024-06-28 12:36 AM
The issue appears to be fixed in TouchGFX 4.24.0. I didn't see it in the release notes though.
EDIT: called it too early. For some reason I wasn't seeing it for a while. But I confirm the problem is still present.
2024-06-14 9:10 AM
Hello @unsigned_char_array ,
Good to hear.
I have made an internal ticket but it got closed so I assume it was already a known issue.
Either way, it is solved now.
Regards,
2024-06-27 7:24 AM
The problem is back again.
2024-06-28 2:01 AM
Hello @unsigned_char_array ,
Thank you for your feedback, I will see with the team.
Regards
2024-09-17 5:03 AM
Any update?
2024-09-25 6:13 AM
Hello @unsigned_char_array ,
This change is now scheduled for implementation by the team.
Regards,
2024-09-26 2:57 AM
Great to hear. Because the problem is still present in 4.24.1. I hope it will be in the next release.
2025-03-03 6:05 AM
This python script fixes the .cproject
#
# Tested on Windows, Cube 1.17, Gfx 4.24.1
# This script processes a `.cproject` file with the following modifications:
# 1. Replaces every two-space indentation with a tab.
# 2. Uses CRLF (`\r\n`) as the newline format.
# 3. Merges lines 2 and 3 into line 2 with no extra characters between them.
# 4. Ensures the last line is exactly `</cproject>`, with no EOF or trailing newline.
#
import os
def process_cproject_file(filename):
with open(filename, 'r', encoding='utf-8') as file:
content = file.read()
# Force CRLF as the newline type
newline_type = '\r\n'
# Split into lines while preserving newline characters
lines = content.splitlines()
# Replace leading spaces with corresponding number of tabs
processed_lines = []
for line in lines:
leading_spaces = len(line) - len(line.lstrip())
tabs = '\t' * (leading_spaces // 2) # Each two spaces become one tab
processed_lines.append(tabs + line.lstrip())
# Combine lines 2 and 3 into line 2 with no extra space
if len(processed_lines) > 2:
processed_lines[1] = processed_lines[1].rstrip() + processed_lines[2].lstrip()
del processed_lines[2]
# Ensure last element is exactly '</cproject>' with no extra newlines or EOF
processed_lines[-1] = '</cproject>'
# Write back changes using CRLF and ensure no trailing newline
with open(filename, 'w', encoding='utf-8', newline='') as file:
file.write(newline_type.join(processed_lines))
if __name__ == "__main__":
process_cproject_file(".cproject")