News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Is there a script to generate automatically all the *.cbp project files?

Started by Pierre8r, August 09, 2018, 10:28:26 AM

Previous topic - Next topic

Pierre8r

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

oBFusCATed

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!]

Pierre8r

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?

oBFusCATed

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!]

BlueHazzard

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?

Pierre8r

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
<?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
<?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>






ollydbg

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.

BlueHazzard

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...

oBFusCATed

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!]