User forums > Using Code::Blocks

[Squirrel] How to set variable value visible in project?

<< < (2/2)

MortenMacFly:
Another solution is to make use of envvars through the envvars plugin. It exposes scripting commands that you can use. However, your projects would depend on the presence of this plugin though.

DejaVu:

--- Quote from: stahta01 on August 26, 2015, 06:10:16 pm ---For what objects/classes have you tried the method "SetVar" and it failed to work?

http://wiki.codeblocks.org/index.php?title=Scripting_commands

It worked for me in the past to set a CB custom variable at the target level.
I never figured out if setting one at the project level was possible.

Edit: I have never used SetBuildOptions script before; I have just edited CB wizards.
Edit2: I am guessing you will need to call "GetParentProject"

Tim S.

--- End quote ---

Thanks! Your post solved my problem :) Final solution provided below:

--- Code: ---// set build version (global variable):
buildVersion <- "1.0.1";

// generate build options (called by codeblocks while building):
function SetBuildOptions(base)
{
// set value for variable $(VERSION) which is visible in project settings:
base.SetVar(_T("VERSION"),_T(buildVersion),false);

//(...)
}

--- End code ---

Navigation

[0] Message Index

[*] Previous page

Go to full version