From 5852acffa4b67a614df3343bcb29e6b9511d0704 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Fri, 25 May 2018 11:40:23 +0200 Subject: Autogen: Add AUTORCC configuration change test --- Tests/QtAutogen/CommonTests.cmake | 1 + .../QtAutogen/RerunRccConfigChange/CMakeLists.txt | 41 ++++++++++++++++++++++ .../RccConfigChange/CMakeLists.txt | 26 ++++++++++++++ .../RerunRccConfigChange/RccConfigChange/main.cpp | 5 +++ .../RccConfigChange/resGen.qrc.in | 6 ++++ .../RccConfigChange/resGen/input1.txt.in | 1 + .../RccConfigChange/resGen/input2.txt.in | 1 + .../RccConfigChange/resPlain.qrc | 6 ++++ .../RccConfigChange/resPlain/input1.txt | 1 + .../RccConfigChange/resPlain/input2.txt | 1 + Tests/QtAutogen/RerunRccConfigChange/dummy.cpp | 5 +++ 11 files changed, 94 insertions(+) create mode 100644 Tests/QtAutogen/RerunRccConfigChange/CMakeLists.txt create mode 100644 Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/CMakeLists.txt create mode 100644 Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/main.cpp create mode 100644 Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resGen.qrc.in create mode 100644 Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resGen/input1.txt.in create mode 100644 Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resGen/input2.txt.in create mode 100644 Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resPlain.qrc create mode 100644 Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resPlain/input1.txt create mode 100644 Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resPlain/input2.txt create mode 100644 Tests/QtAutogen/RerunRccConfigChange/dummy.cpp diff --git a/Tests/QtAutogen/CommonTests.cmake b/Tests/QtAutogen/CommonTests.cmake index 982a296..cd05aeb 100644 --- a/Tests/QtAutogen/CommonTests.cmake +++ b/Tests/QtAutogen/CommonTests.cmake @@ -43,3 +43,4 @@ if(NOT QT_TEST_VERSION STREQUAL 4) ADD_AUTOGEN_TEST(RerunMocPlugin) endif() ADD_AUTOGEN_TEST(RerunRccDepends) +ADD_AUTOGEN_TEST(RerunRccConfigChange) diff --git a/Tests/QtAutogen/RerunRccConfigChange/CMakeLists.txt b/Tests/QtAutogen/RerunRccConfigChange/CMakeLists.txt new file mode 100644 index 0000000..f09865d --- /dev/null +++ b/Tests/QtAutogen/RerunRccConfigChange/CMakeLists.txt @@ -0,0 +1,41 @@ +cmake_minimum_required(VERSION 3.11.2) +project(RerunRccConfigChange) +include("../AutogenTest.cmake") + +# Tests rcc rebuilding after a configuration change + +# Dummy executable to generate a clean target +add_executable(dummy dummy.cpp) + +# When a .qrc or a file listed in a .qrc file changes, +# the target must be rebuilt +set(timeformat "%Y%j%H%M%S") +set(rccDepSD "${CMAKE_CURRENT_SOURCE_DIR}/RccConfigChange") +set(rccDepBD "${CMAKE_CURRENT_BINARY_DIR}/RccConfigChange") + +# Initial build +try_compile(RCC_DEPENDS + "${rccDepBD}" + "${rccDepSD}" + RccConfigChange + CMAKE_FLAGS "-DQT_TEST_VERSION=${QT_TEST_VERSION}" + "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" + OUTPUT_VARIABLE output +) +if (NOT RCC_DEPENDS) + message(SEND_ERROR "Initial build of rccConfigChange failed. Output: ${output}") +endif() + +# - Rebuild Release +message("Rebuilding rccConfigChange in Release configuration") +execute_process(COMMAND "${CMAKE_COMMAND}" --build . --config Release WORKING_DIRECTORY "${rccDepBD}" RESULT_VARIABLE result) +if (result) + message(SEND_ERROR "Release build of rccConfigChange failed.") +endif() + +# - Rebuild Debug +message("Rebuilding rccConfigChange in Debug configuration") +execute_process(COMMAND "${CMAKE_COMMAND}" --build . --config Debug WORKING_DIRECTORY "${rccDepBD}" RESULT_VARIABLE result) +if (result) + message(SEND_ERROR "Debug build of rccConfigChange failed.") +endif() diff --git a/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/CMakeLists.txt b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/CMakeLists.txt new file mode 100644 index 0000000..3cddf5c --- /dev/null +++ b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/CMakeLists.txt @@ -0,0 +1,26 @@ +cmake_minimum_required(VERSION 3.11.2) +project(RccConfigChange) +include("../../AutogenTest.cmake") + +# Enable AUTORCC for all targets +set(CMAKE_AUTORCC ON) + +# Initial resource files setup +configure_file(resGen/input1.txt.in resGen/input1.txt COPYONLY) +configure_file(resGen/input2.txt.in resGen/input2.txt COPYONLY) +configure_file(resGen.qrc.in resGen.qrc COPYONLY) + +# Generated qrc file with dependency +add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/resGen.qrc + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/resGen.qrc.in + COMMAND ${CMAKE_COMMAND} -E sleep 2 + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/resGen.qrc.in ${CMAKE_CURRENT_BINARY_DIR}/resGen.qrc +) + +# Target that uses a plain .qrc file +add_executable(rccConfigChangePlain main.cpp resPlain.qrc) +target_link_libraries(rccConfigChangePlain ${QT_QTCORE_TARGET}) + +# Target that uses a GENERATED .qrc file +add_executable(rccConfigChangeGen main.cpp ${CMAKE_CURRENT_BINARY_DIR}/resGen.qrc ) +target_link_libraries(rccConfigChangeGen ${QT_QTCORE_TARGET}) diff --git a/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/main.cpp b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/main.cpp new file mode 100644 index 0000000..766b775 --- /dev/null +++ b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/main.cpp @@ -0,0 +1,5 @@ + +int main() +{ + return 0; +} diff --git a/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resGen.qrc.in b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resGen.qrc.in new file mode 100644 index 0000000..9674772 --- /dev/null +++ b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resGen.qrc.in @@ -0,0 +1,6 @@ + + + resGen/input1.txt + resGen/input2.txt + + diff --git a/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resGen/input1.txt.in b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resGen/input1.txt.in new file mode 100644 index 0000000..4f24589 --- /dev/null +++ b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resGen/input1.txt.in @@ -0,0 +1 @@ +Generated resource input. diff --git a/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resGen/input2.txt.in b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resGen/input2.txt.in new file mode 100644 index 0000000..4f24589 --- /dev/null +++ b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resGen/input2.txt.in @@ -0,0 +1 @@ +Generated resource input. diff --git a/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resPlain.qrc b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resPlain.qrc new file mode 100644 index 0000000..e448726 --- /dev/null +++ b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resPlain.qrc @@ -0,0 +1,6 @@ + + + resPlain/input1.txt + resPlain/input2.txt + + diff --git a/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resPlain/input1.txt b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resPlain/input1.txt new file mode 100644 index 0000000..03969c6 --- /dev/null +++ b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resPlain/input1.txt @@ -0,0 +1 @@ +Plain resource input. diff --git a/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resPlain/input2.txt b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resPlain/input2.txt new file mode 100644 index 0000000..03969c6 --- /dev/null +++ b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resPlain/input2.txt @@ -0,0 +1 @@ +Plain resource input. diff --git a/Tests/QtAutogen/RerunRccConfigChange/dummy.cpp b/Tests/QtAutogen/RerunRccConfigChange/dummy.cpp new file mode 100644 index 0000000..4837a76 --- /dev/null +++ b/Tests/QtAutogen/RerunRccConfigChange/dummy.cpp @@ -0,0 +1,5 @@ + +int main(int argv, char** args) +{ + return 0; +} -- cgit v0.12