How is KF5 packaged on major systems?

Stephen Kelly steveire at gmail.com
Wed Apr 20 21:43:47 UTC 2016


Shaheed Haque wrote:

> [ resend now I am subscribed, apologies for any dupes ]
> 
> Hi all,
> 
> I am working on trying to revive PyKDE4 as PyKF5 and more [1]. The
> procedure is:
> 
> 1. create SIP file from the relevant KF5 .h file(s)
> 2. run the SIP compiler to produce the actual binding C++ code
> 3. compile the binding C++ code
> 4. link the result into a .so file against the relevant KF5 library .so
> 
> The whole point of what I am doing is to automate as much as possible
> of steps 1-4, and this question centres on step 4. How can I automate
> identifying the correct KF5 library .so file? For example, on my
> Ubuntu Wily system, I can start with the header files in
> "/usr/include/KF5/KItemModels/*.h" and then I need to link against
> "libKF5ItemModels.so".


The easiest way to do may be to generate the bindings when building the 
library itself. 

That is, we might patch kitemmodels like this:

  $ git diff                                                                                                                                                                                                  
  diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt                                                                                                                                                                                                                           
  index f8d76db..3a29e8d 100644                                                                                                                                                                                                                                                  
  --- a/src/CMakeLists.txt                                                                                                                                                                                                                                                       
  +++ b/src/CMakeLists.txt                                                                                                                                                                                                                                                       
  @@ -25,6 +25,29 @@ set_target_properties(KF5ItemModels PROPERTIES VERSION   
${KITEMMODELS_VERSION_S                                                                                                                                                                            
                                                  EXPORT_NAME ItemModels                                                                                                                                                                                                         
  )                                                                                                                                                                                                                                                                             
                                                                                                                                                                                                                                                                
  +# Generate a sip file for each header                                                                                                                                                                                                                                         
  +generate_sip_files(                                                                                                                                                                                                                                                           
  +  RESULT generated_sip_files                                                                                                                                                                                                                                                  
  +  OUTPUT_DIR sip                                                                                                                                                                                                                                                              
  +  RULES KItemModelsRules.py # For libraries which need a rules file                                                                                                                                                                                                           
  +  HEADERS                                                                                                                                                                                                                                                                     
  +    kbreadcrumbselectionmodel.h                                                                                                                                                                                                                                               
  +    kcheckableproxymodel.h                                                                                                                                                                                                                                                    
  +    kdescendantsproxymodel.h                                                                                                                                                                                                                                                  
  +    klinkitemselectionmodel.h                                                                                                                                                                                                                                                 
  +    kmodelindexproxymapper.h                                                                                                                                                                                                                                                  
  +    krecursivefilterproxymodel.h                                                                                                                                                                                                                                              
  +    kselectionproxymodel.h                                                                                                                                                                                                                                                    
  +)                                                                                                                                                                                                                                                                             
  +                                                                                                                                                                                                                                                                              
  +generate_sip_module(                                                                                                                                                                                                                                                          
  +  # Generate a rule to link the sip result to KF5ItemModels
  +  TARGET KF5ItemModels  
  +  OUTPUT_DIR sip                                                                                                                                                                                                                                                              
  +  SIP_FILES generated_sip_files
  +  NAME kitemmodelsmod.sip
  +  DEPENDENCIES Qt5::Core
  +  # List other dependencies and cmake can generate an import for them.
  +)
  +
  ecm_generate_headers(KItemModels_HEADERS
    HEADER_NAMES
    KBreadcrumbSelectionModel



and similar for other modules.

Presumably then, the build of the libraries should install the mod.sip files 
to some location in share/ so that dependencies can use them. 

> So, what I need is a reliable way to map from the name of the module,
> "KItemModels" to the corresponding library in a distro (and platform?)
> independent manner. I have to do this for circa 120 different modules
> just for PyKF5. The worst case solution from my thinking would be for
> me to hard code the mapping in a way that has to be redone for each
> distro/platform.

This seem to me a good reason to modularize the bindings generation as I 
described above.

Thanks,

Steve.


More information about the Kde-buildsystem mailing list