User forums > Using Code::Blocks

Saving everything automatically before every build

<< < (3/3)

cacb:

--- Quote from: BlueHazzard on September 24, 2019, 06:15:39 pm ---here is the relevant ticket:
https://sourceforge.net/p/codeblocks/tickets/396/

there is a small squirrel snippet you can use as pre build step

Preferably i would introduce a option that enables the saving on building...

--- End quote ---
Thank you, thank you, I will try the squirrel snippet! I agree there should be a built-in option to do this, the squirrel snippet is a work around, but much better than nothing.

cacb:
I have now tested the squirrel script and it works! It can be enabled by adding it in <ExtraCommands> outside all build targets, so it always happens, regardless of which build target is active:

<ExtraCommands>
    <Add before="[[ GetProjectManager().SaveAllProjects(); ]]" />
</ExtraCommands>

This obviously saves all projects in a workspace, so it does not make sense to add this in every project in a workspace, and it would be cumbersome too. I have several workspaces with quite a few projects, so I found that I can instead create a dummy "Prebuild" project in such workspaces and let it do nothing except run the above squirrel script in its own prebuild step. The other projects can then depend on that Prebuild project. All project files in the workspace are then always saved before every build and the setting for this is in one place.

Still a work-around, but quite a nice one. It fixes the issue with project files not being checked in to source control.

Navigation

[0] Message Index

[*] Previous page

Go to full version