Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: LETARTARE on January 13, 2013, 12:56:38 pm

Title: pre-build steps
Post by: LETARTARE on January 13, 2013, 12:56:38 pm
hello,
I read : http://wiki.codeblocks.org/index.php?title=The_build_process_of_Code::Blocks (http://wiki.codeblocks.org/index.php?title=The_build_process_of_Code::Blocks)
and : http://wiki.codeblocks.org/index.php?title=Variable_expansion (http://wiki.codeblocks.org/index.php?title=Variable_expansion) conditional condition

With C::B12.11 Vista Pro
In a project I want to start a conditional order before compilation
Quote
cmd /c echo "Pre-build steps"
I defined in "Project build options->Custom variables"
Quote
GOOD=false
or
Quote
GOOD=true
and in "Project build options->Pre/post build steps"
Quote
$(if(GOOD) ) {cmd /c echo "Pre-build steps" }

I run the generation and I get the result:
Quote
[100,0%] Running project pre-build steps
 (false ) {cmd /c echo "Pre-build steps"} {}
Execution of ' (false ) {cmd /c echo "IRtest2 Pre-build steps"} {}' in 'U:\DONNEES\TRAVAIL_NT\CodeBlock\Arduino\IRtest2' failed.

Is it a mistake on my part or not?
Sincerely


Title: Re: pre-build steps
Post by: MortenMacFly on January 13, 2013, 01:26:12 pm
Is it a mistake on my part or not?
I'm afraid so. In SVN, see how you can use such macros/scripting foo in this project file:
[C::B_SVN]\src\tools\test\macrosmanager\macrosmanager.cbp
It covers pretty much every case.

BTW: From the code its unclear to me if you want use C::B's scripting engine, variable expansion, both, or not... ???

However, the example posted above will help.
Title: Re: pre-build steps
Post by: Jenna on January 13, 2013, 01:40:59 pm
Quote from: http://wiki.codeblocks.org/index.php?title=Variable_expansion#Conditional_Evaluation
Please do note that neither the variable syntax variants %if(...) nor $(if)(...) are supported for this construct.

In your case something like:
Code
cmd /c echo $if($GOOD){"Pre-build steps"}
should work
Title: Re: pre-build steps
Post by: LETARTARE on January 13, 2013, 02:38:09 pm
thank you very much to both.
You are always as effective in your answers
I misread the text !

Error syntax !!
it's correct :
Quote
echo $if($GOOD) {"Pre-build step"}
or
Quote
cmd /c echo $if($GOOD) {"Pre-build step"}

Cordially.