0

I'm trying to integrate PyQt5 binding creation into my qmake build process, I have my SIP file ready and I've setup a compiler for it:

SIP_FILES += global/sip/Sy_version.sip

sipSourceBuilder.input = SIP_FILES
sipSourceBuilder.output_function = sipSourceHandler
sipSourceBuilder.variable_out = SOURCES
sipSourceBuilder.dependency_type = TYPE_C
sipSourceBuilder.CONFIG += target_predeps
sipSourceBuilder.commands = $$PYTHON $${PWD}/sipConfigure.py \
                                       $$QT_SIP_PATH \
                                       $${_PRO_FILE_PWD_} \
                                       $${_PRO_FILE_PWD_}/${QMAKE_FILE_IN}

QMAKE_CLEAN += $${_PRO_FILE_PWD_}/sipOutput/sip${QMAKE_TARGET}cmodule.cpp
SOURCES += $${_PRO_FILE_PWD_}/sipOutput/sip${QMAKE_TARGET}cmodule.cpp

QMAKE_EXTRA_COMPILERS += sipSourceBuilder

The defineReplace function sipSourceHandler is working correctly. When I start a build the sipConfigure.py script is not ran and an error occurs:

make: * No rule to make target ../../Syren2/core/sipOutput/sipcoreSy_version.cpp', needed by /home/cmannett85/Programs/Syren2/libs/libcore.so.1.0.0'. Stop.

Which makes sense if the script wasn't ran - but why wasn't it ran? The Makefile shows the rule is there:

/home/cmannett85/workspace/Syren2/source/Syren2/core/sipOutput/sip${QMAKE_TARGET}Sy_version.cpp: ../../Syren2/core/global/Sy_version.h \
        /home/cmannett85/Qt/5.3/gcc_64/include/QtCore/QtGlobal \
        // ...Lots of includes....
        ../../Syren2/core/global/sip/Sy_version.sip
    python3 /home/cmannett85/workspace/Syren2/source/Syren2/sipConfigure.py /usr/share/sip/PyQt5 /home/cmannett85/workspace/Syren2/source/Syren2/core /home/cmannett85/workspace/Syren2/source/Syren2/core/../../Syren2/core/global/sip/Sy_version.sip

(Sorry for the giant side scroll). ${QMAKE_TARGET} is core and it is declared as a variable in the Makefile. I tried setting the sipSourceBuilder.commands to some randomly bashed in characters and nothing complained during the build, so it seems that make isn't even attempting to use sipSourceBuilder. Any suggestions as to why?

Also I know that the SIP compiler also generates a header file that qmake should be made aware of, but I've commented that code out whilst I try to get this step going.

cmannett85
  • 21,725
  • 8
  • 76
  • 119

1 Answers1

0

The issue was occurring due to make using string matching to link dependencies to targets, rather than detecting if a target/dependency is a path and doing any relevant conversion. In my case, it was because the library dependency for my generated source file was listed as a relative path (../../Syren2/core/sipOutput/sipcoreSy_version.cpp), but the associated target was listed as an absolute path (/home/cmannett85/workspace/Syren2/source/Syren2/core/sipOutput/sip${QMAKE_TARGET}Sy_version.cpp).

The solution was to modify the sipSourceHandler output file name generator to return relative paths from the Makefile's location:

// SIP_SOURCE_ABS was previously returned, now SIP_SOURCE is.
SIP_SOURCE_ABS = $${_PRO_FILE_PWD_}/sipOutput/sip${QMAKE_TARGET}$${NO_PREFIX}.cpp
SIP_SOURCE = $$relative_path( $$SIP_SOURCE_ABS, $${OUT_PWD} )
cmannett85
  • 21,725
  • 8
  • 76
  • 119