Skip to content

Commit

Permalink
init release-4.25-gm
Browse files Browse the repository at this point in the history
  • Loading branch information
HaoXuan40404 committed Dec 30, 2018
1 parent 59dbf8f commit f658140
Show file tree
Hide file tree
Showing 7 changed files with 533 additions and 2 deletions.
10 changes: 10 additions & 0 deletions cmake/EthOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ macro(configure_project)

# features
eth_default_option(PROFILING OFF)
if (BUILD_GM)
add_definitions(-DFISCO_GM)
endif()

# guomi
eth_default_option(BUILD_GM OFF)

# components
eth_default_option(TESTS ON)
Expand All @@ -29,6 +35,10 @@ macro(print_config NAME)
message("--------------------------------------------------------------- features")
message("-- PROFILING Profiling support ${PROFILING}")
message("------------------------------------------------------------- components")
if (BUILD_GM)
message("-- BUILD_GM BUILD GM ${BUILD_GM}")
message("------------------------------------------------------------------------")
endif()
if (SUPPORT_TESTS)
message("-- TESTS Build tests ${TESTS}")
endif()
Expand Down
94 changes: 94 additions & 0 deletions cmake/ProjectBoost.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
include(ExternalProject)
include(GNUInstallDirs)

set(BOOST_CXXFLAGS "")
if (WIN32)
set(BOOST_BOOTSTRAP_COMMAND bootstrap.bat)
set(BOOST_BUILD_TOOL b2.exe)
set(BOOST_LIBRARY_SUFFIX -vc140-mt-1_63.lib)
else()
set(BOOST_BOOTSTRAP_COMMAND ./bootstrap.sh)
set(BOOST_BUILD_TOOL ./b2)
set(BOOST_LIBRARY_SUFFIX .a)
if (${BUILD_SHARED_LIBS})
set(BOOST_CXXFLAGS "cxxflags=-fPIC")
endif()
endif()

#set(BOOST_CXXFLAGS "cxxflags=-Wa,-march=generic64")
set(BOOST_CXXFLAGS "cxxflags=-fPIC")

ExternalProject_Add(boost
PREFIX ${CMAKE_SOURCE_DIR}/deps
DOWNLOAD_NO_PROGRESS 1
URL https://github.com/ethereum/cpp-dependencies/releases/download/cache/boost_1_63_0.tar.gz
URL_HASH SHA256=fe34a4e119798e10b8cc9e565b3b0284e9fd3977ec8a1b19586ad1dec397088b
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND ${BOOST_BOOTSTRAP_COMMAND}
LOG_CONFIGURE 1
BUILD_COMMAND ${BOOST_BUILD_TOOL} stage
${BOOST_CXXFLAGS}
threading=multi
link=static
variant=release
address-model=64
--with-thread
--with-date_time
--with-system
--with-regex
--with-chrono
--with-filesystem
--with-program_options
--with-random
LOG_BUILD 1
INSTALL_COMMAND ""
)

ExternalProject_Get_Property(boost SOURCE_DIR)
set(Boost_INCLUDE_DIRS ${SOURCE_DIR})
set(Boost_LIBRARIES ${SOURCE_DIR}/stage/lib)
unset(BUILD_DIR)

add_library(Boost::Chrono STATIC IMPORTED)
set_property(TARGET Boost::Chrono PROPERTY IMPORTED_LOCATION ${Boost_LIBRARIES}/libboost_chrono${BOOST_LIBRARY_SUFFIX})
add_dependencies(Boost::Chrono boost)

add_library(Boost::DataTime STATIC IMPORTED)
set_property(TARGET Boost::DataTime PROPERTY IMPORTED_LOCATION ${Boost_LIBRARIES}/libboost_date_time${BOOST_LIBRARY_SUFFIX})
add_dependencies(Boost::DataTime boost)

add_library(Boost::Regex STATIC IMPORTED)
set_property(TARGET Boost::Regex PROPERTY IMPORTED_LOCATION ${Boost_LIBRARIES}/libboost_regex${BOOST_LIBRARY_SUFFIX})
add_dependencies(Boost::Regex boost)

add_library(Boost::System STATIC IMPORTED)
set_property(TARGET Boost::System PROPERTY IMPORTED_LOCATION ${Boost_LIBRARIES}/libboost_system${BOOST_LIBRARY_SUFFIX})
add_dependencies(Boost::System boost)

add_library(Boost::Filesystem STATIC IMPORTED)
set_property(TARGET Boost::Filesystem PROPERTY IMPORTED_LOCATION ${Boost_LIBRARIES}/libboost_filesystem${BOOST_LIBRARY_SUFFIX})
set_property(TARGET Boost::Filesystem PROPERTY INTERFACE_LINK_LIBRARIES Boost::System)
add_dependencies(Boost::Filesystem boost)

add_library(Boost::Random STATIC IMPORTED)
set_property(TARGET Boost::Random PROPERTY IMPORTED_LOCATION ${Boost_LIBRARIES}/libboost_random${BOOST_LIBRARY_SUFFIX})
add_dependencies(Boost::Random boost)

add_library(Boost::ProgramOptions STATIC IMPORTED)
set_property(TARGET Boost::ProgramOptions PROPERTY IMPORTED_LOCATION ${Boost_LIBRARIES}/libboost_program_options${BOOST_LIBRARY_SUFFIX})
add_dependencies(Boost::ProgramOptions boost)

add_library(Boost::UnitTestFramework STATIC IMPORTED)
set_property(TARGET Boost::UnitTestFramework PROPERTY IMPORTED_LOCATION ${Boost_LIBRARIES}/libboost_unit_test_framework${BOOST_LIBRARY_SUFFIX})
add_dependencies(Boost::UnitTestFramework boost)

add_library(Boost::Thread STATIC IMPORTED)
set_property(TARGET Boost::Thread PROPERTY IMPORTED_LOCATION ${Boost_LIBRARIES}/libboost_thread${BOOST_LIBRARY_SUFFIX})
set_property(TARGET Boost::Thread PROPERTY INTERFACE_LINK_LIBRARIES Boost::Chrono Boost::DataTime Boost::Regex)
add_dependencies(Boost::Thread boost)

set(Boost_FILESYSTEM_LIBRARIES Boost::Filesystem)
set(Boost_REGEX_LIBRARIES Boost::Regex)
set(Boost_SYSTEM_LIBRARIES Boost::System)
set(CMAKE_THREAD_LIBS_INIT Boost::Thread)
set(Boost_PROGRAM_OPTIONS_LIBRARIES Boost::ProgramOptions)
33 changes: 31 additions & 2 deletions libdevcore/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,35 @@
file(GLOB sources "*.cpp")
file(GLOB headers "*.h")

if(BUILD_GM)
set(sources
CommonData.cpp
CommonIO.cpp
Exceptions.cpp
IndentedWriter.cpp
JSON.cpp
GmHash.cpp
StringUtils.cpp
SwarmHash.cpp
UTF8.cpp
Whiskers.cpp
)
else()
set(sources
CommonData.cpp
CommonIO.cpp
Exceptions.cpp
IndentedWriter.cpp
JSON.cpp
SHA3.cpp
StringUtils.cpp
SwarmHash.cpp
UTF8.cpp
Whiskers.cpp
)
endif()
if(BUILD_GM)
aux_source_directory(./sm3 sources)
include_directories(./sm3)
endif()
add_library(devcore ${sources} ${headers})
target_link_libraries(devcore PRIVATE jsoncpp ${Boost_FILESYSTEM_LIBRARIES} ${Boost_REGEX_LIBRARIES} ${Boost_SYSTEM_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
target_include_directories(devcore PUBLIC "${CMAKE_SOURCE_DIR}")
Expand Down
52 changes: 52 additions & 0 deletions libdevcore/GmHash.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
This file is part of FISCO-BCOS.
FISCO-BCOS is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
FISCO-BCOS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with FISCO-BCOS. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file GmHash.cpp
* @author asherli
* @date 2018
*/

#include <libdevcore/SHA3.h>

#include "sm3/sm3.h"
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;
using namespace dev;

namespace dev {

// add SM3
bool sha3(bytesConstRef _input, bytesRef o_output) {
if (o_output.size() != 32)
return false;

SM3((unsigned char *)_input.data(), _input.size(),
(unsigned char *)o_output.data());
return true;
}

bool keccak256(bytesConstRef _input, bytesRef o_output) {
if (o_output.size() != 32)
return false;
SM3((unsigned char *)_input.data(), _input.size(), (unsigned char *)o_output.data());
return true;
}

} // namespace dev
Loading

0 comments on commit f658140

Please sign in to comment.