From 7604ec7bf6f253372c36daa0351d9d5b8ce8c0ef Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Wed, 12 Feb 2020 15:58:36 +0000 Subject: [PATCH] remove WITH_PNG AND WITH_SQLITE options, build SQLite driver into KtSql module both are not really optional, that is why internal copies of the PNG and SQLite projects sources are bundled. by making the SQLite SQL driver built-in the plasma-desktop process memory usage was reduced by roughly 4MB. Signed-off-by: Ivailo Monev --- CMakeLists.txt | 12 +--- src/core/global/qconfig.h.cmake | 1 - src/gui/CMakeLists.txt | 20 ++---- src/plugins/CMakeLists.txt | 4 -- src/plugins/sqldrivers/sqlite/CMakeLists.txt | 46 -------------- src/plugins/sqldrivers/sqlite/sqlitemain.cpp | 74 ---------------------- src/sql/CMakeLists.txt | 28 ++++++++ .../sqlite => sql/drivers}/qsql_sqlite.cpp | 0 .../sqlite => sql/drivers}/qsql_sqlite.h | 0 src/sql/kernel/qsqldatabase.cpp | 50 ++------------- 10 files changed, 38 insertions(+), 197 deletions(-) delete mode 100644 src/plugins/sqldrivers/sqlite/CMakeLists.txt delete mode 100644 src/plugins/sqldrivers/sqlite/sqlitemain.cpp rename src/{plugins/sqldrivers/sqlite => sql/drivers}/qsql_sqlite.cpp (100%) rename src/{plugins/sqldrivers/sqlite => sql/drivers}/qsql_sqlite.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index ec116e35b..70eb5acf6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -106,9 +106,6 @@ add_feature_info(nis WITH_NIS "build NIS support") option(WITH_CUPS "Build CUPS support" ON) add_feature_info(cups WITH_CUPS "build CUPS support") -option(WITH_PNG "Build PNG support" ON) -add_feature_info(png WITH_PNG "build PNG support") - option(WITH_JPEG "Build JPEG support" ON) add_feature_info(jpeg WITH_JPEG "build JPEG support") @@ -137,9 +134,6 @@ add_feature_info(postgresql WITH_PSQL "build PostgreSQL support") option(WITH_MYSQL "Build MySQL database plugin" ON) add_feature_info(mysql WITH_MYSQL "build MySQL support") -option(WITH_SQLITE "Build SQLite database plugin" ON) -add_feature_info(sqlite WITH_SQLITE "build SQLite support") - option(WITH_RESOLV "Build resolv support" ON) add_feature_info(resolv WITH_RESOLV "build resolv support") @@ -484,13 +478,11 @@ foreach(script exec dbg) endforeach() # optional packages which if not found are build internally -if(NOT WITH_PNG) - katie_definition(-DQT_NO_IMAGEFORMAT_PNG) -elseif(NOT PNG_FOUND) +if(NOT PNG_FOUND) message(WARNING "Using internal copy of libpng") endif() -if(WITH_SQLITE AND NOT SQLITE_FOUND) +if(NOT SQLITE_FOUND) message(WARNING "Using internal copy of sqlite") endif() diff --git a/src/core/global/qconfig.h.cmake b/src/core/global/qconfig.h.cmake index c4a938e24..aeae556aa 100644 --- a/src/core/global/qconfig.h.cmake +++ b/src/core/global/qconfig.h.cmake @@ -194,7 +194,6 @@ #cmakedefine QT_NO_IMAGEFORMAT_ICO #cmakedefine QT_NO_IMAGEFORMAT_JPEG #cmakedefine QT_NO_IMAGEFORMAT_MNG -#cmakedefine QT_NO_IMAGEFORMAT_PNG #cmakedefine QT_NO_IMAGEFORMAT_PPM #cmakedefine QT_NO_IMAGEFORMAT_TGA #cmakedefine QT_NO_IMAGEFORMAT_TIFF diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 17e148dbc..dda254b48 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -320,6 +320,7 @@ set(GUI_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/image/qppmhandler_p.h ${CMAKE_CURRENT_SOURCE_DIR}/image/qxbmhandler_p.h ${CMAKE_CURRENT_SOURCE_DIR}/image/qxpmhandler_p.h + ${CMAKE_CURRENT_SOURCE_DIR}/image/qpnghandler_p.h ${CMAKE_CURRENT_SOURCE_DIR}/itemviews/qabstractitemview.h ${CMAKE_CURRENT_SOURCE_DIR}/itemviews/qabstractitemview_p.h ${CMAKE_CURRENT_SOURCE_DIR}/itemviews/qheaderview.h @@ -698,6 +699,7 @@ set(GUI_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/image/qppmhandler.cpp ${CMAKE_CURRENT_SOURCE_DIR}/image/qxbmhandler.cpp ${CMAKE_CURRENT_SOURCE_DIR}/image/qxpmhandler.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/image/qpnghandler.cpp ${CMAKE_CURRENT_SOURCE_DIR}/itemviews/qabstractitemview.cpp ${CMAKE_CURRENT_SOURCE_DIR}/itemviews/qheaderview.cpp ${CMAKE_CURRENT_SOURCE_DIR}/itemviews/qidentityproxymodel.cpp @@ -958,30 +960,16 @@ if(WITH_NSL AND NSL_FOUND) include_directories(${NSL_INCLUDES}) endif() -if(WITH_PNG AND PNG_FOUND) - set(GUI_HEADERS - ${GUI_HEADERS} - ${CMAKE_CURRENT_SOURCE_DIR}/image/qpnghandler_p.h - ) - set(GUI_SOURCES - ${GUI_SOURCES} - ${CMAKE_CURRENT_SOURCE_DIR}/image/qpnghandler.cpp - ) +if(PNG_FOUND) set(EXTRA_GUI_LIBS ${EXTRA_GUI_LIBS} ${PNG_LIBRARIES} ) include_directories(${PNG_INCLUDE_DIRS}) add_definitions(${PNG_DEFINITIONS}) -elseif(WITH_PNG) - set(GUI_HEADERS - ${GUI_HEADERS} - ${CMAKE_CURRENT_SOURCE_DIR}/image/qpnghandler_p.h - ) - +else() set(GUI_SOURCES ${GUI_SOURCES} - ${CMAKE_CURRENT_SOURCE_DIR}/image/qpnghandler.cpp ${CMAKE_SOURCE_DIR}/src/3rdparty/libpng/png.c ${CMAKE_SOURCE_DIR}/src/3rdparty/libpng/pngerror.c ${CMAKE_SOURCE_DIR}/src/3rdparty/libpng/pngget.c diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt index 521041b9d..450e99c96 100644 --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -103,10 +103,6 @@ endif() if(WITH_PSQL AND PostgreSQL_FOUND) add_subdirectory(sqldrivers/psql) endif() -if(WITH_SQLITE) - add_subdirectory(sqldrivers/sqlite) -endif() - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/plugins/designer") set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/plugins/designer") diff --git a/src/plugins/sqldrivers/sqlite/CMakeLists.txt b/src/plugins/sqldrivers/sqlite/CMakeLists.txt deleted file mode 100644 index c9d980d17..000000000 --- a/src/plugins/sqldrivers/sqlite/CMakeLists.txt +++ /dev/null @@ -1,46 +0,0 @@ -set(SQLDRIVER_HEADERS - ${CMAKE_CURRENT_SOURCE_DIR}/qsql_sqlite.h -) - -set(SQLDRIVER_SOURCES - ${CMAKE_CURRENT_SOURCE_DIR}/sqlitemain.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/qsql_sqlite.cpp -) - -if(SQLITE_FOUND) - include_directories(${SQLITE_INCLUDES}) -else() - set(SQLDRIVER_HEADERS - ${SQLDRIVER_HEADERS} - ${CMAKE_SOURCE_DIR}/src/3rdparty/sqlite/sqlite3.h - ${CMAKE_SOURCE_DIR}/src/3rdparty/sqlite/sqlite3ext.h - ) - - set(SQLDRIVER_SOURCES - ${SQLDRIVER_SOURCES} - ${CMAKE_SOURCE_DIR}/src/3rdparty/sqlite/sqlite3.c - ) - - include_directories(${CMAKE_SOURCE_DIR}/src/3rdparty/sqlite) -endif() - -katie_setup_target(qsqliteplugin ${SQLDRIVER_SOURCES} ${SQLDRIVER_HEADERS}) - -add_library(qsqliteplugin MODULE ${qsqliteplugin_SOURCES}) -target_link_libraries(qsqliteplugin KtSql) -set_target_properties(qsqliteplugin PROPERTIES OUTPUT_NAME qsqlite) - -if(SQLITE_FOUND) - target_link_libraries(qsqliteplugin ${SQLITE_LIBRARIES}) -else() - target_compile_definitions(qsqliteplugin PRIVATE - -DSQLITE_OMIT_LOAD_EXTENSION - -DSQLITE_OMIT_COMPLETE - ) -endif() - -install( - TARGETS qsqliteplugin - DESTINATION ${KATIE_PLUGINS_RELATIVE}/sqldrivers - COMPONENT Runtime -) diff --git a/src/plugins/sqldrivers/sqlite/sqlitemain.cpp b/src/plugins/sqldrivers/sqlite/sqlitemain.cpp deleted file mode 100644 index 9fd2406a1..000000000 --- a/src/plugins/sqldrivers/sqlite/sqlitemain.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2016-2020 Ivailo Monev -** -** This file is part of the plugins of the Katie Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qsqldriverplugin.h" -#include "qstringlist.h" -#include "qsql_sqlite.h" - -QT_BEGIN_NAMESPACE - -class QSQLiteDriverPlugin : public QSqlDriverPlugin -{ -public: - QSQLiteDriverPlugin(); - - QSqlDriver* create(const QString &); - QStringList keys() const; -}; - -QSQLiteDriverPlugin::QSQLiteDriverPlugin() - : QSqlDriverPlugin() -{ -} - -QSqlDriver* QSQLiteDriverPlugin::create(const QString &name) -{ - if (name == QLatin1String("QSQLITE")) { - QSQLiteDriver* driver = new QSQLiteDriver(); - return driver; - } - return 0; -} - -QStringList QSQLiteDriverPlugin::keys() const -{ - static const QStringList list = QStringList() - << QLatin1String("QSQLITE"); - return list; -} - -Q_EXPORT_STATIC_PLUGIN(QSQLiteDriverPlugin) -Q_EXPORT_PLUGIN2(qsqlite, QSQLiteDriverPlugin) - -QT_END_NAMESPACE - diff --git a/src/sql/CMakeLists.txt b/src/sql/CMakeLists.txt index 3e701f0c3..bb307738f 100644 --- a/src/sql/CMakeLists.txt +++ b/src/sql/CMakeLists.txt @@ -45,6 +45,7 @@ set(SQL_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/models/qsqltablemodel_p.h ${CMAKE_CURRENT_SOURCE_DIR}/models/qsqlrelationaldelegate.h ${CMAKE_CURRENT_SOURCE_DIR}/models/qsqlrelationaltablemodel.h + ${CMAKE_CURRENT_SOURCE_DIR}/drivers/qsql_sqlite.h ) set(SQL_SOURCES @@ -62,8 +63,35 @@ set(SQL_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/models/qsqltablemodel.cpp ${CMAKE_CURRENT_SOURCE_DIR}/models/qsqlrelationaldelegate.cpp ${CMAKE_CURRENT_SOURCE_DIR}/models/qsqlrelationaltablemodel.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/drivers/qsql_sqlite.cpp ) +if(SQLITE_FOUND) + set(EXTRA_SQL_LIBS + ${EXTRA_SQL_LIBS} + ${SQLITE_LIBRARIES} + ) + include_directories(${SQLITE_INCLUDES}) +else() + set(SQL_HEADERS + ${SQL_HEADERS} + ${CMAKE_SOURCE_DIR}/src/3rdparty/sqlite/sqlite3.h + ${CMAKE_SOURCE_DIR}/src/3rdparty/sqlite/sqlite3ext.h + ) + + set(SQL_SOURCES + ${SQL_SOURCES} + ${CMAKE_SOURCE_DIR}/src/3rdparty/sqlite/sqlite3.c + ) + + add_definitions( + -DSQLITE_OMIT_LOAD_EXTENSION + -DSQLITE_OMIT_COMPLETE + ) + include_directories(${CMAKE_SOURCE_DIR}/src/3rdparty/sqlite) +endif() + + katie_generate_misc("${SQL_HEADERS}" QtSql) katie_generate_public("${SQL_PUBLIC_HEADERS}" QtSql) katie_generate_package(KtSql "KtCore") diff --git a/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp b/src/sql/drivers/qsql_sqlite.cpp similarity index 100% rename from src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp rename to src/sql/drivers/qsql_sqlite.cpp diff --git a/src/plugins/sqldrivers/sqlite/qsql_sqlite.h b/src/sql/drivers/qsql_sqlite.h similarity index 100% rename from src/plugins/sqldrivers/sqlite/qsql_sqlite.h rename to src/sql/drivers/qsql_sqlite.h diff --git a/src/sql/kernel/qsqldatabase.cpp b/src/sql/kernel/qsqldatabase.cpp index f6e6261fd..4d900b57b 100644 --- a/src/sql/kernel/qsqldatabase.cpp +++ b/src/sql/kernel/qsqldatabase.cpp @@ -34,20 +34,6 @@ #include "qsqldatabase.h" #include "qsqlquery.h" -// NOTE: if the following are defined then drivers must be built-in -#ifdef QT_SQL_PSQL -#include "../drivers/psql/qsql_psql.h" -#endif -#ifdef QT_SQL_MYSQL -#include "../drivers/mysql/qsql_mysql.h" -#endif -#ifdef QT_SQL_ODBC -#include "../drivers/odbc/qsql_odbc.h" -#endif -#ifdef QT_SQL_SQLITE -#include "../drivers/sqlite/qsql_sqlite.h" -#endif - #include "qdebug.h" #include "qcoreapplication.h" #include "qreadwritelock.h" @@ -59,6 +45,8 @@ #include "qsqlnulldriver_p.h" #include "qmutex.h" #include "qhash.h" +#include "qsql_sqlite.h" + #include QT_BEGIN_NAMESPACE @@ -500,22 +488,7 @@ void QSqlDatabase::removeDatabase(const QString& connectionName) QStringList QSqlDatabase::drivers() { QStringList list; - -#ifdef QT_SQL_PSQL - list << QLatin1String("QPSQL7"); - list << QLatin1String("QPSQL"); -#endif -#ifdef QT_SQL_MYSQL - list << QLatin1String("QMYSQL3"); - list << QLatin1String("QMYSQL"); -#endif -#ifdef QT_SQL_ODBC - list << QLatin1String("QODBC3"); - list << QLatin1String("QODBC"); -#endif -#ifdef QT_SQL_SQLITE list << QLatin1String("QSQLITE"); -#endif #ifndef QT_NO_LIBRARY if (QFactoryLoader *fl = sqlloader()) { @@ -661,23 +634,8 @@ void QSqlDatabasePrivate::init(const QString &type) { drvName = type; - if (!driver) { -#ifdef QT_SQL_PSQL - if (type == QLatin1String("QPSQL") || type == QLatin1String("QPSQL7")) - driver = new QPSQLDriver(); -#endif -#ifdef QT_SQL_MYSQL - if (type == QLatin1String("QMYSQL") || type == QLatin1String("QMYSQL3")) - driver = new QMYSQLDriver(); -#endif -#ifdef QT_SQL_ODBC - if (type == QLatin1String("QODBC") || type == QLatin1String("QODBC3")) - driver = new QODBCDriver(); -#endif -#ifdef QT_SQL_SQLITE - if (type == QLatin1String("QSQLITE")) - driver = new QSQLiteDriver(); -#endif + if (!driver && type == QLatin1String("QSQLITE")) { + driver = new QSQLiteDriver(); } if (!driver) { -- 2.11.0