Developer forums (C::B DEVELOPMENT STRICTLY!) > Development
Enhancements to the CB Build System
scarphin:
Considering the amount of interest, I decided to implement all the features I had in mind without going step by step. I attached the patch for qt users to try it if they wish to. This patch is NOT for integration into cb (as it is a huge patch implementing everything) but for the adventurer to customize his/her cb installation. I've been testing the implemented features for about a month now and it seems stable on win7 x64. One last reminder, sometimes the modified project needs to be reloaded when build files are modified or a new target is created.
The patch is created against rev10201 and implements:
1- Default weight for files with custom extensions.
2- Implemented build files for custom builds in file properties dialogue.
3- Practical usage of settings from a predefined custom extension in file properties dialogue (intended for header files with Q_OBJECT).
4- Possibility to use $(project_dir) type of macros for generated files in advanced compiler options or build files in file properties dialogue.
5- Auto-creation of folders of generated or build files if they are not existent.
6- Implemented time-stamp checks for files with custom extensions so the target won't be rebuild if they are up-to-date.
7- Fixes a couple of bugs in the build system.
Example usage for qt projects:
1- Create the settings for .ui, .qrc, .moc (to be used for Q_OBJECT headers) extensions in advanced compiler options.
2- Create a qt project.
3- Add files.
4- Set the header files containing the Q_OBJECT macro to use the settings from the .moc extension in file properties dialogue.
5- Compile the project.
That will be all from me, I hope it will serve qt users' needs.
Edit: Corrected incorrect number order.
MortenMacFly:
--- Quote from: scarphin on April 10, 2015, 08:47:57 pm ---The patch is created against rev10201 and implements:
1- Auto-weight for files with custom extensions.
2- Implemented build files for custom builds in file properties dialogue.
3- Practical usage of settings from a predefined custom extension in file properties dialogue (intended for header files with Q_OBJECT).
3- Possibility to use $(project_dir) type of macros for generated files in advanced compiler options or build files in file properties dialogue.
4- Auto-creation of folders of generated or build files if they are not existent.
5- Implemented time-stamp checks for files with custom extensions so the target won't be rebuild if they are up-to-date.
6- Fixes a couple of bugs in the build system.
--- End quote ---
Thanks for the contribution, but it would be nice not to have all in one go. This makes testing way easier and also the acceptance of (parts of) the patch.
Also: Bullet 1) sounds scary to me: Everything that is "automised" should be off by default and have an option to enable it explicitly. Changing project file weights "automagically" can seriously break the build system for people that use those weights already. What is the policy for these "Auto-XXX" features in your patch?
scarphin:
Well, I've already tried step-by-step and as you can see, your comment is the only worthy developer comment I got on this whole topic. I apologize if I missed anything. Please let me know if there is anything more I can do.
About bullet 1, sorry I wasn't clear on that. Let me explain it further. The auto-weight feature does NOT change the weight of any file (source, resource, custom extension or other...) already belongs to a project. It only effects the newly added files. For example, a '.ui' file in qt (similar to .xrc files in wxwidgets) must be compiled to a header file (ordinary '.h' file) to be included in other source files so before the project gets to get build, the '.ui' files must be compiled first all the time. Auto-weight automatizes this by setting a default weight to '.ui' files (say 40) in advanced compiler options and then every '.ui' file will have this weight (40) the moment they are added to the project helping the user to avoid setting each '.ui' files weight manually. To be more clear, assume the user has a '.ui' file in his/her project with a weight of say (70) for some reason, that file's weight will NOT be changed to (40) when a new custom extension for '.ui' is added in advanced compiler options. Again it is intended only for new files to be added to the project. Hope that clears the matter.
Thanks for your input.
Edit: On a second thought, I think it's better to rename auto-weight to default weight to avoid confusion. Done in the original post.
MortenMacFly:
Could you provide a demo project or even better a tiny tutorial what to do to make a proper (tiny) qt project utilising this features?
scarphin:
I attached a simple project which is an exact port of the qt example below to cb build system:
http://doc.qt.io/qt-4.8/qt-designer-calculatorform-example.html
Obviously a prebuilt qt4 library is needed to compile the project. To make things easier please create a 'qt4' entry in 'settings->global variables' with the following settings:
base: path_to_qt_library
include: $(#qt4)\include
lib: $(#qt4)\lib
bin: $(#qt4)\bin
Before trying the project please make sure the following entries in 'settings->compiler->other settings->advanced options->commands' are in place for the project's compiler:
1- Create a new extension named 'ui' with:
command line: $(#qt4.bin)\uic.exe $file -o $(project_dir)tmp\ui_$file_name.h
generated files: $(project_dir)tmp\ui_$file_name.h
weight: 30
2- Create a new extension named 'moc' with:
command line: $(#qt4.bin)\moc.exe $file -o $(project_dir)tmp\moc_$file_name.cpp
generated files: $(project_dir)tmp\moc_$file_name.cpp
weight: 40
Note: There is no need for a file with an 'moc' extension in qt. The 'moc' entry will be used to facilitate the configuration of files including a 'Q_OBJECT' macro and its purpose will be clear later.
I marked the new features with '(x)' in the demonstration below with their numbers in my post here:
http://forums.codeblocks.org/index.php/topic,20043.msg137653.html#msg137653
1- Load the project, there should be 3 files; 'main.cpp', 'calculatorform.cpp', 'calculatorform.h'
2- Add the file 'calculatorform.ui' in the project's folder to the project, when added it's weight should be '30' (1)
3- File 'calculatorform.h' contains a 'Q_OBJECT' macro so it must be compiled with qt's moc compiler. Make sure the project's compiler is selected during this step.
a- Select file properties by right-clicking on file 'calculatorform.h' in 'management->projects' and clicking 'properties'.
b- Go to 'advanced' tab.
c- Check 'use custom build'.
d- Check 'use settings from extension'. (3)
e- Select 'moc' from the drop-down box. (3) The 'custom build command' and 'generated files' (2) settings from the 'moc' entry in advanced compiler options will be set for the file. Hence the 'moc' entry in advanced compiler options.
f- Click 'ok'.
4- Now as everything is set, hit 'compile'. After the project is compiled, check the project's folder to find the auto-generated files 'ui_calculatorform.h' and 'moc_calculatorform.cpp' under the 'tmp' folder (4). Even if 'tmp' folder doesn't exist, it will be created during the build process (5).
5- Clicking 'build' again won't build the project again unless any of the source files (source or custom extension) is changed. (6)
Some notes:
1- Build files (generated files box in 'file properties->advanced' tab) may sometimes require the project to be reloaded if they are modified. That's because of the current implementation of file properties. In the current implementation, even if the user chooses to cancel the changes, they are saved to the original file the moment the compiler is switched when 'custom build command' is not empty. I believe a proper implementation would require a copy constructor for 'ProjectFile' class (or some copy function etc...) to make a temporary copy to work on. I'm not experienced enough with the contents of 'ProjectFile' to implement one, sorry.
2- There is a bug occuring sometimes giving the error 'moc_somefile.o not found'. Cleaning and reloading the project works but I wasn't able to reproduce it. So if anyone can reproduce, please post the steps and I'll try to investigate.
3- Please ignore my previous patches on this thread as they do not cover some of the bugs correctly.
4- As mentioned many times previously, none of these features are qt specific. They can also be used with other tools in general.
5- My tests are only on windows. Although much of the code is platform independent there are some parts that needs to be tested under other suported OSes.
Thanks.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version