News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

getting list of just source files (*.c) for a tool parameter

Started by trailstrider, April 21, 2016, 06:00:25 AM

Previous topic - Next topic

trailstrider

Hi-

   The ${ALL_PROJECT_FILES} variable expansion is just that... Everything.   I can't seem to find a builtin variable that would be appropriate for only selecting the files in the my Sources folder, which is essentially all the *.c in the project.  Also, i'm looking at adding a test directory for unit test harnesses and am likely going to want to be able to select those separately also for passing to a tool.  Am i correct in assuming that I can use [[ ]] script expansion to get what i need since there doesnt seem to be a variable expansion builtin for this?  Also, i cant seem to get variable expansion working quite right either... 

Perhaps im just being an idiot, but the documentation isnt helping in this case either.

Thanks

oBFusCATed

(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

trailstrider

Any hints on where to start for getting that list as efficiently as possible?  Perhaps even a way to automate creating a variable for that list that is accessible to the tools?

As an aside, I did try to go down the scripting route last night, but am looking for some help on what calls are going to be most fruitful.   I had opened the scripting console, and tested with just the one in the documentation:

[[ print(GetProjectManager().GetActiveProject().GetTitle()); ]]

I ran it without the [[ and ]], so just print(print(GetProjectManager().GetActiveProject().GetTitle());

It didn't work. That was last night.   I noticed my machine was getting very sluggish from having left Code::Blocks running for a couple days, so i suspected a memory leak and closed it. 

This morning, I tried again and its working all of a sudden.   I'll report that bug later, and maybe run some Polyspace on the source code for Code::Blocks later to see if i can track any issues down which are more specific.  For now, just trying to get the list of source files i need to pass to a tool.  Glad that the script console will work for me, when i was concerned it wouldn't.

oBFusCATed

Quote from: trailstrider on April 21, 2016, 02:46:48 PM
Perhaps even a way to automate creating a variable for that list that is accessible to the tools?
This is only possible if you modify the internals of codeblocks.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

trailstrider

Good to know.  Just to be clear, there is no way to run a script in one place, and export the variables so that they are available to the Tools?  Trying to put an entire script in a single call is pretty messy/hacky.

Regardless, any hints on the script calls i'll need?  So far, it appears something like this...

fc = GetProjectManager.GetActiveProject().GetFilesCount();
file_string = @"";  //init empty string
// would prefer to use the squirrel foreach here, but then, if i could get the full list of files directly, i wouldnt have to do this anyway!
for(i=0;i<fc;i+=1)
{
  file_string += GetProjectManager.GetActiveProject().GetFile(i).relativeToCommonTopLevelPath() +@" ";
}


but its not working in the console since it keeps complaining about TABLE indexes not existing... i think because the script console is stuck in a funky state.  in the local scope, there is only a 'this' variable, which is a table...  and its not letting me define any local variables because im stuck in a table apparently?

LETARTARE

Hello,
I wrote a script plugin 'squirrel' to translate the projects  'Code::Block' which comes with a script ' tools.script ' which will list the files of a project .
Here the discussion forum :http://forums.next.codeblocks.org/index.php/topic,18223.msg137602.html#msg137602
And here the sources with explanatory: https://sourceforge.net/projects/wxtranslate
I just try with 'svn1816' , it works well .

Maybe this will help.

Best regards.

CB-13834, plugins-sdk-2.25.0 : Collector-2.6.5, AddOnForQt-5.1.2
1- Win7 Business Pack1 64bits : wx-3.2.8, gcc-15.2.0,
2- OpenSuse::Leap-15.6-64bits : wx-3.2.8;gtk3-u, gcc-15.2.0,
=> !! The messages are translated by 'Deepl'