cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeMX: how to disable project saving on code generation?

jjwk
Associate

Hello,

I use STM32CubeMX in a shared project and different developers use different tools to work with its output. So e. g. I want code generation with a makefile output while others use the STM32CubeIDE.

Currently every time when I click "generate code" the project is saved and its .ioc file is overwritten. This is annoying since after I push commits, the next person has to change it again (and adding it to the .gitignore would mean I have to remember including it again when I make actually meaningful changes in the project file). Code generation is not needed a lot after everything has been set up, but nonetheless this is annoying since quickly trying out some stuff without remembering to revert everything manually is not possible. How do I turn this off? I only want to save the project when I explicitly ask CubeMX to do so.

4 REPLIES 4
Oskar_H
Senior

Hello,

as far as I know this option does not exist, there is always a save before generating project for safety I think.

Knowing that code generation sometimes hangs unexpectedly with no possibility to recover in next session. Imagine you forgot to save explicitly an important change, start the code generation and suddenly it crashes, then you lose everything !

Normally if you don't change anything in your project and generate the code, then the automatic save should not modify the ioc file. Is this correct or I missed something ?

Pavel A.
Evangelist III

This is a drawback of multi-user version control: you get to use it responsibly and control your impulses.

In git you can define so called "hooks", these are scripts that execute before of certain action and can block it. So you can add a commit hook that prompts to allow change of the .ioc or revert it.

However CubeMX/IDE could be more version control friendly by not reordering lines in .ioc file unless there's a real change. Sort/group the lines in a stable order.

Newer CubeMX versions can define a post-generate script, this can be used to detect unwanted changes as well.

 

jjwk
Associate

Thank you for your responses.

@Oskar_HI think that is correct, but my problem is that I do have to make a change (changing the toolchain for the code generation), but not one that includes actual changes to the project.

Unrelated to version control I would also like to make changes and generate code for testing purposes (stuff that I know I won't keep) without changing the project file, so I can easily go back to my original project. With the way it is now I need to revert all changes manually or make a copy of the project beforehand or commit and revert etc. Not that all of this wouldn't make sense or would be overly cumbersome, but to me it's unnecessary workflow interference.

@Pavel A.Thank you for the mention of post generate scripts, I wasn't aware of that. Probably an overkill workaround, but I'll check it out.

 

Still, if anybody from ST is reading this: I would very much appreciate a prompt before overwriting a saved project (with the option to deny of course; could be just shown when clicking on generate code with the option to hide it in the future).



Semer CHERNI
ST Employee

Hello @jjwk 

First let me thank you for posting.

As @Oskar_H the auto save when generating code is there for safety issue to sure you don't lose the made modification;

Also the pre and post build command could be a solution as @Pavel A. mentioned, maybe an over kill as you said for your specific use case.

However, I will see internally what we can do about this request and its feasibility.

KR,
Semer.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.