cancel
Showing results for 
Search instead for 
Did you mean: 

TouchGFX Designer adds redundant line ending to .cproject file

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.

 

 

Kudo posts if you have the same problem and kudo replies if the solution works.
Click "Accept as Solution" if a reply solved your problem. If no solution was posted please answer with your own.
9 REPLIES 9
GaetanGodart
ST Employee

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,

Gaetan Godart
Software engineer at ST (TouchGFX)

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.

Kudo posts if you have the same problem and kudo replies if the solution works.
Click "Accept as Solution" if a reply solved your problem. If no solution was posted please answer with your own.

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,

Gaetan Godart
Software engineer at ST (TouchGFX)

The problem is back again.

Kudo posts if you have the same problem and kudo replies if the solution works.
Click "Accept as Solution" if a reply solved your problem. If no solution was posted please answer with your own.

Hello @unsigned_char_array ,

 

Thank you for your feedback, I will see with the team.

 

Regards

Gaetan Godart
Software engineer at ST (TouchGFX)

Any update?

Kudo posts if you have the same problem and kudo replies if the solution works.
Click "Accept as Solution" if a reply solved your problem. If no solution was posted please answer with your own.

Hello @unsigned_char_array ,

 

This change is now scheduled for implementation by the team.

 

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)

Great to hear. Because the problem is still present in 4.24.1. I hope it will be in the next release.

Kudo posts if you have the same problem and kudo replies if the solution works.
Click "Accept as Solution" if a reply solved your problem. If no solution was posted please answer with your own.
ferro
Lead

https://community.st.com/t5/stm32cubeide-mcus/cube-1-16-1-and-gfxdesigner-4-24-1-generates-different-cproject/m-p/778202/highlight/true#M34644

 

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")