From da71c0ff2ce7b764ddb99c55fa3438347bab31a7 Mon Sep 17 00:00:00 2001 From: Chris Kleeschulte Date: Tue, 4 Aug 2015 15:49:01 -0400 Subject: [PATCH] Clean up - Removed the platform directory - renamed the platform/os.sh script to varaibles.sh - realigned the calls to os.sh - changed where the patch_ha.txt was being written to - changed the name of the binary to bitcoind.node --- .gitignore | 2 +- .travis.yml | 1 + bin/build-bindings | 8 +++- bin/build-libbitcoind | 41 ++++++++------------ bin/clean | 2 - binding.gyp | 28 +++++++------- etc/bitcoin.patch | 4 +- etc/patch_sha.txt | 1 - package.json | 2 +- platform/arch/.gitignore | 0 platform/centos/.gitignore | 0 platform/debian/.gitignore | 0 platform/fedora/.gitignore | 0 platform/mandriva/.gitignore | 0 platform/mint/.gitignore | 0 platform/osx/.gitignore | 0 platform/rhel/.gitignore | 0 platform/solaris/.gitignore | 0 platform/suse/.gitignore | 0 platform/os.sh => variables.sh | 68 +++------------------------------- 20 files changed, 46 insertions(+), 111 deletions(-) delete mode 100644 etc/patch_sha.txt delete mode 100644 platform/arch/.gitignore delete mode 100644 platform/centos/.gitignore delete mode 100644 platform/debian/.gitignore delete mode 100644 platform/fedora/.gitignore delete mode 100644 platform/mandriva/.gitignore delete mode 100644 platform/mint/.gitignore delete mode 100644 platform/osx/.gitignore delete mode 100644 platform/rhel/.gitignore delete mode 100644 platform/solaris/.gitignore delete mode 100644 platform/suse/.gitignore rename platform/os.sh => variables.sh (62%) diff --git a/.gitignore b/.gitignore index 62a6633d..fa048b32 100644 --- a/.gitignore +++ b/.gitignore @@ -28,4 +28,4 @@ libbitcoind **/*.creator libbitcoind.includes *.log -platform/* +cache/patch_sha.txt diff --git a/.travis.yml b/.travis.yml index 4531b189..8cb338a2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,3 +13,4 @@ script: cache: directories: - build + - cache diff --git a/bin/build-bindings b/bin/build-bindings index 7b535542..941c526d 100755 --- a/bin/build-bindings +++ b/bin/build-bindings @@ -7,8 +7,14 @@ cd "${root_dir}" debug= if test x"$1" = x'debug'; then debug=--debug + cached_file="${root_dir}"/build/Debug/bitcoind.node +else + cached_file="${root_dir}"/build/Release/bitcoind.node fi -node-pre-gyp ${debug} rebuild --fallback-to-build + +if [ ! -f "${cached_file}" ]; then + node-pre-gyp ${debug} rebuild --fallback-to-build +fi diff --git a/bin/build-libbitcoind b/bin/build-libbitcoind index 27a4b8b3..ac72bbb3 100755 --- a/bin/build-libbitcoind +++ b/bin/build-libbitcoind @@ -1,13 +1,11 @@ #!/bin/bash root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/.." options=`cat ${root_dir}/bin/config_options.sh` -h_and_a_dir=$($root_dir/platform/os.sh h_and_a_dir) -depends_dir=$($root_dir/platform/os.sh depends_dir) -os_dir=$(${root_dir}/platform/os.sh osdir) -host=$(${root_dir}/platform/os.sh host) +depends_dir=$($root_dir/variables.sh depends_dir) +host=$(${root_dir}/variables.sh host) btc_dir="${root_dir}/libbitcoind" -ext=$($root_dir/platform/os.sh ext) -export CPPFLAGS="-I${h_and_a_dir}/include/boost -I${h_and_a_dir}/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include -L${h_and_a_dir}/lib" +patch_sha=$($root_dir/variables.sh patch_sha) +export CPPFLAGS="-I${depends_dir}/${host}/include/boost -I${depends_dir}/${host}/include -L${depends_dir}/${host}/lib" echo "Using BTC directory: ${btc_dir}" cd "${root_dir}" @@ -16,20 +14,10 @@ build_dependencies () { if [ -d "${btc_dir}" ]; then pushd "${depends_dir}" echo "using host for dependencies: ${host}" - boost_files_count=`find "${h_and_a_dir}"/lib -iname "libboost_*-mt.a" | wc -l | xargs` - db_files_count=`find "${h_and_a_dir}"/lib -iname "libdb*.a" | wc -l | xargs` - should_rebuild=false - if [[ "${boost_files_count}" -lt 5 || ( "${db_files_count}" -lt 1 && "${test}" = true ) ]]; then - should_rebuild=true - fi - if [ "${should_rebuild}" = true ]; then - if [ "${test}" = true ]; then - make HOST=${host} NO_QT=1 NO_UPNP=1 - else - make HOST=${host} NO_QT=1 NO_WALLET=1 NO_UPNP=1 - fi + if [ "${test}" = true ]; then + make HOST=${host} NO_QT=1 NO_UPNP=1 else - echo "Looks like libs are already built, so we won't rebuild them. Incidentally, we found: ${boost_files_count} boost libraries and: ${db_files_count} Berkeley DB libraries and you have test mode set to: ${test}" + make HOST=${host} NO_QT=1 NO_WALLET=1 NO_UPNP=1 fi popd fi @@ -64,18 +52,20 @@ if [ "${BITCORENODE_ENV}" == "test" ]; then fi patch_file_sha=$(shasum -a 256 "${root_dir}/etc/bitcoin.patch" | awk '{print $1}') -patch_sha="${root_dir}"/etc/patch_sha.txt last_patch_file_sha= if [ -e "${patch_sha}" ]; then + echo "Patch file sha exists, let's see if the patch has changed since last build..." last_patch_file_sha=$(cat "${patch_sha}") fi shared_file_built=false if [ "${last_patch_file_sha}" == "${patch_file_sha}" ]; then + echo "Patch file contents matches the sha from the patch file itself, so no reason to rebuild the bindings unless there are no prebuilt bindings." shared_file_built=true fi if [ "${shared_file_built}" = false ]; then - mac_response=$($root_dir/platform/os.sh mac_dependencies) + echo "Looks like the patch to bitcoin changed since last build -or- this is the first build, so rebuilding libbitcoind itself..." + mac_response=$($root_dir/variables.sh mac_dependencies) if [ "${mac_response}" != "" ]; then echo "${mac_response}" exit -1 @@ -98,7 +88,6 @@ apply the current patch from "${root_dir}"/etc/bitcoin.patch? (y/N): " fi if [[ "${input}" =~ ^y|^Y ]]; then repatch=true - rm -f "${os_dir}/libbitcoind.*" echo "Removing directory: \"${btc_dir}\" and starting over!" rm -fr "${btc_dir}" fi @@ -132,9 +121,9 @@ apply the current patch from "${root_dir}"/etc/bitcoin.patch? (y/N): " echo './autogen.sh' ./autogen.sh - boost_libdir="--with-boost-libdir=${h_and_a_dir}/lib" + boost_libdir="--with-boost-libdir=${depends_dir}/${host}/lib" - full_options="${options} ${boost_libdir} --prefix=${os_dir}" + full_options="${options} ${boost_libdir}" echo "running the configure script with the following options:\n :::[\"${full_options}\"]:::" ${full_options} @@ -142,9 +131,9 @@ apply the current patch from "${root_dir}"/etc/bitcoin.patch? (y/N): " make V=1 echo "Creating the sha marker for the patching in libbitcoind..." - echo -n `shasum -a 256 "${root_dir}"/etc/bitcoin.patch | awk '{print $1}'` > "${root_dir}"/etc/patch_sha.txt + echo "Writing patch sha file to: \"${patch_sha}\"" + echo -n `shasum -a 256 "${root_dir}"/etc/bitcoin.patch | awk '{print $1}'` > "${patch_sha}" echo 'Build finished successfully.' else echo 'Using existing shared library.' fi - diff --git a/bin/clean b/bin/clean index b4931f12..be22e8e6 100755 --- a/bin/clean +++ b/bin/clean @@ -1,9 +1,7 @@ #!/bin/bash root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/.." -os_dir=$(${root_dir}/platform/os.sh osdir) cd "${root_dir}" rm -fr libbitcoind -rm -fr "${os_dir}"/* node-pre-gyp clean diff --git a/binding.gyp b/binding.gyp index a76f9017..03b2d6b1 100755 --- a/binding.gyp +++ b/binding.gyp @@ -3,9 +3,9 @@ 'target_name': "<(module_name)", 'include_dirs' : [ ' /dev/null -root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/.." +root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" BITCOIN_DIR="${root_dir}/libbitcoind" -os= -ext=so host=`uname -m`-`uname -a | awk '{print tolower($1)}'` depends_dir="${BITCOIN_DIR}"/depends -h_and_a_dir="${depends_dir}"/"${host}" mac_response= check_mac_build_system () { @@ -24,44 +21,6 @@ check_mac_build_system () { fi } -if test -f /etc/centos-release \ - || grep -q 'CentOS' /etc/redhat-release \ - || rpm -q --queryformat '%{VERSION}' centos-release > /dev/null; then - os=centos -elif grep -q 'Fedora' /etc/system-release; then - os=fedora -elif test -f /etc/redhat_release \ - || test -f /etc/redhat-release; then - os=rhel -elif uname -a | grep -q '^Darwin'; then - os=osx - ext=dylib -elif test -f /etc/SuSE-release; then - os=suse -elif test -f /etc/mandrake-release \ - || test -f /etc/mandriva-release; then - os=mandriva -elif grep -q 'Linux Mint' /etc/issue; then - os=mint -elif grep -q 'Ubuntu' /etc/issue \ - || grep -q 'Ubuntu' /etc/lsb-release \ - || uname -v | grep -q 'Ubuntu'; then - os=ubuntu -elif test -f /etc/debian_version \ - || test -f /etc/debian-version; then - os=debian -elif grep -q 'Arch Linux' /etc/issue \ - || test -d /lib/systemd -a "$(readlink /usr/bin/vi)" = 'ex'; then - os=arch -elif test "$(uname -s)" = 'SunOS'; then - os=solaris -elif test "$(uname -s)" = 'AIX'; then - os=aix -elif test -d /system && test -d /data/data; then - os=android -fi - -os_dir=${root_dir}/platform/${os} thread="${BITCOIN_DIR}"/depends/"${host}"/lib/libboost_thread-mt.a filesystem="${BITCOIN_DIR}"/depends/"${host}"/lib/libboost_filesystem-mt.a @@ -72,28 +31,11 @@ leveldb="${BITCOIN_DIR}"/src/leveldb/libleveldb.a memenv="${BITCOIN_DIR}"/src/leveldb/libmemenv.a libsecp256k1="${BITCOIN_DIR}"/src/secp256k1/.libs/libsecp256k1.a -if test -z "$os" -o x"$os" = x'android' -o x"$os" = x'aix'; then - if test "$os" = 'android' -o "$os" = 'aix'; then - echo 'Android or AIX detected!' >& 2 - fi - echo 'OS not supported.' >& 2 - exit 1 -fi - -if test x"$1" = x'osdir'; then - echo -n "$(pwd)/platform/${os}" - exit 0 -fi - if test x"$1" = x'btcdir'; then echo -n "${BITCOIN_DIR}" exit 0 fi -if test -z "$1" -o x"$1" = x'ext'; then - echo -n "${ext}" -fi - if test -z "$1" -o x"$1" = x'thread'; then echo -n "${thread}" fi @@ -130,10 +72,6 @@ if test -z "$1" -o x"$1" = x'libsecp256k1'; then echo -n "${libsecp256k1}" fi -if test -z "$1" -o x"$1" = x'h_and_a_dir'; then - echo -n "${h_and_a_dir}" -fi - if test -z "$1" -o x"$1" = x'host'; then echo -n "${host}" fi @@ -144,6 +82,10 @@ if test -z "$1" -o x"$1" = x'bdb'; then fi fi +if test -z "$1" -o x"$1" = x'patch_sha'; then + echo -n "${root_dir}"/cache/patch_sha.txt +fi + if test -z "$1" -o x"$1" = x'load_archive'; then if [ "${os}" == "osx" ]; then echo -n "-Wl,-all_load -Wl,--no-undefined"