Skip to content

Commit

Permalink
Remove useless component to shorten the compile time (#1332)
Browse files Browse the repository at this point in the history
* Remove useless codes
* minimize build target
  • Loading branch information
JaySon-Huang authored Jan 4, 2021
1 parent 013bd6d commit da8458d
Show file tree
Hide file tree
Showing 22 changed files with 70 additions and 34 deletions.
52 changes: 32 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand All @@ -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")
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion dbms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})

Expand Down
2 changes: 1 addition & 1 deletion dbms/src/DataStreams/CapnProtoRowInputStream.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <Common/config.h>
#if USE_CAPNP
#include <Common/config.h>

#include <Common/escapeForFileName.h>
#include <IO/ReadBuffer.h>
Expand Down
2 changes: 1 addition & 1 deletion dbms/src/DataStreams/CapnProtoRowInputStream.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once
#include <Common/config.h>
#if USE_CAPNP
#include <Common/config.h>

#include <Core/Block.h>
#include <DataStreams/IRowInputStream.h>
Expand Down
2 changes: 1 addition & 1 deletion dbms/src/Dictionaries/Embedded/TechDataHierarchy.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <Common/config.h>
#if USE_MYSQL
#include <Common/config.h>

#include <Dictionaries/Embedded/TechDataHierarchy.h>

Expand Down
2 changes: 1 addition & 1 deletion dbms/src/Dictionaries/MongoDBBlockInputStream.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <Common/config.h>
#if Poco_MongoDB_FOUND
#include <Common/config.h>

#include <vector>
#include <string>
Expand Down
2 changes: 1 addition & 1 deletion dbms/src/Dictionaries/MongoDBDictionarySource.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <Common/config.h>
#if Poco_MongoDB_FOUND
#include <Common/config.h>
#include <Poco/Util/AbstractConfiguration.h>

#pragma GCC diagnostic push
Expand Down
2 changes: 1 addition & 1 deletion dbms/src/Dictionaries/MySQLBlockInputStream.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <Common/config.h>
#if USE_MYSQL
#include <Common/config.h>

#include <Dictionaries/MySQLBlockInputStream.h>
#include <Columns/ColumnsNumber.h>
Expand Down
2 changes: 1 addition & 1 deletion dbms/src/Dictionaries/MySQLDictionarySource.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <Common/config.h>
#if USE_MYSQL
#include <Common/config.h>

#include <IO/WriteBufferFromString.h>
#include <DataTypes/DataTypeString.h>
Expand Down
4 changes: 4 additions & 0 deletions dbms/src/Dictionaries/ODBCBlockInputStream.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#if Poco_SQLODBC_FOUND || Poco_DataODBC_FOUND

#include <Dictionaries/ODBCBlockInputStream.h>

#include <Columns/ColumnsNumber.h>
Expand Down Expand Up @@ -105,3 +107,5 @@ Block ODBCBlockInputStream::readImpl()
}

}

#endif
3 changes: 3 additions & 0 deletions dbms/src/Dictionaries/ODBCBlockInputStream.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once
#if Poco_SQLODBC_FOUND || Poco_DataODBC_FOUND

#include <Core/Block.h>
#include <DataStreams/IProfilingBlockInputStream.h>
Expand Down Expand Up @@ -44,3 +45,5 @@ class ODBCBlockInputStream final : public IProfilingBlockInputStream
};

}

#endif
4 changes: 4 additions & 0 deletions dbms/src/Dictionaries/ODBCDictionarySource.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#if Poco_SQLODBC_FOUND || Poco_DataODBC_FOUND

#include <DataTypes/DataTypeString.h>
#include <Columns/ColumnString.h>
#include <Poco/Ext/SessionPoolHelpers.h>
Expand Down Expand Up @@ -150,3 +152,5 @@ std::string ODBCDictionarySource::doInvalidateQuery(const std::string & request)
}

}

#endif
2 changes: 2 additions & 0 deletions dbms/src/Dictionaries/ODBCDictionarySource.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once
#if Poco_SQLODBC_FOUND || Poco_DataODBC_FOUND

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
Expand Down Expand Up @@ -77,3 +78,4 @@ class ODBCDictionarySource final : public IDictionarySource


}
#endif
2 changes: 1 addition & 1 deletion dbms/src/Storages/StorageMySQL.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <Storages/StorageMySQL.h>

#if USE_MYSQL
#include <Storages/StorageMySQL.h>
#include <Storages/StorageFactory.h>
#include <Storages/transformQueryForExternalDatabase.h>
#include <Dictionaries/MySQLBlockInputStream.h>
Expand Down
2 changes: 1 addition & 1 deletion dbms/src/Storages/StorageMySQL.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include <Common/config.h>
#if USE_MYSQL
#include <Common/config.h>

#include <ext/shared_ptr_helper.h>

Expand Down
4 changes: 4 additions & 0 deletions dbms/src/Storages/StorageODBC.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#if Poco_SQLODBC_FOUND || Poco_DataODBC_FOUND

#include <Poco/Ext/SessionPoolHelpers.h>
#include <Storages/transformQueryForExternalDatabase.h>
#include <Storages/StorageODBC.h>
Expand Down Expand Up @@ -80,3 +82,5 @@ void registerStorageODBC(StorageFactory & factory)
}

}

#endif
3 changes: 3 additions & 0 deletions dbms/src/Storages/StorageODBC.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once
#if Poco_SQLODBC_FOUND || Poco_DataODBC_FOUND

#include <ext/shared_ptr_helper.h>
#include <Storages/IStorage.h>
Expand Down Expand Up @@ -47,3 +48,5 @@ class StorageODBC : public ext::shared_ptr_helper<StorageODBC>, public IStorage
std::shared_ptr<Poco::Data::SessionPool> pool;
};
}

#endif
2 changes: 1 addition & 1 deletion dbms/src/TableFunctions/TableFunctionMySQL.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <Common/config.h>
#if USE_MYSQL
#include <Common/config.h>

#include <DataTypes/DataTypesNumber.h>
#include <DataTypes/DataTypeDate.h>
Expand Down
3 changes: 3 additions & 0 deletions dbms/src/TableFunctions/TableFunctionMySQL.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once
#if USE_MYSQL

#include <TableFunctions/ITableFunction.h>

Expand All @@ -23,3 +24,5 @@ class TableFunctionMySQL : public ITableFunction
};

}

#endif
2 changes: 1 addition & 1 deletion dbms/src/TableFunctions/TableFunctionODBC.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <TableFunctions/TableFunctionODBC.h>

#if Poco_SQLODBC_FOUND || Poco_DataODBC_FOUND
#include <TableFunctions/TableFunctionODBC.h>
#include <type_traits>
#include <ext/scope_guard.h>

Expand Down
2 changes: 1 addition & 1 deletion dbms/src/TableFunctions/TableFunctionODBC.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include <Common/config.h>
#if Poco_SQLODBC_FOUND || Poco_DataODBC_FOUND
#include <Common/config.h>

#include <TableFunctions/ITableFunction.h>

Expand Down
3 changes: 2 additions & 1 deletion release-centos7/build/build-tiflash-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit da8458d

Please sign in to comment.