Skip to content

Commit c5f373d

Browse files
committed
Make the behavior of the build system more obvious
1 parent a268782 commit c5f373d

File tree

5 files changed

+63
-87
lines changed

5 files changed

+63
-87
lines changed

.github/workflows/build.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
uname -a; gcc --version | grep "gcc"; python3 --version; qmake --version
6464
echo ============================
6565
qmake -r PythonQt.pro CONFIG+=ccache CONFIG+=release CONFIG+=force_debug_info \
66-
CONFIG+=sanitizer CONFIG+=sanitize_undefined CONFIG+=sanitize_address \
66+
CONFIG+=sanitizer CONFIG+=sanitize_undefined CONFIG+=sanitize_address CONFIG+=tests CONFIG+=generator \
6767
PYTHON_VERSION=$(python3 --version | cut -d " " -f 2 | cut -d "." -f1,2) \
6868
PYTHON_DIR=$(which python3 | xargs dirname | xargs dirname)
6969
make -j $(nproc)
@@ -138,7 +138,7 @@ jobs:
138138
export PYTHON_DIR=`which python${PYTHON_VERSION_SUFFIX} | xargs dirname | xargs dirname`
139139
echo PYTHON_VERSION_SHORT=${PYTHON_VERSION_SHORT}
140140
echo PYTHON_DIR=${PYTHON_DIR}
141-
qmake-qt5 -r PythonQt.pro CONFIG+=${{ matrix.configuration }} \
141+
qmake-qt5 -r PythonQt.pro CONFIG+=${{ matrix.configuration }} CONFIG+=tests CONFIG+=generator \
142142
"PYTHON_VERSION=${PYTHON_VERSION_SHORT}" "PYTHON_DIR=${PYTHON_DIR}"
143143
make -j $(nproc) && \
144144
PYTHONDEVMODE=1 PYTHONASYNCIODEBUG=1 PYTHONWARNINGS=error PYTHONMALLOC=malloc_debug \
@@ -225,7 +225,7 @@ jobs:
225225
"python${PYTHON_VERSION_MAJOR}-embed" "python${PYTHON_VERSION_MAJOR}"
226226
do if pkg-config --exists "$i"; then PYTHON_PKGCONFIG_NAME="$i"; break; fi; done
227227
qmake CONFIG+=ccache CONFIG+=${{ matrix.configuration }} CONFIG+=sanitizer CONFIG+=sanitize_undefined CONFIG+=sanitize_address \
228-
PYTHON_VERSION=${{ steps.versions.outputs.PYTHON_VERSION_SHORT }} \
228+
CONFIG+=tests CONFIG+=generator PYTHON_VERSION=${{ steps.versions.outputs.PYTHON_VERSION_SHORT }} \
229229
PYTHON_DIR="$pythonLocation" \
230230
PKGCONFIG+=$PYTHON_PKGCONFIG_NAME \
231231
-r PythonQt.pro
@@ -335,7 +335,8 @@ jobs:
335335
qmake -query
336336
python --version
337337
set PYTHONQTALL_CONFIG=${{ matrix.pythonqtall-config }}
338-
qmake CONFIG+=release CONFIG-=debug_and_release CONFIG-=debug_and_release_target ^
338+
qmake CONFIG+=release CONFIG-=debug_and_release CONFIG+=tests CONFIG+=generator ^
339+
CONFIG-=debug_and_release_target ^
339340
"PYTHON_PATH=%pythonLocation%" ^
340341
"PYTHON_VERSION=${{ steps.versions.outputs.PYTHON_VERSION_SHORT }}" ^
341342
PythonQt.pro

.github/workflows/build_latest.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ jobs:
103103
uname -a; gcc --version | grep "gcc"; python3 --version; qmake --version
104104
echo ============================
105105
qmake -r PythonQt.pro CONFIG+=ccache CONFIG+=release CONFIG+=force_debug_info \
106-
CONFIG+=sanitizer CONFIG+=sanitize_undefined CONFIG+=sanitize_address \
106+
CONFIG+=sanitizer CONFIG+=sanitize_undefined CONFIG+=tests CONFIG+=sanitize_address \
107107
PYTHON_VERSION=$(python3 --version | cut -d " " -f 2 | cut -d "." -f1,2) \
108108
PYTHON_DIR=$(which python3 | xargs dirname | xargs dirname)
109109
make -j $(nproc)
@@ -117,7 +117,7 @@ jobs:
117117
run: |
118118
qmake -query
119119
python --version
120-
qmake CONFIG+=release CONFIG-=debug_and_release CONFIG-=debug_and_release_target ^
120+
qmake CONFIG+=release CONFIG-=debug_and_release CONFIG-=debug_and_release_target CONFIG+=tests ^
121121
"PYTHONQTALL_CONFIG=${{ matrix.pythonqtall-config }}" ^
122122
"PYTHON_PATH=%pythonLocation%" ^
123123
"PYTHON_VERSION=${{ steps.setenv.outputs.PYTHON_VERSION_SHORT }}" ^

PythonQt.pro

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
TEMPLATE = subdirs
22

3-
SUBDIRS = generator src extensions tests examples
4-
tests.depends += src extensions
3+
SUBDIRS = src extensions
54
extensions.depends += src
6-
examples.depends += src extensions
5+
6+
CONFIG(tests) {
7+
SUBDIRS += tests
8+
tests.depends += extensions
9+
}
10+
11+
CONFIG(generator) {
12+
SUBDIRS += generator
13+
}
14+
15+
CONFIG(examples) {
16+
SUBDIRS += examples
17+
examples.depends += extensions
18+
}

build/python.prf

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
isEmpty( PYTHON_VERSION ) {
66
PYTHON_VERSION=$$(PYTHON_VERSION)
77
}
8-
isEmpty( PYTHON_VERSION ) {
9-
PYTHON_VERSION=3.10
10-
}
118

129
isEmpty( PYTHON_DIR ) {
1310
PYTHON_DIR=$$(PYTHON_DIR)
@@ -16,6 +13,11 @@ isEmpty( PYTHON_DIR ) {
1613
PYTHON_DIR=$${PYTHON_DIR}/
1714
}
1815

16+
isEmpty( PYTHON_VERSION ) {
17+
error(Missing PYTHON_VERSION)
18+
}
19+
20+
1921
PYTHON_VERSION_MAJOR=$$section(PYTHON_VERSION, ., 0, 0)
2022
PYTHON_VERSION_MINOR=$$section(PYTHON_VERSION, ., 1, 1)
2123

@@ -42,7 +44,17 @@ contains(PKGCONFIG, "python.*"){
4244
# This can help with GNU/Linux (including macOS with Homebrew), MSYS2/MinGW environment,
4345
# and also with OpenEmbedded and other cross-builds
4446
CONFIG += link_pkgconfig
45-
PYTHON_PKGCONFIG = $$member($$unique($$find(PKGCONFIG, "python.*")), 1, 1)
47+
PYTHON_PKGCONFIG = $$unique(PKGCONFIG)
48+
PYTHON_PKGCONFIG = $$find(PYTHON_PKGCONFIG, "python.*")
49+
PYTHON_PKGCONFIG = $$member(PYTHON_PKGCONFIG)
50+
!system($$pkgConfigExecutable() --modversion $$PYTHON_PKGCONFIG) {
51+
message(PKGCONFIG is $$PKGCONFIG)
52+
error(Bad or missing Python development package $$PYTHON_PKGCONFIG passed via PKGCONFIG argument)
53+
}
54+
PYTHON_VERSION_BY_PKGCONFIG = $$system($$pkgConfigExecutable() --modversion $$PYTHON_PKGCONFIG)
55+
!equals(PYTHON_VERSION, $$PYTHON_VERSION_BY_PKGCONFIG):error(PYTHON_VERSION $$PYTHON_VERSION \
56+
must be equal to the corresponding one from PKGCONFIG $$PYTHON_VERSION_BY_PKGCONFIG)
57+
4658
# add rpath
4759
PYTHON_LIBDIR = $$system($$pkgConfigExecutable() --libs-only-L $$PYTHON_PKGCONFIG)
4860
QMAKE_RPATHDIR += $$replace(PYTHON_LIBDIR,-L,)

extensions/PythonQt_QtAll/PythonQt_QtAll.pro

Lines changed: 25 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -77,94 +77,45 @@ headers.path = $${INSTALL_PREFIX}/include
7777
INSTALLS += target headers
7878

7979
defineTest(Xinclude) {
80-
f=$$PYTHONQT_GENERATED_PATH/$$1/$${1}.pri
81-
exists($$f):include($$f):export(HEADERS):export(SOURCES):export(DEFINES)
82-
80+
exists($$f) {
81+
DEFINES += $$2 # shoud be in the included (generated) .pri file
82+
QT += $$3 # shoud be in the included (generated) .pri file
83+
include($$f)
84+
export(HEADERS)
85+
export(SOURCES)
86+
export(DEFINES)
87+
export(QT)
88+
return(true)
89+
}
90+
return(false)
8391
}
8492

93+
PythonQtCore:Xinclude(com_trolltech_qt_core, PYTHONQT_WITH_CORE, core)
8594

86-
PythonQtCore {
87-
DEFINES += PYTHONQT_WITH_CORE
88-
Xinclude (com_trolltech_qt_core)
89-
QT += core
90-
}
91-
92-
PythonQtGui {
93-
DEFINES += PYTHONQT_WITH_GUI
94-
Xinclude (com_trolltech_qt_gui)
95-
QT += gui widgets printsupport
96-
}
95+
PythonQtGui:Xinclude(com_trolltech_qt_gui, PYTHONQT_WITH_GUI, gui widgets printsupport)
9796

98-
PythonQtSvg {
99-
DEFINES += PYTHONQT_WITH_SVG
100-
Xinclude (com_trolltech_qt_svg)
101-
QT += svg
97+
PythonQtSvg:Xinclude(com_trolltech_qt_svg, PYTHONQT_WITH_SVG, svg) {
10298
!lessThan(QT_MAJOR_VERSION,6): QT += svgwidgets
10399
}
104100

105-
PythonQtSql {
106-
DEFINES += PYTHONQT_WITH_SQL
107-
Xinclude (com_trolltech_qt_sql)
108-
QT += sql
109-
}
101+
PythonQtSql:Xinclude(com_trolltech_qt_sql, PYTHONQT_WITH_SQL, sql)
110102

111-
PythonQtNetwork {
112-
DEFINES += PYTHONQT_WITH_NETWORK
113-
Xinclude (com_trolltech_qt_network)
114-
QT += network
115-
}
103+
PythonQtNetwork:Xinclude(com_trolltech_qt_network, PYTHONQT_WITH_NETWORK, network)
116104

117-
PythonQtOpengl {
118-
DEFINES += PYTHONQT_WITH_OPENGL
119-
QT += opengl
120-
PythonQtCore: Xinclude (com_trolltech_qt_opengl)
121-
QT += xml
122-
}
105+
PythonQtOpengl:Xinclude(com_trolltech_qt_opengl, PYTHONQT_WITH_OPENGL, opengl xml)
123106

124-
PythonQtXml {
125-
DEFINES += PYTHONQT_WITH_XML
126-
Xinclude (com_trolltech_qt_xml)
127-
QT += xml
128-
}
107+
PythonQtXml:Xinclude(com_trolltech_qt_xml, PYTHONQT_WITH_XML, xml)
129108

130-
PythonQtXmlpatterns {
131-
DEFINES += PYTHONQT_WITH_XMLPATTERNS
132-
Xinclude (com_trolltech_qt_xmlpatterns)
133-
QT += xmlpatterns
134-
}
109+
PythonQtXmlpatterns:Xinclude(com_trolltech_qt_xmlpatterns, PYTHONQT_WITH_XMLPATTERNS, xmlpatterns)
135110

136-
PythonQtMultimedia {
137-
DEFINES += PYTHONQT_WITH_MULTIMEDIA
138-
Xinclude (com_trolltech_qt_multimedia)
139-
QT += multimedia multimediawidgets
140-
}
111+
PythonQtMultimedia:Xinclude(com_trolltech_qt_multimedia, PYTHONQT_WITH_MULTIMEDIA, multimedia multimediawidgets)
141112

142-
PythonQtQml {
143-
DEFINES += PYTHONQT_WITH_QML
144-
Xinclude (com_trolltech_qt_qml)
145-
QT += qml
146-
}
113+
PythonQtQml:Xinclude(com_trolltech_qt_qml, PYTHONQT_WITH_QML, qml)
147114

148-
PythonQtQuick {
149-
DEFINES += PYTHONQT_WITH_QUICK
150-
Xinclude (com_trolltech_qt_quick)
151-
QT += quick quickwidgets
152-
}
115+
PythonQtQuick:Xinclude(com_trolltech_qt_quick, PYTHONQT_WITH_QUICK, quick quickwidgets)
153116

154-
PythonQtUiTools {
155-
DEFINES += PYTHONQT_WITH_UITOOLS
156-
Xinclude (com_trolltech_qt_uitools)
157-
QT += uitools
158-
}
117+
PythonQtUiTools:Xinclude(com_trolltech_qt_uitools, PYTHONQT_WITH_UITOOLS, uitools)
159118

160-
PythonQtWebEngineWidgets {
161-
DEFINES += PYTHONQT_WITH_WEBENGINEWIDGETS
162-
Xinclude (com_trolltech_qt_webenginewidgets)
163-
QT += webenginewidgets
164-
}
119+
PythonQtWebEngineWidgets:Xinclude(com_trolltech_qt_webenginewidgets, PYTHONQT_WITH_WEBENGINEWIDGETS, webenginewidgets)
165120

166-
PythonQtWebKit {
167-
DEFINES += PYTHONQT_WITH_WEBKIT
168-
Xinclude (com_trolltech_qt_webkit)
169-
QT += webkit webkitwidgets
170-
}
121+
PythonQtWebKit:Xinclude(com_trolltech_qt_webkit, PYTHONQT_WITH_WEBKIT, webkit webkitwidgets)

0 commit comments

Comments
 (0)