3
« Last post by JorgenBest on Yesterday at 06:51:01 pm »
I like to test the new module possibility and like it so far (just shortly started). I made a project template for using it with gcc or Clang (Arch Linux).
What I can do with modules:
1. use the std module with all library features for GCC or CLang
2. create my own modules
Downside is: when I add new modules I have to set the priority weight for compiling lower (e.g. to 10) for gcc. For Clang I need also to create a custom command to build and copy that in (copy the same code for every file).
See the attached main.cpp with a HelloWorld example. All other files can be constructed from this as well as the configuration in Codeblocks. I hope this helps, any one how likes to try modules.
I see two potential possibilities for what I provided: Others use these instructions to be able to work with modules from the Codeblocks IDE, even if it's not perfect.
Or secondly (what I would really like) an addition would be made to Codeblocks. Something (minimal?) like:
1. Add an build option: use C++modules (c++20 and higher should be selected) what adds the necessary compile options
2. Add an build option: use std module (this could add a std project file or create a compiled module in the project). Note the std module is not precompiled in gcc or clang, so the project has to do that, see my attachment.
3. Add the most used suffixes for modules and make those files compile in two steps: first create all the Compiled Module Interface (CMI) thus a gcm or pcm file. This has to be done before all other compilation and then create the object files.
4. Delete the CMI's when rebuilding / cleaning.
I think most of the needed functionality is already available in codeblocks for a solution to build modules. That's why I can make it work manually without too much trouble.
Note:
I doubt if giving 2 commands for clang in this custom build command is intended/allowed, but it works on my platform until now. The sequence of more than one commands seems to have different results than executing them from the command line (parallel execution?). For gcc I do both the CMI and object are made in one step (with standard compilation) and I only have to set the build priority so that's OK anyway.
If anything is not completely right I like to hear it, if it's not too much trouble. I didn't find complete documentation for custom build commands.
Note 2:
My solution builds the CMI's and object files of modules at the same time (but prior to other object files/main.o), so not according to point 3 of my proposal. This can lead to problems if modules have inter dependencies. Then the build weight should be used to build those modules in the right order.
Circular dependencies (that should be possible with modules as I understand) can't be build like that however. That's not really different from using headers I think. I don't know if I would use circular dependencies anyway. There's no easy way to couple 2 building commands to one C++ file in codeblocks and have them execute with different build weights. If I have to do that I need to trick codeblocks with empty files and custom build commands, what is not worth the trouble I think.
That's where an internal codeblock solution would be handy: if an extra building stage for CMI's was introduced prior to building object files the whole dependency handling would be very simple: just build the CMI's first.
I have no clue of the codeblocks source code, but I will be happy to help with what I can do regarding to modules.