Skip to content

Commit

Permalink
Changes made to enable Microsoft Windows build
Browse files Browse the repository at this point in the history
  • Loading branch information
Cube committed Jul 6, 2016
1 parent 0ea6049 commit f239252
Show file tree
Hide file tree
Showing 10 changed files with 108 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ if( WIN32 )
set(CRYPTO_LIB)

if( MSVC )

add_compile_options(/wd4503 /wd4267 /wd4244)
#looks like this flag can have different default on some machines.
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO")
Expand Down
16 changes: 13 additions & 3 deletions libraries/chain/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
file(GLOB HEADERS "include/steemit/chain/*.hpp")

add_custom_target( build_hardfork_hpp
COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/../../programs/build_helpers/cat_parts.py" "${CMAKE_CURRENT_SOURCE_DIR}/hardfork.d" "${CMAKE_CURRENT_BINARY_DIR}/include/steemit/chain/hardfork.hpp" )
if( MSVC )
set( hardfork_hpp_file "${CMAKE_CURRENT_SOURCE_DIR}/include/steemit/chain/hardfork.hpp" )
add_custom_target( build_hardfork_hpp
COMMAND cat-parts "${CMAKE_CURRENT_SOURCE_DIR}/hardfork.d" ${hardfork_hpp_file} )
add_dependencies( build_hardfork_hpp cat-parts )
else( MSVC )
set( hardfork_hpp_file "${CMAKE_CURRENT_BINARY_DIR}/include/steemit/chain/hardfork.hpp" )
add_custom_target( build_hardfork_hpp
COMMAND "${CMAKE_SOURCE_DIR}/programs/build_helpers/cat_parts.py" "${CMAKE_CURRENT_SOURCE_DIR}/hardfork.d" ${hardfork_hpp_file} )
endif( MSVC )


set_source_files_properties( "${CMAKE_CURRENT_BINARY_DIR}/include/steemit/chain/hardfork.hpp" PROPERTIES GENERATED TRUE )

## SORT .cpp by most likely to change / break compile
Expand Down Expand Up @@ -30,7 +40,7 @@ add_library( steemit_chain
block_database.cpp

${HEADERS}
"${CMAKE_CURRENT_BINARY_DIR}/include/steemit/chain/hardfork.hpp"
${hardfork_hpp_file}
)

add_dependencies( steemit_chain build_hardfork_hpp )
Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1938,7 +1938,7 @@ void database::update_account_activity( const account_object& account ) {
auto delta_time = std::min( fc::days(1), now - account.last_active );
auto shares = fc::uint128( delta_time.to_seconds() ) * account.vesting_shares.amount.value;

if( shares == 0 ) return;
if (shares == fc::uint128(0)) return;

modify( account, [&]( account_object& a ) {
a.last_active = now;
Expand Down
5 changes: 3 additions & 2 deletions libraries/chain/protocol/authority.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ bool is_valid_account_name( const string& name )

void authority::validate()const
{
for( auto item : account_auths )
FC_ASSERT( is_valid_account_name( item.first ) );
for (auto item : account_auths) {
FC_ASSERT(is_valid_account_name(item.first));
}
}

} } // steemit::chain
2 changes: 2 additions & 0 deletions libraries/plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# for each subdirectory containing a CMakeLists.txt, add that subdirectory

file( GLOB children RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} * )
set( ENV{STEEMIT_EXTERNAL_PLUGINS} "" )
set( ENV{STEEMIT_INTERNAL_PLUGINS} "" )
foreach( child ${children} )
if( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${child}" )
if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${child}/CMakeLists.txt" )
Expand Down
2 changes: 1 addition & 1 deletion libraries/plugins/market_history/market_history_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class market_history_plugin_impl
void update_market_histories( const operation_object& b );

market_history_plugin& _self;
flat_set<uint32_t> _tracked_buckets = { 15, 60, 300, 3600, 86400 };
flat_set<uint32_t> _tracked_buckets = flat_set<uint32_t> { 15, 60, 300, 3600, 86400 };
int32_t _maximum_history_per_bucket_size = 1000;
};

Expand Down
2 changes: 1 addition & 1 deletion libraries/plugins/witness/witness.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ block_production_condition::block_production_condition_enum witness_plugin::mayb
* and how long it will take to broadcast the work. In other words, we assume 0.5s broadcast times
* and therefore do not even attempt work that cannot be delivered on time.
*/
void witness_plugin::on_applied_block( const chain::signed_block& b )
void witness_plugin::on_applied_block(const steemit::chain::signed_block& b)
{ try {
if( !_mining_threads || _miners.size() == 0 ) return;
chain::database& db = database();
Expand Down
1 change: 1 addition & 0 deletions programs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
add_subdirectory( build_helpers )
add_subdirectory( cli_wallet )
add_subdirectory( steemd )
#add_subdirectory( delayed_node )
Expand Down
8 changes: 8 additions & 0 deletions programs/build_helpers/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

add_executable( cat-parts cat-parts.cpp )
if( UNIX AND NOT APPLE )
set(rt_library rt )
endif()

# we only actually need Boost, but link against FC for now so we don't duplicate it.
target_link_libraries( cat-parts PRIVATE fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} )
77 changes: 77 additions & 0 deletions programs/build_helpers/cat-parts.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@

#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>

#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>

int main( int argc, char** argv, char** envp )
{
if( argc != 3 )
{
std::cerr << "syntax: cat-parts DIR OUTFILE" << std::endl;
return 1;
}

boost::filesystem::path p(argv[1]);

try
{
std::vector< boost::filesystem::path > v;

for( boost::filesystem::directory_iterator it(p);
it != boost::filesystem::directory_iterator();
++it )
{
boost::filesystem::path pit = it->path();
std::string spit = pit.generic_string();
size_t n = spit.length();
if( n <= 3 )
continue;
if( spit.substr(n-3, 3) != ".hf" )
continue;
v.push_back( pit );
}
std::sort( v.begin(), v.end() );

// open each file and grab its contents, concatenating into single stringstream
std::stringstream ss_data;
for( const boost::filesystem::path& p : v )
{
boost::filesystem::ifstream ifs(p);
ss_data << ifs.rdbuf();
}
std::string new_data = ss_data.str();

boost::filesystem::path opath(argv[2]);

if( boost::filesystem::exists( opath ) )
{
boost::filesystem::ifstream ifs(opath);
std::stringstream ss_old_data;
ss_old_data << ifs.rdbuf();
std::string old_data = ss_old_data.str();
if( old_data == new_data )
{
std::cerr << "File " << opath << " up-to-date with .d directory" << std::endl;
return 0;
}
}

{
boost::filesystem::ofstream ofs(opath);
ofs.write( new_data.c_str(), new_data.length() );
}

std::cerr << "Built " << opath << " from .d directory" << std::endl;
}
catch( const boost::filesystem::filesystem_error& e )
{
std::cout << e.what() << std::endl;
return 1;
}
return 0;
}

0 comments on commit f239252

Please sign in to comment.