QMAKE_EXTRA_COMPILERS: single command for multiple targets



  • Hi. I'm trying to integrate Shiboken generator into make process. For example there is simple description for my extra compiler in .pro file:
    @GENERATED_SOURCES = wrappers/class1_wrapper.cpp
    wrappers/class2_wrapper.cpp

    SHIBOKEN_FILE = . # Need to give some bogus input
    SHIBOKEN.input = SHIBOKEN_FILE
    SHIBOKEN.output = $$GENERATED_SOURCES
    SHIBOKEN.commands = shiboken <bla-bla-bla>
    SHIBOKEN.variable_out = SOURCES

    QMAKE_EXTRA_COMPILERS += SHIBOKEN@

    QMake generates the following Makefile's fragment:
    @wrappers/class1_wrapper.cpp: .
    shiboken <bla-bla-bla>@

    But there is no rule for class2_wrappers.cpp! It took only the first item of GENERATED_SOURCES list.
    It works fine when compilation process has 1 job. But if I run it with several jobs (e.g. make -j4), it will fail with
    @
    make: *** No rule to make target wrappers/class2_wrapper.cpp', needed bydebug/.obj/wrappers/class2_wrapper.o'. Stop.
    make: *** Waiting for unfinished jobs....
    @

    It happens because a free job tries to compile class2_wrappers.cpp before shiboken has finished. So if I try to run make -j4 again, it will compile successfully. Of course, files listed in GENERATED_SOURCES do not exist before shiboken invocation.
    Is there any feature to specify one command for multiple targets? I mean, it should work like moc but moc is called once for each target, and I want to run the command once for several targets. I found only "combine" feature:
    @SHIBOKEN.CONFIG += combine@

    but it's opposite to what I need.



  • I solved it via Makefile target pattern. Also, there is a trick with the SOURCES variable. QMake doesn't like when some source files don't exist :-)
    I've put an empty %_wrapper.cpp next to Makefile as qmake includes it into SOURCES.
    Here is simple code:

    @
    GENERATED_SOURCES = wrappers/class1_wrapper.cpp
    wrappers/class2_wrapper.cpp

    defineReplace(shibokenWorkaround) {
    SOURCES += $$GENERATED_SOURCES
    return("%_wrapper.cpp")
    }

    SHIBOKEN_FILE = . # Need to give some bogus input
    SHIBOKEN.input = SHIBOKEN_FILE
    SHIBOKEN.output_function = shibokenWorkaround
    SHIBOKEN.commands = shiboken <bla-bla-bla>
    SHIBOKEN.CONFIG = no_link # don't add the .cpp target file to OBJECTS
    SHIBOKEN.clean = dummy # don't remove the %_wrapper.cpp file by "make clean"

    QMAKE_EXTRA_COMPILERS += SHIBOKEN
    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.