aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2/tests
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2018-10-18 19:40:49 +0200
committerCristian Maureira-Fredes <cristian.maureira-fredes@qt.io>2019-02-07 08:26:31 +0000
commit97df448edbc035a2f531508a5cfe5739fb2de18d (patch)
tree732de8143e1dcb6a5b25e25eb8ec2954bf8ac87f /sources/pyside2/tests
parent9a371088d6b8e8a0986a30a8dfb0076669275103 (diff)
Modernize cmake build
Add a CMake super project that includes the shiboken2, PySide2 and pyside2-tools subprojects, so that it's possible to build everything from Qt Creator (or any other IDE that supports CMake) with minimal set up effort, and thus inform the IDE CMake integration of all relevant files, for easier code editing, navigation and refactoring. This also lays the foundation for allowing 3rd parties to use the shiboken2 generator to generate custom modules. This is achieved by eliminating various hardcoded paths for libraries and include directories. Start using CMake targets throughout the build code to correctly propagate link flags and include dirs for libshiboken and shiboken2 executable targets. Same for the libpyside target. Generate two separate cmake config files (build-tree / install-tree) that can be used with find_package(Shiboken2), to make sure that the PySide2 project can be built as part of the super project build. This is currently the only way I've found to allow the super build to work. Note that for the build-tree find_package() to work, the CMAKE_MODULE_PATH has to be adjusted in the super project file. The generated config files contain variables and logic that allow usage of the installed shiboken package in downstream projects (PySide2). This involves things like getting the includes and libraries for the currently found python interpreter, the shiboken build type (release or debug), was shiboken built with limited api support, etc. Generate 2 separate (build-tree and install-tree) config files for PySide2, similar to how it's done for the shiboken case, for pyside2-tools to build correctly. Install shiboken2 target files using install(EXPORT) to allow building PySide2 with an installed Shiboken2 package (as opposed to one that is built as part of the super project). Same with PySide2 targets for pyside2-tools subproject. Make sure not to redefine uninstall targets if they are already defined. Add a --shorter-paths setup.py option, which would be used by the Windows CI, to circumvent creating paths that are too long, and thus avoiding build issues. Output the build characteristics / classifiers into the generated build_history/YYYY-MM-DD_AAAAAA/build_dir.txt file, so it can be used by the test runner to properly filter out blacklisted tests. This was necessary due to the shorter paths options. Fix various issues regarding target includes and library dependencies. Remove certain duplicated cmake code (like limited api check and build type checks) in PySide2, given that that information will now be present in the exported shiboken2 config file. Include a short README.cmake.md file that describes how to build the super project. References used https://rix0r.nl/blog/2015/08/13/cmake-guide/ https://pabloariasal.github.io/2018/02/19/its-time-to-do-cmake-right/ https://gist.github.com/mbinna/c61dbb39bca0e4fb7d1f73b0d66a4fd1 https://cliutils.gitlab.io/modern-cmake/chapters/basics/functions.html https://cmake.org/cmake/help/v3.0/manual/cmake-packages.7.html https://github.com/ComicSansMS/libstratcom/blob/master/CMakeLists.txt Abandoned approach using ExternalProject references: https://cmake.org/cmake/help/latest/module/ExternalProject.html https://stackoverflow.com/questions/44990964/how-to-perform-cmakefind-package-at-build-stage-only Fixes: PYSIDE-919 Change-Id: Iaa15d20b279a04c5e16ce2795d03f912bc44a389 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/pyside2/tests')
-rw-r--r--sources/pyside2/tests/CMakeLists.txt4
-rw-r--r--sources/pyside2/tests/pysidetest/CMakeLists.txt16
-rw-r--r--sources/pyside2/tests/registry/init_platform.py8
3 files changed, 16 insertions, 12 deletions
diff --git a/sources/pyside2/tests/CMakeLists.txt b/sources/pyside2/tests/CMakeLists.txt
index 4289012a8..08585252c 100644
--- a/sources/pyside2/tests/CMakeLists.txt
+++ b/sources/pyside2/tests/CMakeLists.txt
@@ -8,8 +8,8 @@ else()
# tests/QtWidgets/qstandarditemmodel_test.py needs shiboken2
# tests/QtWidgets/qlabel_test.py needs shiboken2
if(WIN32)
- set(TEST_PYTHONPATH "${CMAKE_BINARY_DIR};${CMAKE_SOURCE_DIR}/tests/util;${CMAKE_BINARY_DIR}/tests/pysidetest;${CMAKE_BINARY_DIR}/../shiboken2/shibokenmodule;$ENV{PYTHONPATH}")
- set(TEST_LIBRARY_PATH "${libpyside_BINARY_DIR};${pysidetest_BINARY_DIR};${SHIBOKEN_INCLUDE_DIR}/../../bin;$ENV{PATH}")
+ set(TEST_PYTHONPATH "${CMAKE_BINARY_DIR};${CMAKE_SOURCE_DIR}/tests/util;${CMAKE_BINARY_DIR}/tests/pysidetest;${SHIBOKEN_PYTHON_MODULE_DIR};$ENV{PYTHONPATH}")
+ set(TEST_LIBRARY_PATH "${libpyside_BINARY_DIR};${pysidetest_BINARY_DIR};${SHIBOKEN_SHARED_LIBRARY_DIR};$ENV{PATH}")
set(LIBRARY_PATH_VAR "PATH")
string(REPLACE "\\" "/" TEST_PYTHONPATH "${TEST_PYTHONPATH}")
string(REPLACE "\\" "/" TEST_LIBRARY_PATH "${TEST_LIBRARY_PATH}")
diff --git a/sources/pyside2/tests/pysidetest/CMakeLists.txt b/sources/pyside2/tests/pysidetest/CMakeLists.txt
index 119553fad..1b1baf39a 100644
--- a/sources/pyside2/tests/pysidetest/CMakeLists.txt
+++ b/sources/pyside2/tests/pysidetest/CMakeLists.txt
@@ -68,8 +68,8 @@ make_path(testbinding_typesystem_path ${pyside2_SOURCE_DIR}
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/mjb_rejected_classes.log"
-BYPRODUCTS ${testbinding_SRC}
-COMMAND ${SHIBOKEN_BINARY} ${GENERATOR_EXTRA_FLAGS}
+ BYPRODUCTS ${testbinding_SRC}
+ COMMAND Shiboken2::shiboken2 ${GENERATOR_EXTRA_FLAGS}
${CMAKE_CURRENT_SOURCE_DIR}/pysidetest_global.h
--include-paths=${testbinding_include_dirs}
${shiboken_framework_include_dirs_option}
@@ -86,16 +86,15 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}
${Qt5Core_INCLUDE_DIRS}
${Qt5Gui_INCLUDE_DIRS}
${Qt5Widgets_INCLUDE_DIRS}
- ${SHIBOKEN_INCLUDE_DIR}
${pyside2_SOURCE_DIR}
${QtCore_GEN_DIR}
${QtGui_GEN_DIR}
${QtWidgets_GEN_DIR}
- ${libpyside_SOURCE_DIR}
- ${SHIBOKEN_PYTHON_INCLUDE_DIR})
+ ${libpyside_SOURCE_DIR})
add_library(pysidetest SHARED ${pysidetest_SRC} ${pysidetest_MOC_SRC})
target_link_libraries(pysidetest
+ Shiboken2::libshiboken
${Qt5Core_LIBRARIES}
${Qt5Gui_LIBRARIES}
${Qt5Widgets_LIBRARIES}
@@ -103,7 +102,7 @@ target_link_libraries(pysidetest
add_library(testbinding MODULE ${testbinding_SRC})
set_property(TARGET testbinding PROPERTY PREFIX "")
-set_property(TARGET testbinding PROPERTY OUTPUT_NAME "testbinding${PYTHON_EXTENSION_SUFFIX}")
+set_property(TARGET testbinding PROPERTY OUTPUT_NAME "testbinding${SHIBOKEN_PYTHON_EXTENSION_SUFFIX}")
if(WIN32)
set_property(TARGET testbinding PROPERTY SUFFIX ".pyd")
endif()
@@ -111,11 +110,10 @@ target_link_libraries(testbinding
pysidetest
pyside2
${PYTHON_LIBRARIES}
- ${SHIBOKEN_LIBRARY}
+ Shiboken2::libshiboken
${Qt5Core_LIBRARIES}
${Qt5Gui_LIBRARIES}
- ${Qt5Widgets_LIBRARIES}
- ${SBK_PYTHON_LIBRARIES})
+ ${Qt5Widgets_LIBRARIES})
add_dependencies(testbinding pyside2 QtCore QtGui QtWidgets pysidetest)
create_generator_target(testbinding)
diff --git a/sources/pyside2/tests/registry/init_platform.py b/sources/pyside2/tests/registry/init_platform.py
index ca2b2cb68..a324c36a2 100644
--- a/sources/pyside2/tests/registry/init_platform.py
+++ b/sources/pyside2/tests/registry/init_platform.py
@@ -73,7 +73,13 @@ elif os.path.exists(history_dir):
fpath = os.path.join(history_dir, last_build, "build_dir.txt")
if os.path.exists(fpath):
with open(fpath) as f:
- all_build_dir = f.read().strip()
+ f_contents = f.read().strip()
+ f_contents_split = f_contents.splitlines()
+ try:
+ all_build_dir = f_contents_split[0]
+ except IndexError:
+ print("Error: can't find the build dir in the given file '{}'".format(fpath))
+ sys.exit(1)
else:
print(dedent("""
Can't find the build dir in the history.