Add special case handling for corelib mimetypes resources
We have to treat the resources from mimetypes in corelibs specially as they are reused for two test cases. Since we no longer use the qrc files, we have wrapped the relevant code in a function that can be called for every target that depends on it. This change also corrects formatting for the generate CMake code regarding resource commands. Change-Id: I50a05c81151d75aefc9ca165f5ffeb9f5cd77162 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
This commit is contained in:
parent
341ccc3b59
commit
3212f1b866
@ -1037,11 +1037,13 @@ extend_target(Core CONDITION QT_FEATURE_mimetype
|
||||
)
|
||||
|
||||
# Resources:
|
||||
set_source_files_properties("mimetypes/mime/packages/freedesktop.org.xml"
|
||||
PROPERTIES alias "freedesktop.org.xml")
|
||||
add_qt_resource(Core "mimetypes" PREFIX "/qt-project.org/qmime/packages" BASE "mimetypes" FILES
|
||||
mime/packages/freedesktop.org.xml)
|
||||
|
||||
# special case begin
|
||||
# We can't specify the resources directly as we have unit tests that
|
||||
# depend on these as well and we no longer support the use of hand
|
||||
# edited qrc files.
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/mimetypes/mimetypes_resources.cmake)
|
||||
corelib_add_mimetypes_resources(Core)
|
||||
# special case end
|
||||
|
||||
extend_target(Core CONDITION WASM
|
||||
SOURCES
|
||||
|
21
src/corelib/mimetypes/mimetypes_resources.cmake
Normal file
21
src/corelib/mimetypes/mimetypes_resources.cmake
Normal file
@ -0,0 +1,21 @@
|
||||
# List of files that need to be packaged as resources.
|
||||
# This file exists solely because of unit tests that need access to this
|
||||
# information as well. This was previosly handled by referrencing a qrc
|
||||
# file with the same information
|
||||
|
||||
set(corelib_mimetypes_resource_file
|
||||
"${CMAKE_CURRENT_LIST_DIR}/mime/packages/freedesktop.org.xml"
|
||||
)
|
||||
|
||||
function(corelib_add_mimetypes_resources target)
|
||||
set(source_file "${corelib_mimetypes_resource_file}")
|
||||
set_source_files_properties("${source_file}"
|
||||
PROPERTIES alias "freedesktop.org.xml"
|
||||
)
|
||||
add_qt_resource(${target} "mimetypes"
|
||||
PREFIX
|
||||
"/qt-project.org/qmime/packages"
|
||||
FILES
|
||||
"${source_file}"
|
||||
)
|
||||
endfunction()
|
@ -1,2 +1,14 @@
|
||||
# add_subdirectory(qmimetype)
|
||||
# Generated from mimetypes.pro.
|
||||
|
||||
# special case begin
|
||||
if(FEATURE_private_tests)
|
||||
# special case end
|
||||
add_subdirectory(qmimetype)
|
||||
add_subdirectory(qmimedatabase)
|
||||
# special case begin
|
||||
endif()
|
||||
# special case end
|
||||
|
||||
if(NOT QT_FEATURE_private_tests)
|
||||
### remove_subdirectory("qmimetype")
|
||||
endif()
|
||||
|
10
tests/auto/corelib/mimetypes/qmimedatabase/CMakeLists.txt
Normal file
10
tests/auto/corelib/mimetypes/qmimedatabase/CMakeLists.txt
Normal file
@ -0,0 +1,10 @@
|
||||
# Generated from qmimedatabase.pro.
|
||||
|
||||
|
||||
if(TARGET Qt::Concurrent)
|
||||
add_subdirectory(qmimedatabase-xml)
|
||||
|
||||
if(UNIX AND NOT APPLE AND NOT QNX)
|
||||
add_subdirectory(qmimedatabase-cache)
|
||||
endif()
|
||||
endif()
|
@ -0,0 +1,66 @@
|
||||
# Generated from qmimedatabase-cache.pro.
|
||||
|
||||
#####################################################################
|
||||
## tst_qmimedatabase-cache Test:
|
||||
#####################################################################
|
||||
|
||||
add_qt_test(tst_qmimedatabase-cache
|
||||
SOURCES
|
||||
../tst_qmimedatabase.h
|
||||
tst_qmimedatabase-cache.cpp
|
||||
PUBLIC_LIBRARIES
|
||||
Qt::Concurrent
|
||||
)
|
||||
|
||||
# Resources:
|
||||
set_source_files_properties("../qml-again.xml"
|
||||
PROPERTIES alias "qml-again.xml"]
|
||||
)
|
||||
set_source_files_properties("../test.qml"
|
||||
PROPERTIES alias "test.qml"]
|
||||
)
|
||||
set_source_files_properties("../text-x-objcsrc.xml"
|
||||
PROPERTIES alias "text-x-objcsrc.xml"]
|
||||
)
|
||||
set_source_files_properties("../yast2-metapackage-handler-mimetypes.xml"
|
||||
PROPERTIES alias "yast2-metapackage-handler-mimetypes.xml"]
|
||||
)
|
||||
add_qt_resource(tst_qmimedatabase-cache "testdata"
|
||||
PREFIX
|
||||
"/qt-project.org/qmime"
|
||||
BASE
|
||||
".."
|
||||
FILES
|
||||
invalid-magic1.xml
|
||||
invalid-magic2.xml
|
||||
invalid-magic3.xml
|
||||
magic-and-hierarchy.foo
|
||||
magic-and-hierarchy.xml
|
||||
magic-and-hierarchy2.foo
|
||||
qml-again.xml
|
||||
test.qml
|
||||
text-x-objcsrc.xml
|
||||
yast2-metapackage-handler-mimetypes.xml
|
||||
)
|
||||
|
||||
|
||||
#### Keys ignored in scope 1:.:.:qmimedatabase-cache.pro:<TRUE>:
|
||||
# CONFIG = "testcase"
|
||||
|
||||
## Scopes:
|
||||
#####################################################################
|
||||
|
||||
extend_target(tst_qmimedatabase-cache CONDITION 2*_x_ - g
|
||||
COMPILE_OPTIONS
|
||||
-W
|
||||
-Wall
|
||||
-Wextra
|
||||
-Wno-long-long
|
||||
-Wnon-virtual-dtor
|
||||
-Wshadow
|
||||
)
|
||||
|
||||
extend_target(tst_qmimedatabase-cache CONDITION UNIX AND NOT APPLE_OSX AND NOT QNX
|
||||
DEFINES
|
||||
USE_XDG_DATA_DIRS
|
||||
)
|
@ -0,0 +1,72 @@
|
||||
# Generated from qmimedatabase-cache.pro.
|
||||
|
||||
#####################################################################
|
||||
## tst_qmimedatabase-cache Test:
|
||||
#####################################################################
|
||||
|
||||
add_qt_test(tst_qmimedatabase-cache
|
||||
SOURCES
|
||||
../tst_qmimedatabase.h
|
||||
tst_qmimedatabase-cache.cpp
|
||||
PUBLIC_LIBRARIES
|
||||
Qt::Concurrent
|
||||
)
|
||||
|
||||
# Resources:
|
||||
set_source_files_properties("../qml-again.xml"
|
||||
PROPERTIES alias "qml-again.xml"
|
||||
)
|
||||
set_source_files_properties("../test.qml"
|
||||
PROPERTIES alias "test.qml"
|
||||
)
|
||||
set_source_files_properties("../text-x-objcsrc.xml"
|
||||
PROPERTIES alias "text-x-objcsrc.xml"
|
||||
)
|
||||
set_source_files_properties("../yast2-metapackage-handler-mimetypes.xml"
|
||||
PROPERTIES alias "yast2-metapackage-handler-mimetypes.xml"
|
||||
)
|
||||
add_qt_resource(tst_qmimedatabase-cache "testdata"
|
||||
PREFIX
|
||||
"/qt-project.org/qmime"
|
||||
BASE
|
||||
".."
|
||||
FILES
|
||||
invalid-magic1.xml
|
||||
invalid-magic2.xml
|
||||
invalid-magic3.xml
|
||||
magic-and-hierarchy.foo
|
||||
magic-and-hierarchy.xml
|
||||
magic-and-hierarchy2.foo
|
||||
qml-again.xml
|
||||
test.qml
|
||||
text-x-objcsrc.xml
|
||||
yast2-metapackage-handler-mimetypes.xml
|
||||
)
|
||||
|
||||
# special case begin
|
||||
set(corelib_source_dir ../../../../../../src/corelib)
|
||||
include(${corelib_source_dir}/mimetypes/mimetypes_resources.cmake)
|
||||
corelib_add_mimetypes_resources(tst_qmimedatabase-cache)
|
||||
# special case end
|
||||
|
||||
#### Keys ignored in scope 1:.:.:qmimedatabase-cache.pro:<TRUE>:
|
||||
# CONFIG = "testcase"
|
||||
|
||||
## Scopes:
|
||||
#####################################################################
|
||||
|
||||
extend_target(tst_qmimedatabase-cache CONDITION CMAKE_COMPILER_IS_GNUCXX
|
||||
|
||||
COMPILE_OPTIONS
|
||||
-W
|
||||
-Wall
|
||||
-Wextra
|
||||
-Wno-long-long
|
||||
-Wnon-virtual-dtor
|
||||
-Wshadow
|
||||
)
|
||||
|
||||
extend_target(tst_qmimedatabase-cache CONDITION UNIX AND NOT APPLE_OSX AND NOT QNX
|
||||
DEFINES
|
||||
USE_XDG_DATA_DIRS
|
||||
)
|
@ -0,0 +1,72 @@
|
||||
# Generated from qmimedatabase-xml.pro.
|
||||
|
||||
#####################################################################
|
||||
## tst_qmimedatabase-xml Test:
|
||||
#####################################################################
|
||||
|
||||
add_qt_test(tst_qmimedatabase-xml
|
||||
SOURCES
|
||||
../tst_qmimedatabase.h
|
||||
tst_qmimedatabase-xml.cpp
|
||||
PUBLIC_LIBRARIES
|
||||
Qt::ConcurrentPrivate
|
||||
)
|
||||
|
||||
# Resources:
|
||||
set_source_files_properties("../qml-again.xml"
|
||||
PROPERTIES alias "qml-again.xml"
|
||||
)
|
||||
set_source_files_properties("../test.qml"
|
||||
PROPERTIES alias "test.qml"
|
||||
)
|
||||
set_source_files_properties("../text-x-objcsrc.xml"
|
||||
PROPERTIES alias "text-x-objcsrc.xml"
|
||||
)
|
||||
set_source_files_properties("../yast2-metapackage-handler-mimetypes.xml"
|
||||
PROPERTIES alias "yast2-metapackage-handler-mimetypes.xml"
|
||||
)
|
||||
|
||||
add_qt_resource(tst_qmimedatabase-xml "testdata"
|
||||
PREFIX
|
||||
"/qt-project.org/qmime"
|
||||
BASE
|
||||
".."
|
||||
FILES
|
||||
invalid-magic1.xml
|
||||
invalid-magic2.xml
|
||||
invalid-magic3.xml
|
||||
magic-and-hierarchy.foo
|
||||
magic-and-hierarchy.xml
|
||||
magic-and-hierarchy2.foo
|
||||
qml-again.xml
|
||||
test.qml
|
||||
text-x-objcsrc.xml
|
||||
yast2-metapackage-handler-mimetypes.xml
|
||||
)
|
||||
|
||||
# special case begin
|
||||
set(corelib_source_dir ../../../../../../src/corelib)
|
||||
include(${corelib_source_dir}/mimetypes/mimetypes_resources.cmake)
|
||||
corelib_add_mimetypes_resources(tst_qmimedatabase-xml)
|
||||
# special case end
|
||||
|
||||
#### Keys ignored in scope 1:.:.:qmimedatabase-xml.pro:<TRUE>:
|
||||
# CONFIG = "testcase"
|
||||
|
||||
## Scopes:
|
||||
#####################################################################
|
||||
|
||||
extend_target(tst_qmimedatabase-xml CONDITION CMAKE_COMPILER_IS_GNUCXX
|
||||
COMPILE_OPTIONS
|
||||
-W
|
||||
-Wall
|
||||
-Wextra
|
||||
-Wno-long-long
|
||||
-Wnon-virtual-dtor
|
||||
-Wshadow
|
||||
)
|
||||
|
||||
extend_target(tst_qmimedatabase-xml CONDITION UNIX AND NOT APPLE_OSX AND NOT QNX
|
||||
DEFINES
|
||||
USE_XDG_DATA_DIRS
|
||||
)
|
@ -1 +1,15 @@
|
||||
add_qt_test(tst_qmimetype SOURCES tst_qmimetype.cpp LIBRARIES Qt::CorePrivate)
|
||||
# Generated from qmimetype.pro.
|
||||
|
||||
#####################################################################
|
||||
## tst_qmimetype Test:
|
||||
#####################################################################
|
||||
|
||||
add_qt_test(tst_qmimetype
|
||||
SOURCES
|
||||
tst_qmimetype.cpp
|
||||
LIBRARIES
|
||||
Qt::CorePrivate
|
||||
)
|
||||
|
||||
#### Keys ignored in scope 1:.:.:qmimetype.pro:<TRUE>:
|
||||
# CONFIG = "testcase"
|
||||
|
@ -132,18 +132,18 @@ def process_qrc_file(target: str, filepath: str, base_dir: str = '') -> str:
|
||||
if alias:
|
||||
full_source = os.path.join(base_dir, source)
|
||||
output += 'set_source_files_properties("{}"\n' \
|
||||
' PROPERTIES alias "{}")\n'.format(full_source, alias)
|
||||
' PROPERTIES alias "{}"\n)\n'.format(full_source, alias)
|
||||
|
||||
params = ''
|
||||
if lang:
|
||||
params += ' LANG "{}"'.format(lang)
|
||||
params += ' LANG\n "{}"\n'.format(lang)
|
||||
if prefix:
|
||||
params += ' PREFIX "{}"'.format(prefix)
|
||||
params += ' PREFIX\n "{}"\n'.format(prefix)
|
||||
if base_dir:
|
||||
params += ' BASE "{}"'.format(base_dir)
|
||||
output += 'add_qt_resource({} "{}"{} FILES\n {})\n'.format(target, full_resource_name,
|
||||
params += ' BASE\n "{}"\n'.format(base_dir)
|
||||
output += 'add_qt_resource({} "{}"\n{} FILES\n {}\n)\n'.format(target, full_resource_name,
|
||||
params,
|
||||
'\n '.join(sorted_files))
|
||||
'\n '.join(sorted_files))
|
||||
|
||||
resource_count += 1
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user