Author Topic: add a directory to the browser without specifing each single file  (Read 13091 times)

Offline mattn2

  • Multiple posting newcomer
  • *
  • Posts: 18
Hi,

we are using a custom makefile driven codeblocks project. My question is, is there a way to only specify a directory (or virtual folder) and only list the files in it, without specifying each single file in the project.cbp file? the files are already specified in the makefiles and i don't want to maintain two locations when we add/rename/delete files.

thanks a lot
Martin

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: add a directory to the browser without specifing each single file
« Reply #1 on: October 14, 2012, 09:29:40 pm »
You can use project->add files recursively to include all of the files in a given path (the dialog then gives you the option to check off the files you want, or wildcard match them). The problem is that after you add, rename, delete etc outside of C::B you will need to manually update the project file. I think it would be reasonably straightforward to write a plugin that automatically updates the project files to the files in the underlying directory. Another option would be to patch C::B itself to implement the updating. I think this would only make sense when working with makefiles, otherwise it would have unpredictable effects on C::B's build targets.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: add a directory to the browser without specifing each single file
« Reply #2 on: October 15, 2012, 07:48:26 am »
Another option would be to patch C::B itself to implement the updating. I think this would only make sense when working with makefiles, otherwise it would have unpredictable effects on C::B's build targets.
Another option is to use the newly introduced "glob" power feature. I never used it so far, but killerbot should be able to explain.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline mattn2

  • Multiple posting newcomer
  • *
  • Posts: 18
Re: add a directory to the browser without specifing each single file
« Reply #3 on: October 15, 2012, 12:55:45 pm »
is there any information about the glob feature?

Offline mattn2

  • Multiple posting newcomer
  • *
  • Posts: 18
Re: add a directory to the browser without specifing each single file
« Reply #4 on: October 15, 2012, 12:57:06 pm »
found it mentioned here: http://forums.codeblocks.org/index.php/topic,16772.0.html

but nothing more pops up in the wiki or the forum.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: add a directory to the browser without specifing each single file
« Reply #5 on: October 15, 2012, 01:15:17 pm »
but nothing more pops up in the wiki or the forum.
Its a power user feature that has no UI support (yet). It was introduced with the 25 August 2012 nightly build,more precisely in revision 8233:
Quote
* added power user support for units glob feature (these are directory paths that can be specified, and all files in there will be considered as sources for the project. This can be based on a wildcard for the * file types, and can be recursive. When no wildcard is specified (empty) the default CB wildcard for adding files is used.
http://preview.tinyurl.com/8lrwz29
It adds another project file entry "UnitsGlob", which "are directory paths that can be specified, and all files in there will be considered as sources for the project. This can be based on a wildcard for the file types, and can be recursive. When no wildcard is specified (empty) the default CB wildcard for adding files is used".

You either try to understand from the changes or wait until killerbot enlighten you, maybe. I don't know how busy he is atm...
« Last Edit: October 15, 2012, 01:18:18 pm by MortenMacFly »
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline mattn2

  • Multiple posting newcomer
  • *
  • Posts: 18
Re: add a directory to the browser without specifing each single file
« Reply #6 on: October 25, 2012, 10:11:42 pm »
thanks a lot for the link
i will try it with this asap:  <UnitsGlob directory="src" wildcard="*.cpp" recursive="1" />
« Last Edit: October 25, 2012, 10:19:07 pm by mattn2 »

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5490
Re: add a directory to the browser without specifing each single file
« Reply #7 on: October 25, 2012, 11:00:58 pm »
ring ring   ;D

There's no GUI for it (yet), but I have been using it for 2 months now, and no problems discovered.
How does it work :
- you specify which directories should be searched for source files
- recursively or not
- you can specify a pattern/wildcard (by default it uses the same wildcard as CB uses when you add files recursively to a project through the gui)

New file in the directory are only picked up when the project is loaded, so you might need to reload the project (workspace) [we don't have a project reload command (??yet??)], or you can later on extra files to the project as in the past. At save time of the project extra added files that are actually covered by the glob entries will be removed as separate unit entries since the glob covers them.

Limitations : this is more or less an "all are equal approach", the moment you specify specific build options per file, there might be inconsistencies, and more business logic, or user feedback will be needed.
But if you can live with the "all are equal" approach this feature rocks  8)

Typical examples :
Code
<UnitsGlob directory="src" recursive="1" />
<UnitsGlob directory="include" recursive="1" />
« Last Edit: October 26, 2012, 07:40:17 am by killerbot »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: add a directory to the browser without specifing each single file
« Reply #8 on: October 26, 2012, 06:19:04 am »
ring ring   ;D
Should this make it into the WiKi at least?
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ