Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: Pierre8r on August 09, 2018, 10:28:26 am

Title: Is there a script to generate automatically all the *.cbp project files?
Post by: Pierre8r on August 09, 2018, 10:28:26 am
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
Title: Re: Is there a script to generate automatically all the *.cbp project files?
Post by: oBFusCATed on August 09, 2018, 12:38:00 pm
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.
Title: Re: Is there a script to generate automatically all the *.cbp project files?
Post by: Pierre8r on August 09, 2018, 04:50:39 pm
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?
Title: Re: Is there a script to generate automatically all the *.cbp project files?
Post by: oBFusCATed on August 09, 2018, 07:59:39 pm
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.
Title: Re: Is there a script to generate automatically all the *.cbp project files?
Post by: BlueHazzard on August 10, 2018, 01:38:47 pm
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?
Title: Re: Is there a script to generate automatically all the *.cbp project files?
Post by: Pierre8r on August 10, 2018, 06:05:20 pm
Hello BlueHazzard,
It's about C++ files not C files.
I want to create a cbp file for each directory and sub directory.

(https://image.ibb.co/dLbS89/choisir_les_constructeurs.jpg)
(https://image.ibb.co/g01S89/Code_Blocks.jpg)
(https://image.ibb.co/hhm5vp/finale.jpg)

choisir_les_constructeurs.cbp
Code
<?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
<?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>




Title: Re: Is there a script to generate automatically all the *.cbp project files?
Post by: ollydbg on August 11, 2018, 04:51:09 am
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.
Title: Re: Is there a script to generate automatically all the *.cbp project files?
Post by: BlueHazzard on August 11, 2018, 10:55:47 am
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...
Title: Re: Is there a script to generate automatically all the *.cbp project files?
Post by: oBFusCATed on August 11, 2018, 06:16:29 pm
Probably it is a good idea to extend it with these capabilities.