[build2] C++ modules: how to generate the modules-list for own library

Wilhelm Meier wilhelm.meier at hs-kl.de
Mon May 8 15:19:02 UTC 2023


On 08.05.23 17:14, Wilhelm Meier via users wrote:
> Hi Boris,
> 
> On 08.05.23 15:31, Boris Kolpackov wrote:
>> Wilhelm Meier <wilhelm.meier at hs-kl.de> writes:
>>
>>> I want to convert a own header-only library to a version using modules.
>>> Because it is a header-only library (mostly templates) I'm using module
>>> interface unit as *.cpp files in some directory structure. Seldom I 
>>> split a
>>> module in module-partitions with more than one *.cpp file.
>>>
>>> If I want to use this modules, the build-tool needs a mapping between 
>>> module
>>> names an the corresponding *.cpp files of our library.
>>
>> Is this header-only library built with build2? If so, you (normally)
>> don't need an explicit mapping. For example, if your module interface
>> is in foo.cpp, then (normally) all you need is:
>>
>> lib{foo}: mxx{foo.cpp}
> 
> Well, our library contains a bunch of header files and I try to convert 
> the library as follows:
> 
> * I convert every .h file to .mpp (module interface unit) with the 
> neccesary module statements.
> * As every file comprises a part of the library, I export a 
> module:partition in every .mpp file
> * Clearly the partitions are dependent, so I have to import (export) 
> partitions of other .mpp files in some .mpp files
> 
> So, the .mpp files are interdependent.
> 
> Therefore I have one .mpp file that imports all the module:partitions in 
> the right order. The order is crucial.
> 
> To use this library one has to import the module, but to to that, he 
> hast to compile all the partitions of the module, which are in the ather 
> files. This ends, that the user has to build all the partitions before 
> in the right order.
> 
> Well, this looks broken to me.
> 
> Can build2 solve this?

I forgot to mention: there really is nothing to be built, no .o files 
are needed, because originally it is header-only. So, I only need the 
gcm-files in the right place.

Regards,
  Wilhelm



More information about the users mailing list