aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2018-10-19 16:24:55 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2018-10-23 07:45:54 +0000
commitff0f55a7f03e70a19a46992dd4e76366d45fc5df (patch)
tree0b3857bd1dbc345b1b4cf18ac2cc7bc68ad1d4c0 /sources/shiboken2
parent25298d800a25848fe15800e365c8987e9d949642 (diff)
Improve build rules for module generation
Previously whenever a typesystem XML file changed, this resulted in a full rebuild of all cpp files generated for that particular module. This change shifts the rules of building in such a way, that files are rebuilt only if their content has changed. XML modifications should generally not cause full rebuilds anymore, unless the change is in a global header. This is achieved in the following way, assuming a binding library "foo" added by add_library(foo ...): 1) CMake calls shiboken via add_custom_command. 2) The OUTPUT file for the command is the generated mjb_rejected_classes.log file, which serves as a timestamp for when shiboken was last run. 3) All the generated cpp files are marked as "Generated" via the add_custom_command BYPRODUCTS option. This allows the files to have an older timestamp than that of an XML file, thus not forcing constant shiboken re-execution. 4) A new custom target foo_generator is added via add_custom_target. 5) This target has a dependency on the mjb_rejected_classes.log file, and the target itself is added as a dependency to the "foo" target. 6) Whenever "foo" is built, it will first try to build "foo_generator" which will force the shiboken custom command to be run, which will generate the cpp files and mjb_rejected_classes.txt file. The BYPRODUCT cpp files can then be used as sources in the "foo" target. 7) If a user modifies the XML file listed in the add_custom_command DEPENDS option, this will re-trigger shiboken execution, which will create a new mjb_rejected_classes.log file, which means that the "foo" target might be rebuilt if, and only if, any of the cpp file timestamps are new. Otherwise "foo" doesn't need to be rebuilt. Change-Id: I9a3844a2fa775106288acc01cb4570a903e16991 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/shiboken2')
-rw-r--r--sources/shiboken2/shibokenmodule/CMakeLists.txt5
-rw-r--r--sources/shiboken2/tests/minimalbinding/CMakeLists.txt5
-rw-r--r--sources/shiboken2/tests/otherbinding/CMakeLists.txt5
-rw-r--r--sources/shiboken2/tests/samplebinding/CMakeLists.txt5
-rw-r--r--sources/shiboken2/tests/smartbinding/CMakeLists.txt5
5 files changed, 20 insertions, 5 deletions
diff --git a/sources/shiboken2/shibokenmodule/CMakeLists.txt b/sources/shiboken2/shibokenmodule/CMakeLists.txt
index 517aecba8..20baf9f7e 100644
--- a/sources/shiboken2/shibokenmodule/CMakeLists.txt
+++ b/sources/shiboken2/shibokenmodule/CMakeLists.txt
@@ -12,7 +12,9 @@ set(shibokenmodule_TYPESYSTEM
${CMAKE_CURRENT_SOURCE_DIR}/typesystem_shiboken.xml
)
-add_custom_command(OUTPUT ${sample_SRC}
+add_custom_command(
+OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/mjb_rejected_classes.log"
+BYPRODUCTS ${sample_SRC}
# Note: shiboken2 is an executable target. By not specifying its explicit
# path, CMAKE figures it out, itself!
# This fixes an issue with Visual Studio, see https://github.com/PySide/shiboken2/pull/11
@@ -39,6 +41,7 @@ target_link_libraries(shibokenmodule
libshiboken)
add_dependencies(shibokenmodule shiboken2)
+create_generator_target(shibokenmodule)
install(TARGETS shibokenmodule DESTINATION ${PYTHON_SITE_PACKAGES}/shiboken2)
diff --git a/sources/shiboken2/tests/minimalbinding/CMakeLists.txt b/sources/shiboken2/tests/minimalbinding/CMakeLists.txt
index b8b6417d1..ec674b56b 100644
--- a/sources/shiboken2/tests/minimalbinding/CMakeLists.txt
+++ b/sources/shiboken2/tests/minimalbinding/CMakeLists.txt
@@ -15,7 +15,9 @@ ${CMAKE_CURRENT_BINARY_DIR}/minimal/minbooluser_wrapper.cpp
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/minimal-binding.txt.in"
"${CMAKE_CURRENT_BINARY_DIR}/minimal-binding.txt" @ONLY)
-add_custom_command(OUTPUT ${minimal_SRC}
+add_custom_command(
+OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/mjb_rejected_classes.log"
+BYPRODUCTS ${minimal_SRC}
COMMAND shiboken2 --project-file=${CMAKE_CURRENT_BINARY_DIR}/minimal-binding.txt ${GENERATOR_EXTRA_FLAGS}
DEPENDS ${minimal_TYPESYSTEM} ${CMAKE_CURRENT_SOURCE_DIR}/global.h shiboken2
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
@@ -38,3 +40,4 @@ target_link_libraries(minimal
libminimal
${SBK_PYTHON_LIBRARIES}
libshiboken)
+create_generator_target(minimal)
diff --git a/sources/shiboken2/tests/otherbinding/CMakeLists.txt b/sources/shiboken2/tests/otherbinding/CMakeLists.txt
index 186766b41..0be66f797 100644
--- a/sources/shiboken2/tests/otherbinding/CMakeLists.txt
+++ b/sources/shiboken2/tests/otherbinding/CMakeLists.txt
@@ -17,7 +17,9 @@ ${CMAKE_CURRENT_BINARY_DIR}/other/other_module_wrapper.cpp
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/other-binding.txt.in"
"${CMAKE_CURRENT_BINARY_DIR}/other-binding.txt" @ONLY)
-add_custom_command(OUTPUT ${other_SRC}
+add_custom_command(
+OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/mjb_rejected_classes.log"
+BYPRODUCTS ${other_SRC}
COMMAND shiboken2 --project-file=${CMAKE_CURRENT_BINARY_DIR}/other-binding.txt ${GENERATOR_EXTRA_FLAGS}
DEPENDS ${other_TYPESYSTEM} ${CMAKE_CURRENT_SOURCE_DIR}/global.h shiboken2
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
@@ -48,4 +50,5 @@ target_link_libraries(other
libshiboken)
add_dependencies(other sample)
+create_generator_target(other)
diff --git a/sources/shiboken2/tests/samplebinding/CMakeLists.txt b/sources/shiboken2/tests/samplebinding/CMakeLists.txt
index ca737ca08..7f4bec5f4 100644
--- a/sources/shiboken2/tests/samplebinding/CMakeLists.txt
+++ b/sources/shiboken2/tests/samplebinding/CMakeLists.txt
@@ -128,7 +128,9 @@ ${CMAKE_CURRENT_BINARY_DIR}/sample/union_wrapper.cpp
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/sample-binding.txt.in"
"${CMAKE_CURRENT_BINARY_DIR}/sample-binding.txt" @ONLY)
-add_custom_command(OUTPUT ${sample_SRC}
+add_custom_command(
+OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/mjb_rejected_classes.log"
+BYPRODUCTS ${sample_SRC}
COMMAND shiboken2 --project-file=${CMAKE_CURRENT_BINARY_DIR}/sample-binding.txt ${GENERATOR_EXTRA_FLAGS}
DEPENDS ${sample_TYPESYSTEM} ${CMAKE_CURRENT_SOURCE_DIR}/global.h shiboken2
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
@@ -152,3 +154,4 @@ target_link_libraries(sample
libsample
${SBK_PYTHON_LIBRARIES}
libshiboken)
+create_generator_target(sample)
diff --git a/sources/shiboken2/tests/smartbinding/CMakeLists.txt b/sources/shiboken2/tests/smartbinding/CMakeLists.txt
index faaa797b6..43888fae2 100644
--- a/sources/shiboken2/tests/smartbinding/CMakeLists.txt
+++ b/sources/shiboken2/tests/smartbinding/CMakeLists.txt
@@ -16,7 +16,9 @@ ${CMAKE_CURRENT_BINARY_DIR}/smart/registry_wrapper.cpp
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/smart-binding.txt.in"
"${CMAKE_CURRENT_BINARY_DIR}/smart-binding.txt" @ONLY)
-add_custom_command(OUTPUT ${smart_SRC}
+add_custom_command(
+OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/mjb_rejected_classes.log"
+BYPRODUCTS ${smart_SRC}
COMMAND shiboken2 --project-file=${CMAKE_CURRENT_BINARY_DIR}/smart-binding.txt ${GENERATOR_EXTRA_FLAGS}
DEPENDS ${smart_TYPESYSTEM} ${CMAKE_CURRENT_SOURCE_DIR}/global.h shiboken2
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
@@ -40,3 +42,4 @@ target_link_libraries(smart
libsmart
${SBK_PYTHON_LIBRARIES}
libshiboken)
+create_generator_target(smart)