Shiboken - Building bindings with headers in subfolders



  • Greetings!

    I'm currently building bindings to a Qt-based library, but I'm running into a problem when it comes to headers being placed in subfolders (but still sharing a single namespace). An example:

    The library I'm wrapping contains a number of header files, many of those being placed in subfolders. Take the following wrappedclasses.h, which is used to feed header files to the Shiboken2 generator:

    #ifndef WRAPPEDCLASSES_H
    #define WRAPPEDCLASSES_H
    
    #include <../model/file.h>
    #include <../model/disk.h>
    #include <../model/filesystem.h>
    
    #endif // WRAPPEDCLASSES_H
    

    As you can see, all headers are in the model directory, which is the base directory for the library (and added to the INCLUDEPATH of my binding's qmake file). Building a binding using these classes works without problems.

    However, when I add a header file from a subfolder, things get messy. Let's add the point.h file from the common subfolder:

    #ifndef WRAPPEDCLASSES_H
    #define WRAPPEDCLASSES_H
    
    #include <../model/file.h>
    #include <../model/disk.h>
    #include <../model/filesystem.h>
    #include <../model/common/point.h>
    
    #endif // WRAPPEDCLASSES_H
    

    Now, when I try to build my binding library, the compilation process is aborted because the compiler cannot find point.h. As it turns out, the wrapper files created by Shiboken2 reference the header file simply as point.h instead of common/point.h, which results in the file not being found:

    // bje_model_point_wrapper.h, generated by shiboken
    #ifndef SBK_BJE_MODEL_POINT_H
    #define SBK_BJE_MODEL_POINT_H
    
    #define protected public
    
    #include <point.h> // <-- this should be common/point.h
    
    #endif // SBK_BJE_MODEL_POINT_H
    

    The project builds when I modify the include paths in the generated files to include the subfolder (as in, replace point.h with common/point.h), but this is not an option due to the number of files being involved.

    Is this a known problem with an already existing solution?


  • Moderators

    This looks like something shiboken people should look into, not Qt.



  • Thanks, I'll be trying to contact the devs directly using IRC or whatever else they offer.
    (Do they not use the official Qt forums, even though it's a Qt project and there's a dedicated section for PySide2 here?)



  • Just a couple of things if someone end up here:

    PS: Shiboken people is Qt people, the thing is that most of the people in the forums is not really experience with shiboken nor pyside, that's why IRC is better ;)


  • Moderators

    @sierdzio said in Shiboken - Building bindings with headers in subfolders:

    This looks like something shiboken people should look into, not Qt.

    To expand on @CristianMaureira's comment that "Shiboken people is Qt people": https://blog.qt.io/blog/2018/05/24/qt-for-python-under-the-hood/


  • Moderators

    Cool, I had no idea, thanks for info.



  • I've contacted the devs using their Gitter and they've been quite helpful. In fact, there's a patch now fixing this problem. Thanks for the help!


  • Lifetime Qt Champion

    Hi,

    Thanks for the feedback ! Can you post the link to said patch ?


Log in to reply