binding.gyp work.
This commit is contained in:
parent
551e84de65
commit
7525208b01
12
README.md
12
README.md
@ -22,6 +22,16 @@ bitcoind as a shared object. This may not be ideal yet.
|
|||||||
|
|
||||||
#### Compiling bticoind as a library
|
#### Compiling bticoind as a library
|
||||||
|
|
||||||
|
##### Dependencies
|
||||||
|
|
||||||
|
- Boost
|
||||||
|
- Bost Header Files (`/usr/include/boost`)
|
||||||
|
|
||||||
|
- Berkeley DB
|
||||||
|
|
||||||
|
- LevelDB Header Files (included in bitcoin source repo, leveldb itself
|
||||||
|
unnecessary, libbitcoind.so is already linked to them)
|
||||||
|
|
||||||
``` bash
|
``` bash
|
||||||
# ensure clean up
|
# ensure clean up
|
||||||
$ make clean
|
$ make clean
|
||||||
@ -63,7 +73,7 @@ Without `--enable-library`, the Makefile with compile bitcoind with -fPIE
|
|||||||
|
|
||||||
``` bash
|
``` bash
|
||||||
$ cd ~/work/node_modules/bitcoind.js
|
$ cd ~/work/node_modules/bitcoind.js
|
||||||
$ PYTHON=/usr/bin/python2.7 make gyp
|
$ BITCOIN_DIR=~/bitcoin PYTHON=/usr/bin/python2.7 make
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Running bitcoind.js
|
#### Running bitcoind.js
|
||||||
|
|||||||
24
binding.gyp
24
binding.gyp
@ -2,17 +2,23 @@
|
|||||||
'targets': [{
|
'targets': [{
|
||||||
'target_name': 'bitcoindjs',
|
'target_name': 'bitcoindjs',
|
||||||
'include_dirs' : [
|
'include_dirs' : [
|
||||||
'/usr/include',
|
# standard include:
|
||||||
|
# '/usr/include',
|
||||||
'<!(node -e "require(\'nan\')")',
|
'<!(node -e "require(\'nan\')")',
|
||||||
'/usr/include/boost',
|
# '/usr/include/boost',
|
||||||
'<!(echo "$HOME")/bitcoin/src/leveldb/include',
|
'<!(test -n "$BITCOIN_DIR" && echo "$BITCOIN_DIR" || echo "${HOME}/bitcoin")/src/leveldb/include',
|
||||||
'<!(echo "$HOME")/bitcoin/src',
|
'<!(test -n "$BITCOIN_DIR" && echo "$BITCOIN_DIR" || echo "${HOME}/bitcoin")/src',
|
||||||
],
|
],
|
||||||
'sources': [
|
'sources': [
|
||||||
'./src/bitcoindjs.cc',
|
'./src/bitcoindjs.cc',
|
||||||
],
|
],
|
||||||
'defines': [
|
'defines': [
|
||||||
'HAVE_WORKING_BOOST_SLEEP',
|
'<!(test $(grep "#define BOOST_VERSION " /usr/include/boost/version.hpp'\
|
||||||
|
' | awk "{ print \$3 }") -gt 105200'\
|
||||||
|
' && echo HAVE_WORKING_BOOST_SLEEP_FOR'\
|
||||||
|
' || echo HAVE_WORKING_BOOST_SLEEP)',
|
||||||
|
# Assume libbitcoind.so is always
|
||||||
|
# compiled with wallet support.
|
||||||
'ENABLE_WALLET',
|
'ENABLE_WALLET',
|
||||||
],
|
],
|
||||||
'cflags_cc': [
|
'cflags_cc': [
|
||||||
@ -21,18 +27,16 @@
|
|||||||
],
|
],
|
||||||
'libraries': [
|
'libraries': [
|
||||||
# standard libs:
|
# standard libs:
|
||||||
'-L/usr/lib',
|
# '-L/usr/lib',
|
||||||
'-L/usr/local/lib',
|
# '-L/usr/local/lib',
|
||||||
# boost:
|
# boost:
|
||||||
'-lboost_system',
|
'-lboost_system',
|
||||||
'-lboost_filesystem',
|
'-lboost_filesystem',
|
||||||
'-lboost_program_options',
|
'-lboost_program_options',
|
||||||
'-lboost_thread',
|
'-lboost_thread',
|
||||||
'-lboost_chrono',
|
'-lboost_chrono',
|
||||||
# leveldb:
|
|
||||||
#'<!(echo "$HOME")/bitcoin/src/leveldb/libleveldb.a',
|
|
||||||
# bitcoind:
|
# bitcoind:
|
||||||
'<!(echo "$HOME")/bitcoin/src/libbitcoind.so',
|
'<!(test -n "$BITCOIN_DIR" && echo "$BITCOIN_DIR" || echo "${HOME}/bitcoin")/src/libbitcoind.so',
|
||||||
]
|
]
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
|
|||||||
91
binding_work.gyp
Normal file
91
binding_work.gyp
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
{
|
||||||
|
'targets': [{
|
||||||
|
'target_name': 'bitcoindjs',
|
||||||
|
'include_dirs' : [
|
||||||
|
# standard include:
|
||||||
|
# '/usr/include',
|
||||||
|
'<!(node -e "require(\'nan\')")',
|
||||||
|
'/usr/include/boost',
|
||||||
|
'<!(test -n "$BITCOIN_DIR" && echo "$BITCOIN_DIR" || echo "${HOME}/bitcoin")/src/leveldb/include',
|
||||||
|
'<!(test -n "$BITCOIN_DIR" && echo "$BITCOIN_DIR" || echo "${HOME}/bitcoin")/src',
|
||||||
|
],
|
||||||
|
# 'includes': [
|
||||||
|
# './include.gypi',
|
||||||
|
# ],
|
||||||
|
# 'variables': {
|
||||||
|
# 'BOOST_VERSION': '<!(grep "#define BOOST_VERSION " /usr/include/boost/version.hpp | awk "{ print \$3 }")',
|
||||||
|
# 'BOOST_HAS_NANOSLEEP': '0',
|
||||||
|
# },
|
||||||
|
'conditions': [
|
||||||
|
['OS=="linux"', {
|
||||||
|
'variables': {
|
||||||
|
'BOOST_VERSION': '<!(grep "#define BOOST_VERSION " /usr/include/boost/version.hpp | awk "{ print \$3 }")',
|
||||||
|
'BOOST_HAS_NANOSLEEP': '<!(grep -q "#define \+BOOST_HAS_NANOSLEEP" /usr/include/boost/config/platform/linux.hpp && echo 1 || echo 0)',
|
||||||
|
},
|
||||||
|
}],
|
||||||
|
['OS=="darwin"', {
|
||||||
|
'variables': {
|
||||||
|
'BOOST_VERSION': '<!(grep "#define BOOST_VERSION " /usr/include/boost/version.hpp | awk "{ print \$3 }")',
|
||||||
|
'BOOST_HAS_NANOSLEEP': '<!(grep -q "#define \+BOOST_HAS_NANOSLEEP" /usr/include/boost/config/platform/macos.hpp && echo 1 || echo 0)',
|
||||||
|
},
|
||||||
|
}],
|
||||||
|
['OS!="linux" && OS!="darwin"', {
|
||||||
|
'variables': {
|
||||||
|
'BOOST_VERSION': '<!(grep "#define BOOST_VERSION " /usr/include/boost/version.hpp | awk "{ print \$3 }")',
|
||||||
|
'BOOST_HAS_NANOSLEEP': '0',
|
||||||
|
},
|
||||||
|
}],
|
||||||
|
['BOOST_VERSION>=105000 && (BOOST_HAS_NANOSLEEP==0 || BOOST_VERSION>=105200)', {
|
||||||
|
'variables': {
|
||||||
|
'BOOST_SLEEP': 'HAVE_WORKING_BOOST_SLEEP_FOR',
|
||||||
|
},
|
||||||
|
#'defines': [
|
||||||
|
# 'HAVE_WORKING_BOOST_SLEEP_FOR',
|
||||||
|
# # Assume libbitcoind.so is always
|
||||||
|
# # compiled with wallet support.
|
||||||
|
# 'ENABLE_WALLET',
|
||||||
|
#],
|
||||||
|
}, { # !(BOOST_VERSION>=105000) ...
|
||||||
|
'variables': {
|
||||||
|
'BOOST_SLEEP': 'HAVE_WORKING_BOOST_SLEEP',
|
||||||
|
},
|
||||||
|
#'defines': [
|
||||||
|
# 'HAVE_WORKING_BOOST_SLEEP',
|
||||||
|
# # Assume libbitcoind.so is always
|
||||||
|
# # compiled with wallet support.
|
||||||
|
# 'ENABLE_WALLET',
|
||||||
|
#],
|
||||||
|
}],
|
||||||
|
],
|
||||||
|
'sources': [
|
||||||
|
'./src/bitcoindjs.cc',
|
||||||
|
],
|
||||||
|
'defines': [
|
||||||
|
# TODO: Figure out how to detect BOOST_SLEEP in gyp.
|
||||||
|
# 'HAVE_WORKING_BOOST_SLEEP',
|
||||||
|
'<(BOOST_SLEEP)',
|
||||||
|
# Assume libbitcoind.so is always
|
||||||
|
# compiled with wallet support.
|
||||||
|
'ENABLE_WALLET',
|
||||||
|
],
|
||||||
|
'conditions': [
|
||||||
|
],
|
||||||
|
'cflags_cc': [
|
||||||
|
'-fexceptions',
|
||||||
|
'-frtti',
|
||||||
|
],
|
||||||
|
'libraries': [
|
||||||
|
# standard libs:
|
||||||
|
# '-L/usr/lib',
|
||||||
|
# '-L/usr/local/lib',
|
||||||
|
# boost:
|
||||||
|
'-lboost_system',
|
||||||
|
'-lboost_filesystem',
|
||||||
|
'-lboost_program_options',
|
||||||
|
'-lboost_thread',
|
||||||
|
'-lboost_chrono',
|
||||||
|
# bitcoind:
|
||||||
|
'<!(test -n "$BITCOIN_DIR" && echo "$BITCOIN_DIR" || echo "${HOME}/bitcoin")/src/libbitcoind.so',
|
||||||
|
]
|
||||||
|
}]
|
||||||
|
}
|
||||||
66
binding_work2.gyp
Normal file
66
binding_work2.gyp
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
{
|
||||||
|
'targets': [{
|
||||||
|
'target_name': 'bitcoindjs',
|
||||||
|
'include_dirs' : [
|
||||||
|
# standard include:
|
||||||
|
# '/usr/include',
|
||||||
|
'<!(node -e "require(\'nan\')")',
|
||||||
|
'/usr/include/boost',
|
||||||
|
'<!(test -n "$BITCOIN_DIR" && echo "$BITCOIN_DIR" || echo "${HOME}/bitcoin")/src/leveldb/include',
|
||||||
|
'<!(test -n "$BITCOIN_DIR" && echo "$BITCOIN_DIR" || echo "${HOME}/bitcoin")/src',
|
||||||
|
],
|
||||||
|
'variables': {
|
||||||
|
'BOOST_VERSION': '<!(grep "#define BOOST_VERSION " /usr/include/boost/version.hpp | awk "{ print \$3 }")',
|
||||||
|
'BOOST_HAS_NANOSLEEP': '0',
|
||||||
|
},
|
||||||
|
'conditions': [
|
||||||
|
['OS=="linux"', {
|
||||||
|
'variables': {
|
||||||
|
'BOOST_VERSION': '<!(grep "#define BOOST_VERSION " /usr/include/boost/version.hpp | awk "{ print \$3 }")',
|
||||||
|
'BOOST_HAS_NANOSLEEP': '<!(grep -q "#define \+BOOST_HAS_NANOSLEEP" /usr/include/boost/config/platform/linux.hpp && echo 1 || echo 0)',
|
||||||
|
},
|
||||||
|
}],
|
||||||
|
['OS=="darwin"', {
|
||||||
|
'variables': {
|
||||||
|
'BOOST_VERSION': '<!(grep "#define BOOST_VERSION " /usr/include/boost/version.hpp | awk "{ print \$3 }")',
|
||||||
|
'BOOST_HAS_NANOSLEEP': '<!(grep -q "#define \+BOOST_HAS_NANOSLEEP" /usr/include/boost/config/platform/macos.hpp && echo 1 || echo 0)',
|
||||||
|
},
|
||||||
|
}],
|
||||||
|
['BOOST_VERSION >= 105000 && (BOOST_HAS_NANOSLEEP == 0 || BOOST_VERSION >= 105200)', {
|
||||||
|
'defines': [
|
||||||
|
'HAVE_WORKING_BOOST_SLEEP_FOR',
|
||||||
|
],
|
||||||
|
}, { # !(BOOST_VERSION>=105000) ...
|
||||||
|
'defines': [
|
||||||
|
'HAVE_WORKING_BOOST_SLEEP',
|
||||||
|
],
|
||||||
|
}],
|
||||||
|
],
|
||||||
|
'sources': [
|
||||||
|
'./src/bitcoindjs.cc',
|
||||||
|
],
|
||||||
|
'defines': [
|
||||||
|
# Assume libbitcoind.so is always
|
||||||
|
# compiled with wallet support.
|
||||||
|
'<!(test $(grep "#define BOOST_VERSION " /usr/include/boost/version.hpp | awk "{ print \$3 }") -gt 105200 && echo HAVE_WORKING_BOOST_SLEEP_FOR || echo HAVE_WORKING_BOOST_SLEEP)',
|
||||||
|
'ENABLE_WALLET',
|
||||||
|
],
|
||||||
|
'cflags_cc': [
|
||||||
|
'-fexceptions',
|
||||||
|
'-frtti',
|
||||||
|
],
|
||||||
|
'libraries': [
|
||||||
|
# standard libs:
|
||||||
|
# '-L/usr/lib',
|
||||||
|
# '-L/usr/local/lib',
|
||||||
|
# boost:
|
||||||
|
'-lboost_system',
|
||||||
|
'-lboost_filesystem',
|
||||||
|
'-lboost_program_options',
|
||||||
|
'-lboost_thread',
|
||||||
|
'-lboost_chrono',
|
||||||
|
# bitcoind:
|
||||||
|
'<!(test -n "$BITCOIN_DIR" && echo "$BITCOIN_DIR" || echo "${HOME}/bitcoin")/src/libbitcoind.so',
|
||||||
|
]
|
||||||
|
}]
|
||||||
|
}
|
||||||
66
binding_work3.gyp
Normal file
66
binding_work3.gyp
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
{
|
||||||
|
'targets': [{
|
||||||
|
'target_name': 'bitcoindjs',
|
||||||
|
'include_dirs' : [
|
||||||
|
# standard include:
|
||||||
|
# '/usr/include',
|
||||||
|
'<!(node -e "require(\'nan\')")',
|
||||||
|
'/usr/include/boost',
|
||||||
|
'<!(test -n "$BITCOIN_DIR" && echo "$BITCOIN_DIR" || echo "${HOME}/bitcoin")/src/leveldb/include',
|
||||||
|
'<!(test -n "$BITCOIN_DIR" && echo "$BITCOIN_DIR" || echo "${HOME}/bitcoin")/src',
|
||||||
|
],
|
||||||
|
'variables': {
|
||||||
|
'BOOST_VERSION': '<!(grep "#define BOOST_VERSION " /usr/include/boost/version.hpp | awk "{ print \$3 }")',
|
||||||
|
'BOOST_HAS_NANOSLEEP': '0',
|
||||||
|
},
|
||||||
|
'conditions': [
|
||||||
|
['OS=="linux"', {
|
||||||
|
'variables': {
|
||||||
|
'BOOST_VERSION': '<!(grep "#define BOOST_VERSION " /usr/include/boost/version.hpp | awk "{ print \$3 }")',
|
||||||
|
'BOOST_HAS_NANOSLEEP': '<!(grep -q "#define \+BOOST_HAS_NANOSLEEP" /usr/include/boost/config/platform/linux.hpp && echo 1 || echo 0)',
|
||||||
|
},
|
||||||
|
}],
|
||||||
|
['OS=="darwin"', {
|
||||||
|
'variables': {
|
||||||
|
'BOOST_VERSION': '<!(grep "#define BOOST_VERSION " /usr/include/boost/version.hpp | awk "{ print \$3 }")',
|
||||||
|
'BOOST_HAS_NANOSLEEP': '<!(grep -q "#define \+BOOST_HAS_NANOSLEEP" /usr/include/boost/config/platform/macos.hpp && echo 1 || echo 0)',
|
||||||
|
},
|
||||||
|
}],
|
||||||
|
['BOOST_VERSION >= 105000 && (BOOST_HAS_NANOSLEEP == 0 || BOOST_VERSION >= 105200)', {
|
||||||
|
'defines': [
|
||||||
|
'HAVE_WORKING_BOOST_SLEEP_FOR',
|
||||||
|
],
|
||||||
|
}, { # !(BOOST_VERSION>=105000) ...
|
||||||
|
'defines': [
|
||||||
|
'HAVE_WORKING_BOOST_SLEEP',
|
||||||
|
],
|
||||||
|
}],
|
||||||
|
],
|
||||||
|
'sources': [
|
||||||
|
'./src/bitcoindjs.cc',
|
||||||
|
],
|
||||||
|
'defines': [
|
||||||
|
'<!(test $(grep "#define BOOST_VERSION " /usr/include/boost/version.hpp | awk "{ print \$3 }") -gt 105200 && echo HAVE_WORKING_BOOST_SLEEP_FOR || echo HAVE_WORKING_BOOST_SLEEP)',
|
||||||
|
# Assume libbitcoind.so is always
|
||||||
|
# compiled with wallet support.
|
||||||
|
'ENABLE_WALLET',
|
||||||
|
],
|
||||||
|
'cflags_cc': [
|
||||||
|
'-fexceptions',
|
||||||
|
'-frtti',
|
||||||
|
],
|
||||||
|
'libraries': [
|
||||||
|
# standard libs:
|
||||||
|
# '-L/usr/lib',
|
||||||
|
# '-L/usr/local/lib',
|
||||||
|
# boost:
|
||||||
|
'-lboost_system',
|
||||||
|
'-lboost_filesystem',
|
||||||
|
'-lboost_program_options',
|
||||||
|
'-lboost_thread',
|
||||||
|
'-lboost_chrono',
|
||||||
|
# bitcoind:
|
||||||
|
'<!(test -n "$BITCOIN_DIR" && echo "$BITCOIN_DIR" || echo "${HOME}/bitcoin")/src/libbitcoind.so',
|
||||||
|
]
|
||||||
|
}]
|
||||||
|
}
|
||||||
@ -79,6 +79,7 @@ extern void (DetectShutdownThread)(boost::thread_group*);
|
|||||||
extern void (StartNode)(boost::thread_group&);
|
extern void (StartNode)(boost::thread_group&);
|
||||||
extern void (ThreadScriptCheck)();
|
extern void (ThreadScriptCheck)();
|
||||||
extern void (StartShutdown)();
|
extern void (StartShutdown)();
|
||||||
|
extern bool (AppInit2)(boost::thread_group&);
|
||||||
extern int nScriptCheckThreads;
|
extern int nScriptCheckThreads;
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
extern std::string strWalletFile;
|
extern std::string strWalletFile;
|
||||||
@ -287,15 +288,16 @@ start_node(void) {
|
|||||||
detectShutdownThread = new boost::thread(
|
detectShutdownThread = new boost::thread(
|
||||||
boost::bind(&DetectShutdownThread, &threadGroup));
|
boost::bind(&DetectShutdownThread, &threadGroup));
|
||||||
|
|
||||||
int _nScriptCheckThreads = 0;
|
for (int i = 0; i < nScriptCheckThreads - 1; i++) {
|
||||||
for (int i = 0; i < _nScriptCheckThreads - 1; i++) {
|
|
||||||
threadGroup.create_thread(&ThreadScriptCheck);
|
threadGroup.create_thread(&ThreadScriptCheck);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<boost::filesystem::path> vImportFiles;
|
std::vector<boost::filesystem::path> vImportFiles;
|
||||||
threadGroup.create_thread(boost::bind(&ThreadImport, vImportFiles));
|
threadGroup.create_thread(boost::bind(&ThreadImport, vImportFiles));
|
||||||
|
|
||||||
StartNode(threadGroup);
|
// StartNode(threadGroup);
|
||||||
|
|
||||||
|
AppInit2(threadGroup);
|
||||||
|
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
if (pwalletMain) {
|
if (pwalletMain) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user