- 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:
Chris Kleeschulte 2015-08-04 18:13:21 -04:00
parent 05d8cf521d
commit 6fe8bc7702
9 changed files with 47 additions and 36 deletions

View File

@ -12,5 +12,5 @@ script:
- _mocha -R spec --recursive - _mocha -R spec --recursive
cache: cache:
directories: directories:
- build - libbitcoind
- cache - cache

View File

@ -153,7 +153,7 @@ $ node index.js
## Static Library Patch ## 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. 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.

View File

@ -7,14 +7,8 @@ cd "${root_dir}"
debug= debug=
if test x"$1" = x'debug'; then if test x"$1" = x'debug'; then
debug=--debug debug=--debug
cached_file="${root_dir}"/build/Debug/bitcoind.node
else
cached_file="${root_dir}"/build/Release/bitcoind.node
fi fi
node-pre-gyp ${debug} rebuild --fallback-to-build
if [ ! -f "${cached_file}" ]; then
node-pre-gyp ${debug} rebuild --fallback-to-build
fi

View File

@ -1,10 +1,10 @@
#!/bin/bash #!/bin/bash
root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/.." root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/.."
options=`cat ${root_dir}/bin/config_options.sh` options=`cat ${root_dir}/bin/config_options.sh`
depends_dir=$($root_dir/variables.sh depends_dir) depends_dir=$($root_dir/bin/variables.sh depends_dir)
host=$(${root_dir}/variables.sh host) host=$(${root_dir}/bin/variables.sh host)
btc_dir="${root_dir}/libbitcoind" 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" export CPPFLAGS="-I${depends_dir}/${host}/include/boost -I${depends_dir}/${host}/include -L${depends_dir}/${host}/lib"
echo "Using BTC directory: ${btc_dir}" echo "Using BTC directory: ${btc_dir}"
@ -40,6 +40,22 @@ compare_patch () {
matching_patch=`diff -w /tmp/tmp.patch "${root_dir}/etc/bitcoin.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= debug=
if [ "${BITCORENODE_ENV}" == "debug" ]; then if [ "${BITCORENODE_ENV}" == "debug" ]; then
options=`cat ${root_dir}/bin/config_options_debug.sh` options=`cat ${root_dir}/bin/config_options_debug.sh`
@ -65,7 +81,7 @@ fi
if [ "${shared_file_built}" = false ]; then 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..." 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 if [ "${mac_response}" != "" ]; then
echo "${mac_response}" echo "${mac_response}"
exit -1 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 "Creating the sha marker for the patching in libbitcoind..."
echo "Writing patch sha file to: \"${patch_sha}\"" echo "Writing patch sha file to: \"${patch_sha}\""
echo -n `shasum -a 256 "${root_dir}"/etc/bitcoin.patch | awk '{print $1}'` > "${patch_sha}" echo -n `shasum -a 256 "${root_dir}"/etc/bitcoin.patch | awk '{print $1}'` > "${patch_sha}"
prepare_for_caching
echo 'Build finished successfully.' echo 'Build finished successfully.'
else else
echo 'Using existing shared library.' echo 'Using existing shared library.'

View File

@ -3,5 +3,5 @@
root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/.." root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/.."
cd "${root_dir}" cd "${root_dir}"
rm -fr libbitcoind make clean
node-pre-gyp clean node-pre-gyp clean

View File

@ -2,7 +2,7 @@
exec 2> /dev/null 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" BITCOIN_DIR="${root_dir}/libbitcoind"
host=`uname -m`-`uname -a | awk '{print tolower($1)}'` host=`uname -m`-`uname -a | awk '{print tolower($1)}'`

View File

@ -3,9 +3,9 @@
'target_name': "<(module_name)", 'target_name': "<(module_name)",
'include_dirs' : [ 'include_dirs' : [
'<!(node -e "require(\'nan\')")', '<!(node -e "require(\'nan\')")',
'<!(./variables.sh btcdir)/src', '<!(./bin/variables.sh btcdir)/src',
'<!(./variables.sh btcdir)/depends/<!(./variables.sh host)/include', '<!(./bin/variables.sh btcdir)/depends/<!(./bin/variables.sh host)/include',
'<!(./variables.sh btcdir)/src/leveldb/include' '<!(./bin/variables.sh btcdir)/src/leveldb/include'
], ],
'sources': [ 'sources': [
'./src/libbitcoind.cc', './src/libbitcoind.cc',
@ -27,21 +27,21 @@
], ],
'link_settings': { 'link_settings': {
'libraries': [ 'libraries': [
'<!(./variables.sh bitcoind)', '<!(./bin/variables.sh bitcoind)',
'<!(./variables.sh filesystem)', '<!(./bin/variables.sh filesystem)',
'<!(./variables.sh thread)', '<!(./bin/variables.sh thread)',
'<!(./variables.sh program_options)', '<!(./bin/variables.sh program_options)',
'<!(./variables.sh system)', '<!(./bin/variables.sh system)',
'<!(./variables.sh chrono)', '<!(./bin/variables.sh chrono)',
'<!(./variables.sh libsecp256k1)', '<!(./bin/variables.sh libsecp256k1)',
'<!(./variables.sh leveldb)', '<!(./bin/variables.sh leveldb)',
'<!(./variables.sh memenv)', '<!(./bin/variables.sh memenv)',
'<!(./variables.sh bdb)', '<!(./bin/variables.sh bdb)',
'-lssl', '-lssl',
'-lcrypto' '-lcrypto'
], ],
'ldflags': [ 'ldflags': [
'<!(./variables.sh load_archive)' '<!(./bin/variables.sh load_archive)'
] ]
} }
}, },

View File

@ -139,7 +139,7 @@ index e7aa48d..df0f7ae 100644
endef endef
diff --git a/src/Makefile.am b/src/Makefile.am diff --git a/src/Makefile.am b/src/Makefile.am
index 1c2f770..85db1d3 100644 index 1c2f770..5582b7e 100644
--- a/src/Makefile.am --- a/src/Makefile.am
+++ b/src/Makefile.am +++ b/src/Makefile.am
@@ -1,6 +1,12 @@ @@ -1,6 +1,12 @@
@ -203,7 +203,7 @@ index 1c2f770..85db1d3 100644
$(abs_top_srcdir) $(abs_top_srcdir)
-libbitcoin_util_a-clientversion.$(OBJEXT): obj/build.h -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 +libbitcoin_util_a-clientversion.$(OBJEXT): obj/build.h
+clientversion.cpp: obj/build.h +clientversion.cpp: obj/build.h

View File

@ -63,10 +63,10 @@
}, },
"bundledDependencies": ["node-pre-gyp"], "bundledDependencies": ["node-pre-gyp"],
"binary": { "binary": {
"module_name" : "bitcoind", "module_name" : "bitcoind",
"module_path" : "./build/{configuration}/{node_abi}-{platform}-{arch}/", "module_path" : "./build/{configuration}/{node_abi}-{platform}-{arch}/",
"remote_path" : "./{module_name}/v{version}/{configuration}/", "remote_path" : "./{module_name}/v{version}/{configuration}/",
"package_name": "{module_name}-v{version}-{node_abi}-{platform}-{arch}.tar.gz", "package_name": "{module_name}-v{version}-{node_abi}-{platform}-{arch}.tar.gz",
"host" : "https://bitcore-node.s3-us-west-2.amazonaws.com" "host" : "https://bitcore-node.s3-us-west-2.amazonaws.com"
} }
} }