Android: activate tst_QLibrary
On Android we demand the libraries to always start with "lib" and end with ".so" extension. Also Android does not support versioned libraries. This patch updates CMakeLists.txt to fulfill these requirements, and also omits some unsupported test cases. This allows to enable this test for Android in CMakeLists.txt Task-number: QTBUG-87438 Pick-to: 6.3 6.2 Change-Id: Iec30acdefe00c471acc7139cd255b3389e31d22b Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
This commit is contained in:
parent
5cbb93adc7
commit
ed6fe5abc8
@ -4,9 +4,11 @@ if(QT_BUILD_SHARED_LIBS)
|
|||||||
add_subdirectory(qfactoryloader)
|
add_subdirectory(qfactoryloader)
|
||||||
endif()
|
endif()
|
||||||
add_subdirectory(quuid)
|
add_subdirectory(quuid)
|
||||||
# QTBUG-87438 # special case
|
if(QT_FEATURE_library)
|
||||||
if(QT_FEATURE_library AND NOT ANDROID)
|
# QTBUG-87438 # special case
|
||||||
add_subdirectory(qpluginloader)
|
if(NOT ANDROID)
|
||||||
|
add_subdirectory(qpluginloader)
|
||||||
|
endif()
|
||||||
add_subdirectory(qlibrary)
|
add_subdirectory(qlibrary)
|
||||||
endif()
|
endif()
|
||||||
if(QT_BUILD_SHARED_LIBS AND QT_FEATURE_library)
|
if(QT_BUILD_SHARED_LIBS AND QT_FEATURE_library)
|
||||||
|
@ -37,7 +37,8 @@ if (MACOS)
|
|||||||
"${CMAKE_CURRENT_BINARY_DIR}/*dylib"
|
"${CMAKE_CURRENT_BINARY_DIR}/*dylib"
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/../")
|
"${CMAKE_CURRENT_BINARY_DIR}/../")
|
||||||
elseif (UNIX)
|
elseif (UNIX)
|
||||||
add_custom_command(TARGET mylib POST_BUILD
|
if (NOT ANDROID)
|
||||||
|
add_custom_command(TARGET mylib POST_BUILD
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||||
$<TARGET_FILE:mylib>
|
$<TARGET_FILE:mylib>
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/../libmylib.so.1.0.0"
|
"${CMAKE_CURRENT_BINARY_DIR}/../libmylib.so.1.0.0"
|
||||||
@ -48,6 +49,16 @@ elseif (UNIX)
|
|||||||
"libmylib.so.1.0.0"
|
"libmylib.so.1.0.0"
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/../libmylib.so1"
|
"${CMAKE_CURRENT_BINARY_DIR}/../libmylib.so1"
|
||||||
VERBATIM)
|
VERBATIM)
|
||||||
|
else()
|
||||||
|
# Android does not use symlinks. Also, according to our conventions,
|
||||||
|
# libraries on Android MUST be named in the following pattern:
|
||||||
|
# lib*.so
|
||||||
|
add_custom_command(TARGET mylib POST_BUILD
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||||
|
$<TARGET_FILE:mylib>
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/../libmylib.so"
|
||||||
|
VERBATIM)
|
||||||
|
endif()
|
||||||
else() #Win32
|
else() #Win32
|
||||||
add_custom_command(TARGET mylib POST_BUILD
|
add_custom_command(TARGET mylib POST_BUILD
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||||
|
@ -40,25 +40,36 @@ if(WIN32)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (UNIX)
|
if (UNIX)
|
||||||
add_custom_command(TARGET mylib2 POST_BUILD
|
if(NOT ANDROID)
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
add_custom_command(TARGET mylib2 POST_BUILD
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||||
|
$<TARGET_FILE:mylib2>
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/../system.qt.test.mylib.so"
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||||
|
$<TARGET_FILE:mylib2>
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/../libmylib.so.2.0.0"
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E create_symlink
|
||||||
|
"libmylib.so.2.0.0"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/../libmylib.so.2"
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E remove
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/../libmylib.so"
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E create_symlink
|
||||||
|
"libmylib.so.2.0.0"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/../libmylib.so"
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E create_symlink
|
||||||
|
"libmylib.so.2.0.0"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/../libmylib.so2"
|
||||||
|
VERBATIM)
|
||||||
|
else()
|
||||||
|
# Android does not use symlinks. Also, according to our conventions,
|
||||||
|
# libraries on Android MUST be named in the following pattern:
|
||||||
|
# lib*.so
|
||||||
|
add_custom_command(TARGET mylib2 POST_BUILD
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||||
$<TARGET_FILE:mylib2>
|
$<TARGET_FILE:mylib2>
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/../system.qt.test.mylib.so"
|
"${CMAKE_CURRENT_BINARY_DIR}/../libsystem.qt.test.mylib.so"
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
VERBATIM)
|
||||||
$<TARGET_FILE:mylib2>
|
endif()
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/../libmylib.so.2.0.0"
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E create_symlink
|
|
||||||
"libmylib.so.2.0.0"
|
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/../libmylib.so.2"
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E remove
|
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/../libmylib.so"
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E create_symlink
|
|
||||||
"libmylib.so.2.0.0"
|
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/../libmylib.so"
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E create_symlink
|
|
||||||
"libmylib.so.2.0.0"
|
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/../libmylib.so2"
|
|
||||||
VERBATIM)
|
|
||||||
else() #Win32
|
else() #Win32
|
||||||
add_custom_command(TARGET mylib2 POST_BUILD
|
add_custom_command(TARGET mylib2 POST_BUILD
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||||
|
@ -15,39 +15,13 @@ qt_internal_add_test(tst_qlibrary
|
|||||||
LIBRARIES mylib mylib2 # special case
|
LIBRARIES mylib mylib2 # special case
|
||||||
)
|
)
|
||||||
|
|
||||||
## Scopes:
|
add_dependencies(tst_qlibrary mylib mylib2)
|
||||||
#####################################################################
|
|
||||||
|
|
||||||
if(ANDROID)
|
if(ANDROID)
|
||||||
# special case begin
|
list(APPEND extra_libs
|
||||||
set_source_files_properties(
|
"${CMAKE_CURRENT_BINARY_DIR}/../libmylib.so")
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/../libmylib.so
|
list(APPEND extra_libs
|
||||||
PROPERTIES QT_RESOURCE_TARGET_DEPENDENCY mylib
|
"${CMAKE_CURRENT_BINARY_DIR}/../libsystem.qt.test.mylib.so")
|
||||||
)
|
set_target_properties(tst_qlibrary PROPERTIES
|
||||||
set_source_files_properties(
|
QT_ANDROID_EXTRA_LIBS "${extra_libs}")
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/../libmylib.so2
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/../system.qt.test.mylib.so
|
|
||||||
PROPERTIES QT_RESOURCE_TARGET_DEPENDENCY mylib2
|
|
||||||
)
|
|
||||||
# special case end
|
|
||||||
# Resources:
|
|
||||||
set(qmake_libs_resource_files
|
|
||||||
# special case begin
|
|
||||||
#libmylib.prl
|
|
||||||
libmylib.so
|
|
||||||
libmylib.so2
|
|
||||||
system.qt.test.mylib.so
|
|
||||||
# special case end
|
|
||||||
)
|
|
||||||
|
|
||||||
list(TRANSFORM qmake_libs_resource_files PREPEND "${CMAKE_CURRENT_BINARY_DIR}/../")
|
|
||||||
|
|
||||||
qt_internal_add_resource(tst_qlibrary "qmake_libs"
|
|
||||||
PREFIX
|
|
||||||
"android_test_data"
|
|
||||||
BASE
|
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/.."
|
|
||||||
FILES
|
|
||||||
${qmake_libs_resource_files}
|
|
||||||
)
|
|
||||||
endif()
|
endif()
|
||||||
|
@ -104,9 +104,6 @@ enum QLibraryOperation {
|
|||||||
QString sys_qualifiedLibraryName(const QString &fileName);
|
QString sys_qualifiedLibraryName(const QString &fileName);
|
||||||
|
|
||||||
QString directory;
|
QString directory;
|
||||||
#ifdef Q_OS_ANDROID
|
|
||||||
QSharedPointer<QTemporaryDir> temporaryDir;
|
|
||||||
#endif
|
|
||||||
private slots:
|
private slots:
|
||||||
void initTestCase();
|
void initTestCase();
|
||||||
|
|
||||||
@ -141,24 +138,9 @@ typedef int (*VersionFunction)(void);
|
|||||||
void tst_QLibrary::initTestCase()
|
void tst_QLibrary::initTestCase()
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_ANDROID
|
#ifdef Q_OS_ANDROID
|
||||||
auto tempDir = QEXTRACTTESTDATA("android_test_data");
|
const QStringList paths = QCoreApplication::libraryPaths();
|
||||||
|
QVERIFY(!paths.isEmpty());
|
||||||
QVERIFY2(QDir::setCurrent(tempDir->path()), qPrintable("Could not chdir to " + tempDir->path()));
|
directory = paths.first();
|
||||||
|
|
||||||
// copy :/library_path into ./library_path
|
|
||||||
QVERIFY(QDir().mkdir("library_path"));
|
|
||||||
QDirIterator iterator(":/library_path", QDirIterator::Subdirectories);
|
|
||||||
while (iterator.hasNext()) {
|
|
||||||
iterator.next();
|
|
||||||
QFileInfo sourceFileInfo(iterator.path());
|
|
||||||
QFileInfo targetFileInfo("./library_path/" + sourceFileInfo.fileName());
|
|
||||||
if (!targetFileInfo.exists()) {
|
|
||||||
QDir().mkpath(targetFileInfo.path());
|
|
||||||
QVERIFY(QFile::copy(sourceFileInfo.filePath(), targetFileInfo.filePath()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
directory = tempDir->path();
|
|
||||||
temporaryDir = std::move(tempDir);
|
|
||||||
#else
|
#else
|
||||||
// chdir to our testdata directory, and use relative paths in some tests.
|
// chdir to our testdata directory, and use relative paths in some tests.
|
||||||
QString testdatadir = QFileInfo(QFINDTESTDATA("library_path")).absolutePath();
|
QString testdatadir = QFileInfo(QFINDTESTDATA("library_path")).absolutePath();
|
||||||
@ -224,7 +206,10 @@ void tst_QLibrary::load_data()
|
|||||||
QTest::newRow( "ok03 (with many dots)" ) << appDir + "/system.qt.test.mylib.dll" << true;
|
QTest::newRow( "ok03 (with many dots)" ) << appDir + "/system.qt.test.mylib.dll" << true;
|
||||||
# elif defined Q_OS_UNIX
|
# elif defined Q_OS_UNIX
|
||||||
QTest::newRow( "ok01 (with suffix)" ) << appDir + "/libmylib" SUFFIX << true;
|
QTest::newRow( "ok01 (with suffix)" ) << appDir + "/libmylib" SUFFIX << true;
|
||||||
|
#ifndef Q_OS_ANDROID
|
||||||
|
// We do not support non-standard suffixes on Android
|
||||||
QTest::newRow( "ok02 (with non-standard suffix)" ) << appDir + "/libmylib.so2" << true;
|
QTest::newRow( "ok02 (with non-standard suffix)" ) << appDir + "/libmylib.so2" << true;
|
||||||
|
#endif
|
||||||
QTest::newRow( "ok03 (with many dots)" ) << appDir + "/system.qt.test.mylib.so" << true;
|
QTest::newRow( "ok03 (with many dots)" ) << appDir + "/system.qt.test.mylib.so" << true;
|
||||||
# endif // Q_OS_UNIX
|
# endif // Q_OS_UNIX
|
||||||
}
|
}
|
||||||
@ -438,7 +423,10 @@ void tst_QLibrary::loadHints_data()
|
|||||||
QTest::newRow( "ok03 (with many dots)" ) << appDir + "/system.qt.test.mylib.dll" << int(lh) << true;
|
QTest::newRow( "ok03 (with many dots)" ) << appDir + "/system.qt.test.mylib.dll" << int(lh) << true;
|
||||||
# elif defined Q_OS_UNIX
|
# elif defined Q_OS_UNIX
|
||||||
QTest::newRow( "ok01 (with suffix)" ) << appDir + "/libmylib" SUFFIX << int(lh) << true;
|
QTest::newRow( "ok01 (with suffix)" ) << appDir + "/libmylib" SUFFIX << int(lh) << true;
|
||||||
|
#ifndef Q_OS_ANDROID
|
||||||
|
// We do not support non-standard suffixes on Android
|
||||||
QTest::newRow( "ok02 (with non-standard suffix)" ) << appDir + "/libmylib.so2" << int(lh) << true;
|
QTest::newRow( "ok02 (with non-standard suffix)" ) << appDir + "/libmylib.so2" << int(lh) << true;
|
||||||
|
#endif
|
||||||
QTest::newRow( "ok03 (with many dots)" ) << appDir + "/system.qt.test.mylib.so" << int(lh) << true;
|
QTest::newRow( "ok03 (with many dots)" ) << appDir + "/system.qt.test.mylib.so" << int(lh) << true;
|
||||||
# endif // Q_OS_UNIX
|
# endif // Q_OS_UNIX
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user