Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

Global addition of build options (in this case search directories), in Squirrel!

(1/3) > >>

xod:
*EDIT* Misplaced post. Kindly move to the plugin devel forum, thanks! */EDIT*

Hello there! After unsuccessfully trying the IRC channel yesterday, I decided to register and try my luck here in the forum.

I have created a script that provides a menu entry, and when clicked..

..it does..
1) Execute a 'cmd.exe' script that iterates over a preselected (by me) folder's contained folders, detects whether they have either/both of 'include' and 'lib' folders, and ouputs the full path to those detected folders.

..and is supposed to also do..
2) Add those paths (output by 'cmd.exe') to the global compiler and linker search paths.

Question is how to do that, if possible ? I have trial-and-error tested (not completely sure whether it is supposed to be method or static function):

* CompileOptionsBase().AddIncludeDir(PATH);
* CompileOptionsBase.AddIncludeDir(PATH);

which do nothing and are silently ignored. Maybe the class/object is initialized at build-time ?!
I have also tried (for starters):

* GetCompilerFactory().GetCompilerByName(_T("GNU GCC Compiler"));

which fails, saying the index 'GetCompilerByName' doesn't exist. I have not evaluated ConfigManager yet, largely because I don't know what actual arguments are expected. I'd be grateful for any solutions to my problem.

gamemusta:
Are you familiar with Squirrel syntax in respect to Code::Blocks? You should maybe study this: http://wiki.codeblocks.org/index.php/Scripting_commands. I suggest getting the compiler by ID instead. Not much I can do without first seeing your actual attempt though. Maybe post the script file contents?

xod:
Thank you for replying, much appreciated. I'm not too familiar with Squirrel, that's true, but my knowledge is not a showstopper as far as the test script goes.

Here's the script. I've stripped it down so it tries to add an 'include' search path directly instead of using 'cmd.exe'. Better for the purpose of illustration:


--- Code: ---// not called: clearly needs to be executed as build script
function SetBuildOptions(baseOptions)
{
Log(_T("***** [xod] SetBuildOptions() *****"));
}



// called
function OnMenuClick()
{
// nothing happens
CompileOptionsBase().AddIncludeDir(_T("E:\\applications\\__inpath__\\allegro\\include"));
CompileOptionsBase.AddIncludeDir(_T("E:\\applications\\__inpath__\\allegro\\include"));
}



Log(_T("***** xod - begin *****"));

local scriptManager = GetScriptingManager();
scriptManager.RegisterScriptMenu(_T("Settings/[xod] Add __inpath__ SDK paths"), _T("OnMenuClick"), true); // ok

local compilerFactory = GetCompilerFactory();
Log(_T("Number of compilers: " + compilerFactory.GetCompilersCount())); // index 'GetCompilersCount' not found
local gcc = compilerFactory.GetCompilerByName(_T("GNU GCC Compiler")); // same here, would this line execute

Log(_T("***** xod - end *****"));
--- End code ---

I had hoped that a startup script could register (or merely define) callbacks for events relating to the various stages of C::B's build progress, and provide contextual interfaces obviously. I much prefer my scripts to not be attached per project manually and instead be global and start on C::B's startup. Is that possible ?

*EDIT*

Like you wrote, I should have used GetCompilerIDByName(). Problem is though that the apparent CompilerFactory API exposed to scripts merely returns wsStrings, bools, and ints. No objects. I suppose I looked in the C++ 'SDK documentation' and presumed the (full) C++ CompilerFactory API be exposed to scripts too.

*EDIT 2*

I have made a script plugin as well, but no new API under the sun there as far as I can tell; I didn't find any doc on cbScriptPlugin..

gamemusta:
Code::Blocks ships with an example plugin and such as far as I know. Get to reading bro:

http://wiki.codeblocks.org/index.php/Scripting_commands

Are you sure you searched on the topic of script Plugins?

http://wiki.codeblocks.org/index.php/Script_plugins
http://wiki.codeblocks.org/index.php/Category:Scripting_Code::Blocks


--- Quote ---
--- Code: ---// nothing happens
CompileOptionsBase().AddIncludeDir(_T("E:\\applications\\__inpath__\\allegro\\include"));
CompileOptionsBase.AddIncludeDir(_T("E:\\applications\\__inpath__\\allegro\\include"));
--- End code ---

--- End quote ---

By the way, using CompileOptionsBase() by itself will net you null (pun intended) since it's just a base. GetProjectManager().GetActiveProject().GetCurrentlyCompilingTarget().AddIncludeDir(<dir>) or GetProjectManager().GetActiveProject().GetbuildTargets() which fields a wxArrayString for an an index or identifier to a specific target which can be obtained with GetProjectManager().GetActiveProject().GetbuildTarget(<identifier>) and used with GetProjectManager().GetActiveProject().GetbuildTarget(<identifier>).AddIncludeDir(<dir>), are your best bet.


--- Quote ---
--- Code: ---Log(_T("Number of compilers: " + compilerFactory.GetCompilersCount())); // index 'GetCompilersCount' not found
--- End code ---

--- End quote ---

GetCompilersCount? no. Check the first link for valid commands. GetDefaultCompilerID() yields "gcc", for example. GetCompilerIDByName(), not GetCompilerByName(), is for when you're looking for a specific compiler you know the exact name of. You also might wanna brush up on your Squirrel bud, just in case:

http://www.squirrel-lang.org/doc/squirrel3.html

xod:

--- Quote from: gamemusta on August 15, 2016, 02:41:55 am ---Code::Blocks ships with an example plugin and such as far as I know. Get to reading bro:

http://wiki.codeblocks.org/index.php/Scripting_commands

Are you sure you searched on the topic of script Plugins?

http://wiki.codeblocks.org/index.php/Script_plugins
http://wiki.codeblocks.org/index.php/Category:Scripting_Code::Blocks
--- End quote ---

I believe I did write that I wrote a script plugin as well. Yes the Script_Plugin page has "some" documentation, but I assumed there were more functions involved than those in that page.


--- Quote ---
--- Quote ---
--- Code: ---// nothing happens
CompileOptionsBase().AddIncludeDir(_T("E:\\applications\\__inpath__\\allegro\\include"));
CompileOptionsBase.AddIncludeDir(_T("E:\\applications\\__inpath__\\allegro\\include"));
--- End code ---

--- End quote ---

By the way, using CompileOptionsBase() by itself will net you null (pun intended) since it's just a base. GetProjectManager().GetActiveProject().GetCurrentlyCompilingTarget().AddIncludeDir(<dir>) or GetProjectManager().GetActiveProject().GetbuildTargets() which fields a wxArrayString for an an index or identifier to a specific target which can be obtained with GetProjectManager().GetActiveProject().GetbuildTarget(<identifier>) and used with GetProjectManager().GetActiveProject().GetbuildTarget(<identifier>).AddIncludeDir(<dir>), are your best bet.
--- End quote ---

Thanks for the explanation. However, I want to add search paths (include and lib folders) globally, across projects. Or in other words, I want to configure global compiler/linker options. C::B has global search path settings, but question is if we can programmatically configure. If ConfigManager is the way, I guess I have to see some script/snippet/tutorial around that.


--- Quote ---
--- Quote ---
--- Code: ---Log(_T("Number of compilers: " + compilerFactory.GetCompilersCount())); // index 'GetCompilersCount' not found
--- End code ---

--- End quote ---

GetCompilersCount? no. Check the first link for valid commands. GetDefaultCompilerID() yields "gcc", for example. GetCompilerIDByName(), not GetCompilerByName(), is for when you're looking for a specific compiler you know the exact name of. You also might wanna brush up on your Squirrel bud, just in case:

http://www.squirrel-lang.org/doc/squirrel3.html

--- End quote ---

Those were for testing/illustration purpose, to illustrate that the (C++) CompilerFactory API is not fully exposed to squirrel. I know the Scripting_commands page only shows what's actually exposed to squirrel, but it was just a curious test and a big question mark I suppose. And no, mastering squirrel is no interest of mine, not as long as I'm unsure of whether the API allows me to programmatically configure the global (not per-project) compiler options or not. Looks like the Compiler object returned by some of the CompilerManager functions would do the job, but unfortunately those functions aren't exposed to squirrel.

Navigation

[0] Message Index

[#] Next page

Go to full version