Author Topic: Is there a script to generate automatically all the *.cbp project files?  (Read 986 times)

Offline Pierre8r

  • Single posting newcomer
  • *
  • Posts: 5
Hello,

I work with Code::Blocks 17.12, under Windows 10.
I downloaded examples of C ++ programs.
These examples are in the form of a directory hierarchy.
Is there a script to generate automatically all the *.cbp project files?

Thank you,
Pierre8r

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 11282
    • Travis build status
No, but probably you could write one using the integrated squirrel scripting language or try and tell us what is missing from the scripting engine.
Or you could just use "add files recursively..." to already existing project.
(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!]

Offline Pierre8r

  • Single posting newcomer
  • *
  • Posts: 5
Thanks oBFusCATed.
Can we generate a cbp file with the --build parameter?
if yes, what do you think is the best idea, use the --build parameter recursively, or copy, modify and rename a cbp file template?
« Last Edit: August 09, 2018, 05:41:17 pm by Pierre8r »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 11282
    • Travis build status
You cannot generate cbp files using the --build parameter of codeblocks. This parameter is used when you want to build existing cbp files on the command line without starting the ui.
(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!]

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2105
Can you explain more what you would like to do?
Create a project for every c file in the folder?
Create a exe for every c file in the project, but only one project file?

Offline Pierre8r

  • Single posting newcomer
  • *
  • Posts: 5
Hello BlueHazzard,
It's about C++ files not C files.
I want to create a cbp file for each directory and sub directory.





choisir_les_constructeurs.cbp
Code: [Select]
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="choisir_les_constructeurs" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="bin/Debug/choisir_les_constructeurs" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Debug/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-g" />
</Compiler>
</Target>
<Target title="Release">
<Option output="bin/Release/choisir_les_constructeurs" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Release/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-O2" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-Wall" />
<Add option="-fexceptions" />
</Compiler>
<Unit filename="main.cpp" />
<Extensions>
<code_completion />
<envvars />
<debugger />
<lib_finder disable_auto="1" />
</Extensions>
</Project>
</CodeBlocks_project_file>

finale.cbp
Code: [Select]
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="finale" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="bin/Debug/finale" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Debug/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-g" />
</Compiler>
</Target>
<Target title="Release">
<Option output="bin/Release/finale" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Release/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-O2" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-Wall" />
<Add option="-fexceptions" />
</Compiler>
<Unit filename="main.cpp" />
<Extensions>
<code_completion />
<envvars />
<debugger />
<lib_finder disable_auto="1" />
</Extensions>
</Project>
</CodeBlocks_project_file>




« Last Edit: August 10, 2018, 06:10:57 pm by Pierre8r »

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5128
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Here is my suggestion:
1, you can write a simple script(maybe using python) file which replace the source file paths in the cbp(you may first create a cbp template).
2, you can write a simple cmake, and let cmake generate all the cbp files.

I think method 1 is easier.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2105
I have looked into the squirrel api and it is not possible with the current api in codeblocks to do this within codeblocks...
The API is missing some folder traversing and file searching... : http://wiki.codeblocks.org/index.php/Scripting_commands#IO_namespace

@obfuscated: Is it worth to extend the scripting api? I think file handling is something essential for a embedded scripting api...

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 11282
    • Travis build status
Probably it is a good idea to extend it with these capabilities.
(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!]