Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Merge pull request #9125 from EOSIO/unity-build
Browse files Browse the repository at this point in the history
Add unity build support for some targets
  • Loading branch information
huangminghuang authored Jun 1, 2020
2 parents c873818 + f2ed1d5 commit a8c169f
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .cicd/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -eo pipefail
. ./.cicd/helpers/general.sh
mkdir -p $BUILD_DIR
CMAKE_EXTRAS="-DCMAKE_BUILD_TYPE='Release' -DENABLE_MULTIVERSION_PROTOCOL_TEST=true"
CMAKE_EXTRAS="-DCMAKE_BUILD_TYPE='Release' -DENABLE_MULTIVERSION_PROTOCOL_TEST=true -DENABLE_UNITY_BUILD=ON"
if [[ "$(uname)" == 'Darwin' && $FORCE_LINUX != true ]]; then
# You can't use chained commands in execute
if [[ "$GITHUB_ACTIONS" == 'true' ]]; then
Expand Down
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ if ("${CMAKE_GENERATOR}" STREQUAL "Ninja")
add_compile_options(-fdiagnostics-color=always)
endif()

set(CMAKE_EXPORT_COMPILE_COMMANDS "ON")
if (ENABLE_UNITY_BUILD)
set(CMAKE_EXPORT_COMPILE_COMMANDS "OFF")
else()
set(CMAKE_EXPORT_COMPILE_COMMANDS "ON")
endif()

set(BUILD_DOXYGEN FALSE CACHE BOOL "Build doxygen documentation on every make")
set(ENABLE_MULTIVERSION_PROTOCOL_TEST FALSE CACHE BOOL "Enable nodeos multiversion protocol test")

Expand Down
4 changes: 4 additions & 0 deletions libraries/chain/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ target_include_directories( eosio_chain
add_library(eosio_chain_wrap INTERFACE )
target_link_libraries(eosio_chain_wrap INTERFACE eosio_chain)

if(ENABLE_UNITY_BUILD)
set_target_properties(eosio_chain PROPERTIES UNITY_BUILD TRUE)
endif()

if("eos-vm-oc" IN_LIST EOSIO_WASM_RUNTIMES)
target_link_libraries(eosio_chain_wrap INTERFACE "-Wl,-wrap=main")
endif()
Expand Down
4 changes: 4 additions & 0 deletions libraries/chainbase/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ add_library( chainbase src/chainbase.cpp src/pinnable_mapped_file.cpp ${HEADERS}
target_link_libraries( chainbase Boost::filesystem ${PLATFORM_LIBRARIES} )
target_include_directories( chainbase PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )

if(ENABLE_UNITY_BUILD)
set_target_properties(chainbase PROPERTIES UNITY_BUILD TRUE)
endif()

if(WIN32)
target_link_libraries( chainbase ws2_32 mswsock )
endif()
Expand Down
5 changes: 5 additions & 0 deletions libraries/fc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ list(APPEND sources ${fc_headers})

setup_library( fc SOURCES ${sources} LIBRARY_TYPE STATIC DONT_INSTALL_LIBRARY )

if(ENABLE_UNITY_BUILD)
set_target_properties(fc PROPERTIES UNITY_BUILD TRUE)
endif()


function(detect_thread_name)
include(CheckSymbolExists)
list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
Expand Down
3 changes: 2 additions & 1 deletion libraries/fc/src/crypto/elliptic_secp256k1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,11 @@ namespace fc { namespace ecc {
}

static const public_key_data empty_pub;
static const private_key_secret empty_priv;


fc::sha512 private_key::get_shared_secret( const public_key& other )const
{
static const private_key_secret empty_priv;
FC_ASSERT( my->_key != empty_priv );
FC_ASSERT( other.my->_key != empty_pub );
public_key_data pub(other.my->_key);
Expand Down
4 changes: 2 additions & 2 deletions libraries/fc/src/crypto/private_key.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ namespace fc { namespace crypto {
return Data(fc::variant(key_bytes).as<typename Data::data_type>());
}

static private_key::storage_type parse_base58(const string& base58str)
static private_key::storage_type priv_parse_base58(const string& base58str)
{
const auto pivot = base58str.find('_');

Expand All @@ -108,7 +108,7 @@ namespace fc { namespace crypto {
}

private_key::private_key(const std::string& base58str)
:_storage(parse_base58(base58str))
:_storage(priv_parse_base58(base58str))
{}

std::string private_key::to_string(const fc::yield_function_t& yield) const
Expand Down
4 changes: 2 additions & 2 deletions libraries/fc/src/crypto/signature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace fc { namespace crypto {
}
};

static signature::storage_type parse_base58(const std::string& base58str)
static signature::storage_type sig_parse_base58(const std::string& base58str)
{ try {
constexpr auto prefix = config::signature_base_prefix;

Expand All @@ -32,7 +32,7 @@ namespace fc { namespace crypto {
} FC_RETHROW_EXCEPTIONS( warn, "error parsing signature", ("str", base58str ) ) }

signature::signature(const std::string& base58str)
:_storage(parse_base58(base58str))
:_storage(sig_parse_base58(base58str))
{}

int signature::which() const {
Expand Down
4 changes: 4 additions & 0 deletions libraries/rodeos/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ target_link_libraries( rodeos_lib
target_include_directories( rodeos_lib
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include"
)

if(ENABLE_UNITY_BUILD)
set_target_properties(rodeos_lib PROPERTIES UNITY_BUILD TRUE)
endif()
1 change: 1 addition & 0 deletions libraries/rodeos/include/b1/rodeos/rodeos.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pragma once
#include <b1/chain_kv/chain_kv.hpp>
#include <b1/rodeos/filter.hpp>
#include <b1/rodeos/wasm_ql.hpp>
Expand Down
4 changes: 4 additions & 0 deletions libraries/state_history/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ target_link_libraries( state_history
target_include_directories( state_history
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include"
)

if(ENABLE_UNITY_BUILD)
set_target_properties(state_history PROPERTIES UNITY_BUILD TRUE)
endif()
2 changes: 1 addition & 1 deletion libraries/state_history/trace_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <eosio/state_history/compression.hpp>
#include <eosio/state_history/serialization.hpp>
#include <eosio/state_history/trace_converter.hpp>
extern const char* state_history_plugin_abi;
extern const char* const state_history_plugin_abi;

namespace bio = boost::iostreams;
namespace eosio {
Expand Down

0 comments on commit a8c169f

Please sign in to comment.