From da8458ddc9d7aeabb2d233619e14f1f530ebe97a Mon Sep 17 00:00:00 2001 From: JaySon Date: Mon, 4 Jan 2021 00:53:33 -0600 Subject: [PATCH] Remove useless component to shorten the compile time (#1332) * Remove useless codes * minimize build target --- CMakeLists.txt | 52 ++++++++++++------- dbms/CMakeLists.txt | 2 +- .../DataStreams/CapnProtoRowInputStream.cpp | 2 +- .../src/DataStreams/CapnProtoRowInputStream.h | 2 +- .../Embedded/TechDataHierarchy.cpp | 2 +- .../Dictionaries/MongoDBBlockInputStream.cpp | 2 +- .../Dictionaries/MongoDBDictionarySource.cpp | 2 +- .../Dictionaries/MySQLBlockInputStream.cpp | 2 +- .../Dictionaries/MySQLDictionarySource.cpp | 2 +- .../src/Dictionaries/ODBCBlockInputStream.cpp | 4 ++ dbms/src/Dictionaries/ODBCBlockInputStream.h | 3 ++ .../src/Dictionaries/ODBCDictionarySource.cpp | 4 ++ dbms/src/Dictionaries/ODBCDictionarySource.h | 2 + dbms/src/Storages/StorageMySQL.cpp | 2 +- dbms/src/Storages/StorageMySQL.h | 2 +- dbms/src/Storages/StorageODBC.cpp | 4 ++ dbms/src/Storages/StorageODBC.h | 3 ++ .../src/TableFunctions/TableFunctionMySQL.cpp | 2 +- dbms/src/TableFunctions/TableFunctionMySQL.h | 3 ++ dbms/src/TableFunctions/TableFunctionODBC.cpp | 2 +- dbms/src/TableFunctions/TableFunctionODBC.h | 2 +- release-centos7/build/build-tiflash-ci.sh | 3 +- 22 files changed, 70 insertions(+), 34 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a59359764d8..6355e1c2dfc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,9 +62,6 @@ if (ARCH_LINUX) set (CXX11_ABI "ENABLE" CACHE STRING "Use C++11 ABI: DEFAULT, ENABLE, DISABLE") endif () -option (TEST_COVERAGE "Enables flags for test coverage" OFF) -option (ENABLE_TESTS "Enables tests" ${NOT_MSVC}) - option (USE_STATIC_LIBRARIES "Set to FALSE to use shared libraries" ON) option (MAKE_STATIC_LIBRARIES "Set to FALSE to make shared libraries" ${USE_STATIC_LIBRARIES}) if (NOT MAKE_STATIC_LIBRARIES) @@ -213,17 +210,6 @@ if (USE_INCLUDE_WHAT_YOU_USE) endif() endif () -# Flags for test coverage -if (TEST_COVERAGE AND CMAKE_BUILD_TYPE STREQUAL "Debug") - include(CodeCoverage) - set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage -DIS_DEBUG") -endif () - -if (ENABLE_TESTS) - message (STATUS "Tests are enabled") - enable_testing() -endif () - # when installing to /usr - place configs to /etc but for /usr/local place to /usr/local/etc if (CMAKE_INSTALL_PREFIX STREQUAL "/usr") set (CLICKHOUSE_ETC_DIR "/etc") @@ -246,6 +232,7 @@ message (STATUS "Building for: ${CMAKE_SYSTEM} ${CMAKE_SYSTEM_PROCESSOR} ${CMAKE include(GNUInstallDirs) +# openssl, zlib before poco include (cmake/find_ssl.cmake) if (NOT OPENSSL_FOUND) message (FATAL_ERROR "Need openssl for build. debian tip: sudo apt install libssl-dev") @@ -254,18 +241,22 @@ endif () include (cmake/lib_name.cmake) include (cmake/find_icu4c.cmake) include (cmake/find_boost.cmake) -# openssl, zlib before poco # Clickhouse wants to use internal zlib (contrib/zlib-ng) to speed up by default. But it will conflict with `find_package(ZLIB REQUIRED)` from cmake. # If `ENABLE_RDKAFKA` is true, librdkafka will fix the conflict by using the standard one. # librdkafka is useless for tiflash, need to set `USE_INTERNAL_ZLIB_LIBRARY` and `ENABLE_RDKAFKA` to OFF. set (ENABLE_RDKAFKA OFF CACHE BOOL "" FORCE) set (USE_INTERNAL_ZLIB_LIBRARY OFF CACHE BOOL "" FORCE) +option (ENABLE_ODBC "Set to ON to link odbc libraries if exists" OFF) +option (ENABLE_CAPNP "Set to ON to link capnp" OFF) +option (ENABLE_MONGODB "Enable MongoDB" OFF) +option (ENABLE_CPPUNIT "Enable CppUnit" OFF) +option (POCO_ENABLE_MONGODB "Enable MongoDB in Poco" OFF) +option (ENABLE_MYSQL_STORAGE "Set to ON to enable mysql storage" OFF) +message(STATUS "feature odbc: ${ENABLE_ODBC} capnp: ${ENABLE_CAPNP} mysql-storage: ${ENABLE_MYSQL_STORAGE} ") include (cmake/find_zlib.cmake) include (cmake/find_zstd.cmake) -option (ENABLE_ODBC "Set to ON to link odbc libraries if exists" OFF) -message(STATUS "enalbe odbc: ${ENABLE_ODBC}") if (ENABLE_ODBC) include (cmake/find_ltdl.cmake) # for odbc if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/poco/cmake/FindODBC.cmake) @@ -282,8 +273,12 @@ include (cmake/find_rt.cmake) include (cmake/find_execinfo.cmake) include (cmake/find_readline_edit.cmake) include (cmake/find_re2.cmake) -include (cmake/find_rdkafka.cmake) -include (cmake/find_capnp.cmake) +if (ENABLE_RDKAFKA) + include (cmake/find_rdkafka.cmake) +endif() +if (ENABLE_CAPNP) + include (cmake/find_capnp.cmake) +endif() include (cmake/find_llvm.cmake) include (cmake/find_grpc.cmake) include (cmake/find_kvproto.cmake) @@ -302,7 +297,9 @@ find_contrib_lib(double-conversion) include (libs/libcommon/cmake/find_gperftools.cmake) include (libs/libcommon/cmake/find_jemalloc.cmake) include (libs/libcommon/cmake/find_cctz.cmake) -include (libs/libmysqlxx/cmake/find_mysqlclient.cmake) +if (ENABLE_MYSQL_STORAGE) + include (libs/libmysqlxx/cmake/find_mysqlclient.cmake) +endif() include (libs/libdaemon/cmake/find_unwind.cmake) include (cmake/print_flags.cmake) @@ -314,6 +311,21 @@ if (EXISTS ${CLICKHOUSE_PRIVATE_DIR}) endif () add_subdirectory (contrib) + +option (TEST_COVERAGE "Enables flags for test coverage" OFF) +option (ENABLE_TESTS "Enables tests" ${NOT_MSVC}) + +# Flags for test coverage +if (TEST_COVERAGE AND CMAKE_BUILD_TYPE STREQUAL "Debug") + include(CodeCoverage) + set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage -DIS_DEBUG") +endif () + +if (ENABLE_TESTS) + message (STATUS "Tests are enabled") + enable_testing() +endif () + add_subdirectory (libs) add_subdirectory (utils) add_subdirectory (dbms) diff --git a/dbms/CMakeLists.txt b/dbms/CMakeLists.txt index b22a1fb4243..cf5cc963cfe 100644 --- a/dbms/CMakeLists.txt +++ b/dbms/CMakeLists.txt @@ -9,7 +9,7 @@ set (CONFIG_COMMON ${CMAKE_CURRENT_BINARY_DIR}/src/Common/config.h) set (CONFIG_BUILD ${CMAKE_CURRENT_BINARY_DIR}/src/Common/config_build.cpp) include (cmake/version.cmake) -message (STATUS "Will build ${VERSION_FULL} (${TIFLASH_VERSION_FULL})") +message (STATUS "Will build ${VERSION_FULL} (TiFlash ${TIFLASH_RELEASE_VERSION})") configure_file (${CMAKE_CURRENT_SOURCE_DIR}/src/Common/config.h.in ${CONFIG_COMMON}) configure_file (${CMAKE_CURRENT_SOURCE_DIR}/src/Common/config_version.h.in ${CONFIG_VERSION}) diff --git a/dbms/src/DataStreams/CapnProtoRowInputStream.cpp b/dbms/src/DataStreams/CapnProtoRowInputStream.cpp index 151b092c995..941527bb897 100644 --- a/dbms/src/DataStreams/CapnProtoRowInputStream.cpp +++ b/dbms/src/DataStreams/CapnProtoRowInputStream.cpp @@ -1,5 +1,5 @@ -#include #if USE_CAPNP +#include #include #include diff --git a/dbms/src/DataStreams/CapnProtoRowInputStream.h b/dbms/src/DataStreams/CapnProtoRowInputStream.h index 7fe93906b29..f69a78f417e 100644 --- a/dbms/src/DataStreams/CapnProtoRowInputStream.h +++ b/dbms/src/DataStreams/CapnProtoRowInputStream.h @@ -1,6 +1,6 @@ #pragma once -#include #if USE_CAPNP +#include #include #include diff --git a/dbms/src/Dictionaries/Embedded/TechDataHierarchy.cpp b/dbms/src/Dictionaries/Embedded/TechDataHierarchy.cpp index 741d3833c34..8963c4d6bcd 100644 --- a/dbms/src/Dictionaries/Embedded/TechDataHierarchy.cpp +++ b/dbms/src/Dictionaries/Embedded/TechDataHierarchy.cpp @@ -1,5 +1,5 @@ -#include #if USE_MYSQL +#include #include diff --git a/dbms/src/Dictionaries/MongoDBBlockInputStream.cpp b/dbms/src/Dictionaries/MongoDBBlockInputStream.cpp index 11125fb08ed..8ecd3451aa8 100644 --- a/dbms/src/Dictionaries/MongoDBBlockInputStream.cpp +++ b/dbms/src/Dictionaries/MongoDBBlockInputStream.cpp @@ -1,5 +1,5 @@ -#include #if Poco_MongoDB_FOUND +#include #include #include diff --git a/dbms/src/Dictionaries/MongoDBDictionarySource.cpp b/dbms/src/Dictionaries/MongoDBDictionarySource.cpp index 348e415b201..e4f6ab9e838 100644 --- a/dbms/src/Dictionaries/MongoDBDictionarySource.cpp +++ b/dbms/src/Dictionaries/MongoDBDictionarySource.cpp @@ -1,5 +1,5 @@ -#include #if Poco_MongoDB_FOUND +#include #include #pragma GCC diagnostic push diff --git a/dbms/src/Dictionaries/MySQLBlockInputStream.cpp b/dbms/src/Dictionaries/MySQLBlockInputStream.cpp index a3fc591ef7d..2f45ddc43db 100644 --- a/dbms/src/Dictionaries/MySQLBlockInputStream.cpp +++ b/dbms/src/Dictionaries/MySQLBlockInputStream.cpp @@ -1,5 +1,5 @@ -#include #if USE_MYSQL +#include #include #include diff --git a/dbms/src/Dictionaries/MySQLDictionarySource.cpp b/dbms/src/Dictionaries/MySQLDictionarySource.cpp index 352010c93da..81ad5cacb3a 100644 --- a/dbms/src/Dictionaries/MySQLDictionarySource.cpp +++ b/dbms/src/Dictionaries/MySQLDictionarySource.cpp @@ -1,5 +1,5 @@ -#include #if USE_MYSQL +#include #include #include diff --git a/dbms/src/Dictionaries/ODBCBlockInputStream.cpp b/dbms/src/Dictionaries/ODBCBlockInputStream.cpp index d6ba9f5cdd9..00e2322fe89 100644 --- a/dbms/src/Dictionaries/ODBCBlockInputStream.cpp +++ b/dbms/src/Dictionaries/ODBCBlockInputStream.cpp @@ -1,3 +1,5 @@ +#if Poco_SQLODBC_FOUND || Poco_DataODBC_FOUND + #include #include @@ -105,3 +107,5 @@ Block ODBCBlockInputStream::readImpl() } } + +#endif diff --git a/dbms/src/Dictionaries/ODBCBlockInputStream.h b/dbms/src/Dictionaries/ODBCBlockInputStream.h index b881beb9b1f..220c17b3ff0 100644 --- a/dbms/src/Dictionaries/ODBCBlockInputStream.h +++ b/dbms/src/Dictionaries/ODBCBlockInputStream.h @@ -1,4 +1,5 @@ #pragma once +#if Poco_SQLODBC_FOUND || Poco_DataODBC_FOUND #include #include @@ -44,3 +45,5 @@ class ODBCBlockInputStream final : public IProfilingBlockInputStream }; } + +#endif diff --git a/dbms/src/Dictionaries/ODBCDictionarySource.cpp b/dbms/src/Dictionaries/ODBCDictionarySource.cpp index 489b168b3fa..070b8d050b4 100644 --- a/dbms/src/Dictionaries/ODBCDictionarySource.cpp +++ b/dbms/src/Dictionaries/ODBCDictionarySource.cpp @@ -1,3 +1,5 @@ +#if Poco_SQLODBC_FOUND || Poco_DataODBC_FOUND + #include #include #include @@ -150,3 +152,5 @@ std::string ODBCDictionarySource::doInvalidateQuery(const std::string & request) } } + +#endif diff --git a/dbms/src/Dictionaries/ODBCDictionarySource.h b/dbms/src/Dictionaries/ODBCDictionarySource.h index 0f10dbd94ff..bc52e7c418d 100644 --- a/dbms/src/Dictionaries/ODBCDictionarySource.h +++ b/dbms/src/Dictionaries/ODBCDictionarySource.h @@ -1,4 +1,5 @@ #pragma once +#if Poco_SQLODBC_FOUND || Poco_DataODBC_FOUND #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" @@ -77,3 +78,4 @@ class ODBCDictionarySource final : public IDictionarySource } +#endif diff --git a/dbms/src/Storages/StorageMySQL.cpp b/dbms/src/Storages/StorageMySQL.cpp index 3c63ebe4ca5..c5e611d05fa 100644 --- a/dbms/src/Storages/StorageMySQL.cpp +++ b/dbms/src/Storages/StorageMySQL.cpp @@ -1,6 +1,6 @@ -#include #if USE_MYSQL +#include #include #include #include diff --git a/dbms/src/Storages/StorageMySQL.h b/dbms/src/Storages/StorageMySQL.h index 9e2b233283e..597b6ce1037 100644 --- a/dbms/src/Storages/StorageMySQL.h +++ b/dbms/src/Storages/StorageMySQL.h @@ -1,7 +1,7 @@ #pragma once -#include #if USE_MYSQL +#include #include diff --git a/dbms/src/Storages/StorageODBC.cpp b/dbms/src/Storages/StorageODBC.cpp index 39b51d46047..803b948f986 100644 --- a/dbms/src/Storages/StorageODBC.cpp +++ b/dbms/src/Storages/StorageODBC.cpp @@ -1,3 +1,5 @@ +#if Poco_SQLODBC_FOUND || Poco_DataODBC_FOUND + #include #include #include @@ -80,3 +82,5 @@ void registerStorageODBC(StorageFactory & factory) } } + +#endif diff --git a/dbms/src/Storages/StorageODBC.h b/dbms/src/Storages/StorageODBC.h index 605d35b0202..4d0f43f35ae 100644 --- a/dbms/src/Storages/StorageODBC.h +++ b/dbms/src/Storages/StorageODBC.h @@ -1,4 +1,5 @@ #pragma once +#if Poco_SQLODBC_FOUND || Poco_DataODBC_FOUND #include #include @@ -47,3 +48,5 @@ class StorageODBC : public ext::shared_ptr_helper, public IStorage std::shared_ptr pool; }; } + +#endif diff --git a/dbms/src/TableFunctions/TableFunctionMySQL.cpp b/dbms/src/TableFunctions/TableFunctionMySQL.cpp index 1f7839ada86..773a9bcbc66 100644 --- a/dbms/src/TableFunctions/TableFunctionMySQL.cpp +++ b/dbms/src/TableFunctions/TableFunctionMySQL.cpp @@ -1,5 +1,5 @@ -#include #if USE_MYSQL +#include #include #include diff --git a/dbms/src/TableFunctions/TableFunctionMySQL.h b/dbms/src/TableFunctions/TableFunctionMySQL.h index 870b3f75624..89d476dce27 100644 --- a/dbms/src/TableFunctions/TableFunctionMySQL.h +++ b/dbms/src/TableFunctions/TableFunctionMySQL.h @@ -1,4 +1,5 @@ #pragma once +#if USE_MYSQL #include @@ -23,3 +24,5 @@ class TableFunctionMySQL : public ITableFunction }; } + +#endif diff --git a/dbms/src/TableFunctions/TableFunctionODBC.cpp b/dbms/src/TableFunctions/TableFunctionODBC.cpp index c9cb78479a9..b1ecec9c776 100644 --- a/dbms/src/TableFunctions/TableFunctionODBC.cpp +++ b/dbms/src/TableFunctions/TableFunctionODBC.cpp @@ -1,6 +1,6 @@ -#include #if Poco_SQLODBC_FOUND || Poco_DataODBC_FOUND +#include #include #include diff --git a/dbms/src/TableFunctions/TableFunctionODBC.h b/dbms/src/TableFunctions/TableFunctionODBC.h index eb06a8c5097..d44ac2c5b53 100644 --- a/dbms/src/TableFunctions/TableFunctionODBC.h +++ b/dbms/src/TableFunctions/TableFunctionODBC.h @@ -1,7 +1,7 @@ #pragma once -#include #if Poco_SQLODBC_FOUND || Poco_DataODBC_FOUND +#include #include diff --git a/release-centos7/build/build-tiflash-ci.sh b/release-centos7/build/build-tiflash-ci.sh index 59af130db11..9771fd08108 100755 --- a/release-centos7/build/build-tiflash-ci.sh +++ b/release-centos7/build/build-tiflash-ci.sh @@ -67,7 +67,8 @@ cmake "$SRCPATH" \ -DENABLE_EMBEDDED_COMPILER=$ENABLE_EMBEDDED_COMPILER \ -DENABLE_TESTS=$ENABLE_TEST \ -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -make -j $NPROC + +make -j $NPROC tiflash cp -f "$build_dir/dbms/src/Server/tiflash" "$install_dir/tiflash" cp -f "${SRCPATH}/libs/libtiflash-proxy/libtiflash_proxy.so" "$install_dir/libtiflash_proxy.so"