Code::Blocks Forums

User forums => Help => Topic started by: thomas on June 10, 2005, 07:08:15 pm

Title: Post-compilation steps not getting saved
Post by: thomas on June 10, 2005, 07:08:15 pm
I already solved it for myself, just writing in case anyone else has the same problem:

Post compile steps are "broken" when there are pre-compile steps at the  same time. The reason is that the project saver and the project loader don't quite speak the same language, so the pre-compile steps get loaded while the post-compile steps don't.

This is what goes into the project file:
Code

<ExtraCommands>
    <Add before="this is done before compile"/>
</ExtraCommands>
<ExtraCommands>
    <Add after="this being done after"/>
</ExtraCommands>


and this is what the project loader expects:
Code

<ExtraCommands>
    <Add before="this is done before compile"/>
    <Add after="this being done after"/>
</ExtraCommands>


A functional workaround (if you are reluctant to rebuild c::b) is this:

Code

sed  -e 'N;s/\n//;N;s/\n//;s%</ExtraCommands>\s*<ExtraCommands>%%g'  project.cbp


Quite nasty, but put in a batch file, it is not that painful really, and it fixes things :)



The "guilty" function in projectloader.cpp (for those who *want* to recompile c::b) is ProjectLoader::DoExtraCommands.
Code

TiXmlElement* node = parentNode->FirstChildElement("ExtraCommands");
if (!node)
 return; // no options

TiXmlElement* child = node->FirstChildElement("Add");
while (child)
 {
 ...
 }

should be something like
Code

if( !(TiXmlElement* node = parentNode->FirstChildElement("ExtraCommands")) )
return;
do
 {
 TiXmlElement* child = node->FirstChildElement("Add");
 while (child)
  {
  ...
  }
 }while ( ( TiXmlElement* node = node->NextSiblingElement("ExtraCommands") ) )

One could argue, too, that the project is correctly read in, as several Adds inside one ExtraCommands seems more logical. In that case the save function would have to be changed.
Title: Post-compilation steps not getting saved
Post by: mandrav on June 10, 2005, 09:58:53 pm
Which C::B version are you referring to?

Yiannis.
Title: Post-compilation steps not getting saved
Post by: thomas on June 11, 2005, 06:45:56 pm
1.0finalbeta build May 15 2005, 16:02:37
Title: Post-compilation steps not getting saved
Post by: mandrav on June 11, 2005, 10:29:24 pm
Mind submitting a bug report about this? It will be forgotten if it is just left here...

Yiannis.
Title: Post-compilation steps not getting saved
Post by: rickg22 on June 12, 2005, 12:26:33 am
I submitted it. :)