- put variables.sh in bin/
- fixed wording and description in README.md - make clean in libbitcoind for clean script - changed references to variables.sh
This commit is contained in:
parent
05d8cf521d
commit
6fe8bc7702
|
@ -12,5 +12,5 @@ script:
|
|||
- _mocha -R spec --recursive
|
||||
cache:
|
||||
directories:
|
||||
- build
|
||||
- libbitcoind
|
||||
- cache
|
||||
|
|
|
@ -153,7 +153,7 @@ $ node index.js
|
|||
|
||||
## Static Library Patch
|
||||
|
||||
To provide native bindings to JavaScript *(or any other language for that matter)*, Bitcoin code, itself, must be linkable. Currently, Bitcoin Core provides a JSON RPC interface to bitcoind as well as a shared library for script validation *(and hopefully more)* called libbitcoinconsensus. There is a node module, [node-libbitcoinconsensus](https://github.com/bitpay/node-libbitcoinconsensus), that exposes these methods. While these interfaces are useful for several use cases, there are additional use cases that are not fulfilled, and being able to implement customized interfaces is necessary. To be able to do this a few simple changes need to be made to Bitcoin Core to compile as a shared library.
|
||||
To provide native bindings to JavaScript *(or any other language for that matter)*, Bitcoin code, itself, must be linkable. Currently, Bitcoin Core provides a JSON RPC interface to bitcoind as well as a shared library for script validation *(and hopefully more)* called libbitcoinconsensus. There is a node module, [node-libbitcoinconsensus](https://github.com/bitpay/node-libbitcoinconsensus), that exposes these methods. While these interfaces are useful for several use cases, there are additional use cases that are not fulfilled, and being able to implement customized interfaces is necessary. To be able to do this a few simple changes need to be made to Bitcoin Core to compile as a static library.
|
||||
|
||||
The patch is located at `etc/bitcoin.patch` and adds a configure option `--enable-daemonlib` to compile all object files with `-fPIC` (Position Independent Code - needed to create a shared object), exposes leveldb variables and objects, exposes the threadpool to the bindings, and conditionally includes the main function.
|
||||
|
||||
|
|
|
@ -7,14 +7,8 @@ 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
|
||||
|
||||
|
||||
if [ ! -f "${cached_file}" ]; then
|
||||
node-pre-gyp ${debug} rebuild --fallback-to-build
|
||||
fi
|
||||
node-pre-gyp ${debug} rebuild --fallback-to-build
|
||||
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#!/bin/bash
|
||||
root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/.."
|
||||
options=`cat ${root_dir}/bin/config_options.sh`
|
||||
depends_dir=$($root_dir/variables.sh depends_dir)
|
||||
host=$(${root_dir}/variables.sh host)
|
||||
depends_dir=$($root_dir/bin/variables.sh depends_dir)
|
||||
host=$(${root_dir}/bin/variables.sh host)
|
||||
btc_dir="${root_dir}/libbitcoind"
|
||||
patch_sha=$($root_dir/variables.sh patch_sha)
|
||||
patch_sha=$($root_dir/bin/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}"
|
||||
|
||||
|
@ -40,6 +40,22 @@ compare_patch () {
|
|||
matching_patch=`diff -w /tmp/tmp.patch "${root_dir}/etc/bitcoin.patch"`
|
||||
}
|
||||
|
||||
prepare_for_caching () {
|
||||
cp -r $("${root_dir}"/bin/variables.sh bitcoind) /tmp/bitcoind.tmp
|
||||
cp -r $("${root_dir}"/bin/variables.sh libsecp256k1) /tmp/libsecp256k1.tmp
|
||||
cp -r $("${root_dir}"/bin/variables.sh memenv) /tmp/libmemenv.tmp
|
||||
cp -r $("${root_dir}"/bin/variables.sh leveldb) /tmp/leveldb.tmp
|
||||
pushd "${btc_dir}"
|
||||
make clean
|
||||
mkdir -p "${btc_dir}"/src/.libs
|
||||
mkdir -p "${btc_dir}"/src/secp256k1/.libs
|
||||
cp -r /tmp/bitcoind.tmp $("${root_dir}"/bin/variables.sh bitcoind)
|
||||
cp -r /tmp/libsecp256k1.tmp $("${root_dir}"/bin/variables.sh libsecp256k1)
|
||||
cp -r /tmp/libmemenv.tmp $("${root_dir}"/bin/variables.sh memenv)
|
||||
cp -r /tmp/leveldb.tmp $("${root_dir}"/bin/variables.sh leveldb)
|
||||
popd
|
||||
}
|
||||
|
||||
debug=
|
||||
if [ "${BITCORENODE_ENV}" == "debug" ]; then
|
||||
options=`cat ${root_dir}/bin/config_options_debug.sh`
|
||||
|
@ -65,7 +81,7 @@ fi
|
|||
|
||||
if [ "${shared_file_built}" = false ]; then
|
||||
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)
|
||||
mac_response=$($root_dir/bin/variables.sh mac_dependencies)
|
||||
if [ "${mac_response}" != "" ]; then
|
||||
echo "${mac_response}"
|
||||
exit -1
|
||||
|
@ -133,6 +149,7 @@ apply the current patch from "${root_dir}"/etc/bitcoin.patch? (y/N): "
|
|||
echo "Creating the sha marker for the patching in libbitcoind..."
|
||||
echo "Writing patch sha file to: \"${patch_sha}\""
|
||||
echo -n `shasum -a 256 "${root_dir}"/etc/bitcoin.patch | awk '{print $1}'` > "${patch_sha}"
|
||||
prepare_for_caching
|
||||
echo 'Build finished successfully.'
|
||||
else
|
||||
echo 'Using existing shared library.'
|
||||
|
|
|
@ -3,5 +3,5 @@
|
|||
root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/.."
|
||||
cd "${root_dir}"
|
||||
|
||||
rm -fr libbitcoind
|
||||
make clean
|
||||
node-pre-gyp clean
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
exec 2> /dev/null
|
||||
|
||||
root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/.."
|
||||
BITCOIN_DIR="${root_dir}/libbitcoind"
|
||||
|
||||
host=`uname -m`-`uname -a | awk '{print tolower($1)}'`
|
28
binding.gyp
28
binding.gyp
|
@ -3,9 +3,9 @@
|
|||
'target_name': "<(module_name)",
|
||||
'include_dirs' : [
|
||||
'<!(node -e "require(\'nan\')")',
|
||||
'<!(./variables.sh btcdir)/src',
|
||||
'<!(./variables.sh btcdir)/depends/<!(./variables.sh host)/include',
|
||||
'<!(./variables.sh btcdir)/src/leveldb/include'
|
||||
'<!(./bin/variables.sh btcdir)/src',
|
||||
'<!(./bin/variables.sh btcdir)/depends/<!(./bin/variables.sh host)/include',
|
||||
'<!(./bin/variables.sh btcdir)/src/leveldb/include'
|
||||
],
|
||||
'sources': [
|
||||
'./src/libbitcoind.cc',
|
||||
|
@ -27,21 +27,21 @@
|
|||
],
|
||||
'link_settings': {
|
||||
'libraries': [
|
||||
'<!(./variables.sh bitcoind)',
|
||||
'<!(./variables.sh filesystem)',
|
||||
'<!(./variables.sh thread)',
|
||||
'<!(./variables.sh program_options)',
|
||||
'<!(./variables.sh system)',
|
||||
'<!(./variables.sh chrono)',
|
||||
'<!(./variables.sh libsecp256k1)',
|
||||
'<!(./variables.sh leveldb)',
|
||||
'<!(./variables.sh memenv)',
|
||||
'<!(./variables.sh bdb)',
|
||||
'<!(./bin/variables.sh bitcoind)',
|
||||
'<!(./bin/variables.sh filesystem)',
|
||||
'<!(./bin/variables.sh thread)',
|
||||
'<!(./bin/variables.sh program_options)',
|
||||
'<!(./bin/variables.sh system)',
|
||||
'<!(./bin/variables.sh chrono)',
|
||||
'<!(./bin/variables.sh libsecp256k1)',
|
||||
'<!(./bin/variables.sh leveldb)',
|
||||
'<!(./bin/variables.sh memenv)',
|
||||
'<!(./bin/variables.sh bdb)',
|
||||
'-lssl',
|
||||
'-lcrypto'
|
||||
],
|
||||
'ldflags': [
|
||||
'<!(./variables.sh load_archive)'
|
||||
'<!(./bin/variables.sh load_archive)'
|
||||
]
|
||||
}
|
||||
},
|
||||
|
|
|
@ -139,7 +139,7 @@ index e7aa48d..df0f7ae 100644
|
|||
endef
|
||||
|
||||
diff --git a/src/Makefile.am b/src/Makefile.am
|
||||
index 1c2f770..85db1d3 100644
|
||||
index 1c2f770..5582b7e 100644
|
||||
--- a/src/Makefile.am
|
||||
+++ b/src/Makefile.am
|
||||
@@ -1,6 +1,12 @@
|
||||
|
@ -203,7 +203,7 @@ index 1c2f770..85db1d3 100644
|
|||
$(abs_top_srcdir)
|
||||
-libbitcoin_util_a-clientversion.$(OBJEXT): obj/build.h
|
||||
|
||||
+ARCH_PLATFORM = $(shell ../../variables.sh host)
|
||||
+ARCH_PLATFORM = $(shell ../../bin/variables.sh host)
|
||||
+
|
||||
+libbitcoin_util_a-clientversion.$(OBJEXT): obj/build.h
|
||||
+clientversion.cpp: obj/build.h
|
||||
|
|
10
package.json
10
package.json
|
@ -63,10 +63,10 @@
|
|||
},
|
||||
"bundledDependencies": ["node-pre-gyp"],
|
||||
"binary": {
|
||||
"module_name" : "bitcoind",
|
||||
"module_path" : "./build/{configuration}/{node_abi}-{platform}-{arch}/",
|
||||
"remote_path" : "./{module_name}/v{version}/{configuration}/",
|
||||
"package_name": "{module_name}-v{version}-{node_abi}-{platform}-{arch}.tar.gz",
|
||||
"host" : "https://bitcore-node.s3-us-west-2.amazonaws.com"
|
||||
"module_name" : "bitcoind",
|
||||
"module_path" : "./build/{configuration}/{node_abi}-{platform}-{arch}/",
|
||||
"remote_path" : "./{module_name}/v{version}/{configuration}/",
|
||||
"package_name": "{module_name}-v{version}-{node_abi}-{platform}-{arch}.tar.gz",
|
||||
"host" : "https://bitcore-node.s3-us-west-2.amazonaws.com"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue