Browse Source

Autogen: Add AUTORCC configuration change test

Sebastian Holtermann 7 years ago
parent
commit
5852acffa4

+ 1 - 0
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)

+ 41 - 0
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()

+ 26 - 0
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})

+ 5 - 0
Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/main.cpp

@@ -0,0 +1,5 @@
+
+int main()
+{
+  return 0;
+}

+ 6 - 0
Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resGen.qrc.in

@@ -0,0 +1,6 @@
+<RCC>
+    <qresource prefix="/TextsGenerated">
+        <file>resGen/input1.txt</file>
+        <file>resGen/input2.txt</file>
+    </qresource>
+</RCC>

+ 1 - 0
Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resGen/input1.txt.in

@@ -0,0 +1 @@
+Generated resource input.

+ 1 - 0
Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resGen/input2.txt.in

@@ -0,0 +1 @@
+Generated resource input.

+ 6 - 0
Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resPlain.qrc

@@ -0,0 +1,6 @@
+<RCC>
+    <qresource prefix="/TextsPlain">
+        <file>resPlain/input1.txt</file>
+        <file>resPlain/input2.txt</file>
+    </qresource>
+</RCC>

+ 1 - 0
Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resPlain/input1.txt

@@ -0,0 +1 @@
+Plain resource input.

+ 1 - 0
Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resPlain/input2.txt

@@ -0,0 +1 @@
+Plain resource input.

+ 5 - 0
Tests/QtAutogen/RerunRccConfigChange/dummy.cpp

@@ -0,0 +1,5 @@
+
+int main(int argv, char** args)
+{
+  return 0;
+}