mirror of
https://github.com/reactos/CMake.git
synced 2024-12-01 07:20:22 +00:00
Autogen: Tests: Refactor the QtAutogenRebuild rccDepends test
Refactors the QtAutogenRebuild rccDepends test script to be more readable.
This commit is contained in:
parent
04a0daeeed
commit
3c77515e13
@ -1,14 +1,15 @@
|
||||
# When a file listed in a .qrc file changes the target must be rebuilt
|
||||
# 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(rccDependsSrcDir "${CMAKE_CURRENT_SOURCE_DIR}/rccDepends")
|
||||
set(rccDependsBinDir "${CMAKE_CURRENT_BINARY_DIR}/rccDepends")
|
||||
set(rccDepSD "${CMAKE_CURRENT_SOURCE_DIR}/rccDepends")
|
||||
set(rccDepBD "${CMAKE_CURRENT_BINARY_DIR}/rccDepends")
|
||||
|
||||
# Initial build
|
||||
configure_file(${rccDependsSrcDir}/res1a.qrc.in ${rccDependsBinDir}/res1.qrc COPYONLY)
|
||||
configure_file(${rccDependsSrcDir}/res2a.qrc.in ${rccDependsBinDir}/res2.qrc.in COPYONLY)
|
||||
configure_file(${rccDepSD}/resPlainA.qrc.in ${rccDepBD}/resPlain.qrc COPYONLY)
|
||||
configure_file(${rccDepSD}/resGenA.qrc.in ${rccDepBD}/resGen.qrc.in COPYONLY)
|
||||
try_compile(RCC_DEPENDS
|
||||
"${rccDependsBinDir}"
|
||||
"${rccDependsSrcDir}"
|
||||
"${rccDepBD}"
|
||||
"${rccDepSD}"
|
||||
rccDepends
|
||||
CMAKE_FLAGS "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}"
|
||||
"-DQT_TEST_VERSION=${QT_TEST_VERSION}"
|
||||
@ -18,74 +19,113 @@ try_compile(RCC_DEPENDS
|
||||
if (NOT RCC_DEPENDS)
|
||||
message(SEND_ERROR "Initial build of rccDepends failed. Output: ${output}")
|
||||
endif()
|
||||
# Get name of the output binary
|
||||
file(STRINGS "${rccDependsBinDir}/target.txt" targetList ENCODING UTF-8)
|
||||
list(GET targetList 0 rccDependsBin)
|
||||
|
||||
file(TIMESTAMP "${rccDependsBin}" timeBegin "${timeformat}")
|
||||
# Sleep, touch regular qrc input file, rebuild and compare timestamp
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that the timestamp will change.
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${rccDependsBinDir}/res1/input.txt")
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${rccDependsBinDir}" RESULT_VARIABLE result)
|
||||
# Get name of the output binaries
|
||||
file(STRINGS "${rccDepBD}/targetPlain.txt" targetListPlain ENCODING UTF-8)
|
||||
file(STRINGS "${rccDepBD}/targetGen.txt" targetListGen ENCODING UTF-8)
|
||||
list(GET targetListPlain 0 rccDepBinPlain)
|
||||
list(GET targetListGen 0 rccDepBinGen)
|
||||
message("Target that uses a plain .qrc file is:\n ${rccDepBinPlain}")
|
||||
message("Target that uses a GENERATED .qrc file is:\n ${rccDepBinGen}")
|
||||
|
||||
|
||||
message("Changing a resource files listed in the .qrc file")
|
||||
# - Acquire binary timestamps before the build
|
||||
file(TIMESTAMP "${rccDepBinPlain}" rdPlainBefore "${timeformat}")
|
||||
file(TIMESTAMP "${rccDepBinGen}" rdGenBefore "${timeformat}")
|
||||
# - Ensure that the timestamp will change
|
||||
# - Change a resource files listed in the .qrc file
|
||||
# - Rebuild
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${rccDepBD}/resPlain/input.txt")
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${rccDepBD}/resGen/input.txt")
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${rccDepBD}" RESULT_VARIABLE result)
|
||||
if (result)
|
||||
message(SEND_ERROR "Second build of rccDepends failed.")
|
||||
endif()
|
||||
file(TIMESTAMP "${rccDependsBin}" timeStep1 "${timeformat}")
|
||||
if (NOT timeStep1 GREATER timeBegin)
|
||||
message(SEND_ERROR "File (${rccDependsBin}) should have changed in the first step!")
|
||||
# - Acquire binary timestamps after the build
|
||||
file(TIMESTAMP "${rccDepBinPlain}" rdPlainAfter "${timeformat}")
|
||||
file(TIMESTAMP "${rccDepBinGen}" rdGenAfter "${timeformat}")
|
||||
# - Test if timestamps changed
|
||||
if (NOT rdPlainAfter GREATER rdPlainBefore)
|
||||
message(SEND_ERROR "Plain .qrc binary ${rccDepBinPlain}) should have changed!")
|
||||
endif()
|
||||
# Sleep, update regular qrc file, rebuild and compare timestamp
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that the timestamp will change.
|
||||
configure_file(${rccDependsSrcDir}/res1b.qrc.in ${rccDependsBinDir}/res1.qrc COPYONLY)
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${rccDependsBinDir}" RESULT_VARIABLE result)
|
||||
if (NOT rdGenAfter GREATER rdGenBefore)
|
||||
message(SEND_ERROR "GENERATED .qrc binary ${rccDepBinGen} should have changed!")
|
||||
endif()
|
||||
|
||||
|
||||
message("Changing a the .qrc file")
|
||||
# - Acquire binary timestamps before the build
|
||||
file(TIMESTAMP "${rccDepBinPlain}" rdPlainBefore "${timeformat}")
|
||||
file(TIMESTAMP "${rccDepBinGen}" rdGenBefore "${timeformat}")
|
||||
# - Ensure that the timestamp will change
|
||||
# - Change the .qrc file
|
||||
# - Rebuild
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
|
||||
configure_file(${rccDepSD}/resPlainB.qrc.in ${rccDepBD}/resPlain.qrc COPYONLY)
|
||||
configure_file(${rccDepSD}/resGenB.qrc.in ${rccDepBD}/resGen.qrc.in COPYONLY)
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${rccDepBD}" RESULT_VARIABLE result)
|
||||
if (result)
|
||||
message(SEND_ERROR "Third build of rccDepends failed.")
|
||||
endif()
|
||||
file(TIMESTAMP "${rccDependsBin}" timeStep2 "${timeformat}")
|
||||
if (NOT timeStep2 GREATER timeStep1)
|
||||
message(SEND_ERROR "File (${rccDependsBin}) should have changed in the second step!")
|
||||
# - Acquire binary timestamps after the build
|
||||
file(TIMESTAMP "${rccDepBinPlain}" rdPlainAfter "${timeformat}")
|
||||
file(TIMESTAMP "${rccDepBinGen}" rdGenAfter "${timeformat}")
|
||||
# - Test if timestamps changed
|
||||
if (NOT rdPlainAfter GREATER rdPlainBefore)
|
||||
message(SEND_ERROR "Plain .qrc binary ${rccDepBinPlain}) should have changed!")
|
||||
endif()
|
||||
# Sleep, touch regular qrc newly added input file, rebuild and compare timestamp
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that the timestamp will change.
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${rccDependsBinDir}/res1/inputAdded.txt")
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${rccDependsBinDir}" RESULT_VARIABLE result)
|
||||
if (NOT rdGenAfter GREATER rdGenBefore)
|
||||
message(SEND_ERROR "GENERATED .qrc binary ${rccDepBinGen} should have changed!")
|
||||
endif()
|
||||
|
||||
|
||||
message("Changing a newly added resource files listed in the .qrc file")
|
||||
# - Acquire binary timestamps before the build
|
||||
file(TIMESTAMP "${rccDepBinPlain}" rdPlainBefore "${timeformat}")
|
||||
file(TIMESTAMP "${rccDepBinGen}" rdGenBefore "${timeformat}")
|
||||
# - Ensure that the timestamp will change
|
||||
# - Change a newly added resource files listed in the .qrc file
|
||||
# - Rebuild
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${rccDepBD}/resPlain/inputAdded.txt")
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${rccDepBD}/resGen/inputAdded.txt")
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${rccDepBD}" RESULT_VARIABLE result)
|
||||
if (result)
|
||||
message(SEND_ERROR "Fourth build of rccDepends failed.")
|
||||
endif()
|
||||
file(TIMESTAMP "${rccDependsBin}" timeStep3 "${timeformat}")
|
||||
if (NOT timeStep3 GREATER timeStep2)
|
||||
message(SEND_ERROR "File (${rccDependsBin}) should have changed in the third step!")
|
||||
# - Acquire binary timestamps after the build
|
||||
file(TIMESTAMP "${rccDepBinPlain}" rdPlainAfter "${timeformat}")
|
||||
file(TIMESTAMP "${rccDepBinGen}" rdGenAfter "${timeformat}")
|
||||
# - Test if timestamps changed
|
||||
if (NOT rdPlainAfter GREATER rdPlainBefore)
|
||||
message(SEND_ERROR "Plain .qrc binary ${rccDepBinPlain}) should have changed!")
|
||||
endif()
|
||||
# Sleep, touch generated qrc input file, rebuild and compare timestamp
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that the timestamp will change.
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${rccDependsBinDir}/res2/input.txt")
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${rccDependsBinDir}" RESULT_VARIABLE result)
|
||||
if (NOT rdGenAfter GREATER rdGenBefore)
|
||||
message(SEND_ERROR "GENERATED .qrc binary ${rccDepBinGen} should have changed!")
|
||||
endif()
|
||||
|
||||
|
||||
message("Changing nothing in the .qrc file")
|
||||
# - Acquire binary timestamps before the build
|
||||
file(TIMESTAMP "${rccDepBinPlain}" rdPlainBefore "${timeformat}")
|
||||
file(TIMESTAMP "${rccDepBinGen}" rdGenBefore "${timeformat}")
|
||||
# - Ensure that the timestamp will change
|
||||
# - Change nothing
|
||||
# - Rebuild
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${rccDepBD}" RESULT_VARIABLE result)
|
||||
if (result)
|
||||
message(SEND_ERROR "Fifth build of rccDepends failed.")
|
||||
endif()
|
||||
file(TIMESTAMP "${rccDependsBin}" timeStep4 "${timeformat}")
|
||||
if (NOT timeStep4 GREATER timeStep3)
|
||||
message(SEND_ERROR "File (${rccDependsBin}) should have changed in the fourth step!")
|
||||
# - Acquire binary timestamps after the build
|
||||
file(TIMESTAMP "${rccDepBinPlain}" rdPlainAfter "${timeformat}")
|
||||
file(TIMESTAMP "${rccDepBinGen}" rdGenAfter "${timeformat}")
|
||||
# - Test if timestamps changed
|
||||
if (rdPlainAfter GREATER rdPlainBefore)
|
||||
message(SEND_ERROR "Plain .qrc binary ${rccDepBinPlain}) should NOT have changed!")
|
||||
endif()
|
||||
# Sleep, update generated qrc file, rebuild and compare timestamp
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that the timestamp will change.
|
||||
configure_file(${rccDependsSrcDir}/res2b.qrc.in ${rccDependsBinDir}/res2.qrc.in COPYONLY)
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${rccDependsBinDir}" RESULT_VARIABLE result)
|
||||
if (result)
|
||||
message(SEND_ERROR "Sixth build of rccDepends failed.")
|
||||
endif()
|
||||
file(TIMESTAMP "${rccDependsBin}" timeStep5 "${timeformat}")
|
||||
if (NOT timeStep5 GREATER timeStep4)
|
||||
message(SEND_ERROR "File (${rccDependsBin}) should have changed in the fitfh step!")
|
||||
endif()
|
||||
# Sleep, touch generated qrc newly added input file, rebuild and compare timestamp
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that the timestamp will change.
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${rccDependsBinDir}/res2/inputAdded.txt")
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${rccDependsBinDir}" RESULT_VARIABLE result)
|
||||
if (result)
|
||||
message(SEND_ERROR "Seventh build of rccDepends failed.")
|
||||
endif()
|
||||
file(TIMESTAMP "${rccDependsBin}" timeStep6 "${timeformat}")
|
||||
if (NOT timeStep6 GREATER timeStep5)
|
||||
message(SEND_ERROR "File (${rccDependsBin}) should have changed in the sixth step!")
|
||||
if (rdGenAfter GREATER rdGenBefore)
|
||||
message(SEND_ERROR "GENERATED .qrc binary ${rccDepBinGen} should NOT have changed!")
|
||||
endif()
|
||||
|
@ -1,8 +1,6 @@
|
||||
cmake_minimum_required(VERSION 3.9)
|
||||
project(rccDepends CXX)
|
||||
|
||||
set(CMAKE_AUTORCC ON)
|
||||
|
||||
if (QT_TEST_VERSION STREQUAL 4)
|
||||
find_package(Qt4 REQUIRED)
|
||||
set(QT_CORE_TARGET Qt4::QtCore)
|
||||
@ -15,21 +13,29 @@ else()
|
||||
set(QT_CORE_TARGET Qt5::Core)
|
||||
endif()
|
||||
|
||||
configure_file(res/input1.txt.in res1/input.txt COPYONLY)
|
||||
configure_file(res/input1.txt.in res1/inputAdded.txt COPYONLY)
|
||||
configure_file(res/input2.txt.in res2/input.txt COPYONLY)
|
||||
configure_file(res/input2.txt.in res2/inputAdded.txt COPYONLY)
|
||||
# Dependency generated qrc file
|
||||
add_custom_command(OUTPUT res2.qrc
|
||||
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/res2.qrc.in
|
||||
COMMAND ${CMAKE_COMMAND} -E sleep 2
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/res2.qrc.in ${CMAKE_CURRENT_BINARY_DIR}/res2.qrc
|
||||
)
|
||||
# Enable AUTORCC for all targets
|
||||
set(CMAKE_AUTORCC ON)
|
||||
|
||||
add_executable(rccDepends
|
||||
main.cpp
|
||||
${CMAKE_CURRENT_BINARY_DIR}/res1.qrc
|
||||
${CMAKE_CURRENT_BINARY_DIR}/res2.qrc )
|
||||
target_link_libraries(rccDepends ${QT_CORE_TARGET})
|
||||
add_custom_command(TARGET rccDepends POST_BUILD COMMAND
|
||||
${CMAKE_COMMAND} -E echo "$<TARGET_FILE:rccDepends>" > target.txt)
|
||||
# Initial resource files setup
|
||||
configure_file(resPlain/input.txt.in resPlain/input.txt COPYONLY)
|
||||
configure_file(resPlain/input.txt.in resPlain/inputAdded.txt COPYONLY)
|
||||
configure_file(resGen/input.txt.in resGen/input.txt COPYONLY)
|
||||
configure_file(resGen/input.txt.in resGen/inputAdded.txt COPYONLY)
|
||||
|
||||
# Generated qrc file with dependency
|
||||
add_custom_command(OUTPUT resGen.qrc
|
||||
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/resGen.qrc.in
|
||||
COMMAND ${CMAKE_COMMAND} -E sleep 2
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/resGen.qrc.in ${CMAKE_CURRENT_BINARY_DIR}/resGen.qrc)
|
||||
|
||||
# Target that uses a plain .qrc file
|
||||
add_executable(rccDependsPlain main.cpp ${CMAKE_CURRENT_BINARY_DIR}/resPlain.qrc)
|
||||
target_link_libraries(rccDependsPlain ${QT_CORE_TARGET})
|
||||
add_custom_command(TARGET rccDependsPlain POST_BUILD COMMAND
|
||||
${CMAKE_COMMAND} -E echo "$<TARGET_FILE:rccDependsPlain>" > targetPlain.txt)
|
||||
|
||||
# Target that uses a GENERATED .qrc file
|
||||
add_executable(rccDependsGen main.cpp ${CMAKE_CURRENT_BINARY_DIR}/resGen.qrc )
|
||||
target_link_libraries(rccDependsGen ${QT_CORE_TARGET})
|
||||
add_custom_command(TARGET rccDependsGen POST_BUILD COMMAND
|
||||
${CMAKE_COMMAND} -E echo "$<TARGET_FILE:rccDependsGen>" > targetGen.txt)
|
||||
|
@ -1 +0,0 @@
|
||||
Res1 input.
|
@ -1 +0,0 @@
|
||||
Res2 input.
|
@ -1,5 +0,0 @@
|
||||
<RCC>
|
||||
<qresource prefix="/Texts1">
|
||||
<file>res1/input.txt</file>
|
||||
</qresource>
|
||||
</RCC>
|
@ -1,6 +0,0 @@
|
||||
<RCC>
|
||||
<qresource prefix="/Texts1">
|
||||
<file>res1/input.txt</file>
|
||||
<file alias="Added">res1/inputAdded.txt</file>
|
||||
</qresource>
|
||||
</RCC>
|
@ -1,5 +0,0 @@
|
||||
<RCC>
|
||||
<qresource prefix="/Texts2">
|
||||
<file>res2/input.txt</file>
|
||||
</qresource>
|
||||
</RCC>
|
@ -1,6 +0,0 @@
|
||||
<RCC>
|
||||
<qresource prefix="/Texts2">
|
||||
<file>res2/input.txt</file>
|
||||
<file alias="Added">res2/inputAdded.txt</file>
|
||||
</qresource>
|
||||
</RCC>
|
1
Tests/QtAutogenRerun/rccDepends/resGen/input.txt.in
Normal file
1
Tests/QtAutogenRerun/rccDepends/resGen/input.txt.in
Normal file
@ -0,0 +1 @@
|
||||
Generated resource input.
|
1
Tests/QtAutogenRerun/rccDepends/resGen/inputAdded.txt.in
Normal file
1
Tests/QtAutogenRerun/rccDepends/resGen/inputAdded.txt.in
Normal file
@ -0,0 +1 @@
|
||||
Generated resource input.
|
5
Tests/QtAutogenRerun/rccDepends/resGenA.qrc.in
Normal file
5
Tests/QtAutogenRerun/rccDepends/resGenA.qrc.in
Normal file
@ -0,0 +1,5 @@
|
||||
<RCC>
|
||||
<qresource prefix="/TextsGenerated">
|
||||
<file>resGen/input.txt</file>
|
||||
</qresource>
|
||||
</RCC>
|
6
Tests/QtAutogenRerun/rccDepends/resGenB.qrc.in
Normal file
6
Tests/QtAutogenRerun/rccDepends/resGenB.qrc.in
Normal file
@ -0,0 +1,6 @@
|
||||
<RCC>
|
||||
<qresource prefix="/TextsGenerated">
|
||||
<file>resGen/input.txt</file>
|
||||
<file alias="Added">resGen/inputAdded.txt</file>
|
||||
</qresource>
|
||||
</RCC>
|
1
Tests/QtAutogenRerun/rccDepends/resPlain/input.txt.in
Normal file
1
Tests/QtAutogenRerun/rccDepends/resPlain/input.txt.in
Normal file
@ -0,0 +1 @@
|
||||
Plaint resource input.
|
@ -0,0 +1 @@
|
||||
Plaint resource input.
|
5
Tests/QtAutogenRerun/rccDepends/resPlainA.qrc.in
Normal file
5
Tests/QtAutogenRerun/rccDepends/resPlainA.qrc.in
Normal file
@ -0,0 +1,5 @@
|
||||
<RCC>
|
||||
<qresource prefix="/TextsPlain">
|
||||
<file>resPlain/input.txt</file>
|
||||
</qresource>
|
||||
</RCC>
|
6
Tests/QtAutogenRerun/rccDepends/resPlainB.qrc.in
Normal file
6
Tests/QtAutogenRerun/rccDepends/resPlainB.qrc.in
Normal file
@ -0,0 +1,6 @@
|
||||
<RCC>
|
||||
<qresource prefix="/TextsPlain">
|
||||
<file>resPlain/input.txt</file>
|
||||
<file alias="Added">resPlain/inputAdded.txt</file>
|
||||
</qresource>
|
||||
</RCC>
|
Loading…
Reference in New Issue
Block a user