I have existing project in Code::Blocks 17.12 and I would like to add command after build using script (Properties -> build scripts).
Are pre/post build steps in Code:Blocks doing same thing as AddCommandsBeforeBuild/AddCommandsAfterBuild scripting commands? How to use AddCommandsBeforeBuild and AddCommandsAfterBuild?
I tried to add post build commands to existing project using script:
// My script - why it does not work?
function SetBuildOptions(base)
{
base.AddCommandsBeforeBuild(_T("cmd /c mkdir bbb"));
base.AddCommandsAfterBuild(_T("cmd /c mkdir ccc"));
}
but it doesn't work. If I put the following command directly to the Build options -> Pre/post build steps it works fine:
Script in general also works fine, because if I put following example in script, the directory is created and compiler option is added:
// My script - example of working commands
function SetBuildOptions(base)
{
IO.Execute(_T("cmd /c mkdir aaa"));
base.AddCompilerOption(_T("-Os"));
}
In addiction AddCompilerOption and AddCommandsAfterBuild are both defined in same base: http://wiki.codeblocks.org/index.php/Scripting_commands#CompileOptionsBase
I noticed that AddCommandsAfterBuild is used (for example) in AVR template like this:
// Template avr/wizard.script
function SetupProject(project)
{
project.AddCommandsAfterBuild(pb_lockhex);
}
but if I put that function to my script it doesn't work.
Is it even possible to use AddCommandsAfterBuild in normal (not template) script with existing project?
The "base" parameter in this function is a CompileTargetBase instance. Source:http://wiki.codeblocks.org/index.php/Build_scripts (http://wiki.codeblocks.org/index.php/Build_scripts)
When I load sript into scripting console it only say "Script loaded successfully". There are no other errors in Scripting console nor Build log when I build project.
I never used scripting console before :-[
I typed this in console:
GetProjectManager().GetActiveProject().AddCommandsBeforeBuild(_T("cmd /c mkdir abc"));
This option just permamently ads pre build step to project build options -> Pre/post build steps so I think this command is meant to be used mainly in wizard scripts.
I decided to not use script for this. I will just put my pre/post build steps directly in build options -> Pre/post build steps.
Thanks for help.