Skip to content

Commit e4df534

Browse files
committed
Merge #15382: util: add RunCommandParseJSON
31cf68a [util] add RunCommandParseJSON (Sjors Provoost) c17f54e [ci] use boost::process (Sjors Provoost) 32128ba [doc] include Doxygen comments for HAVE_BOOST_PROCESS (Sjors Provoost) 3c84d85 [build] msvc: add boost::process (Sjors Provoost) c47e4bb [build] make boost-process opt-in (Sjors Provoost) 929cda5 configure: add ax_boost_process (Sjors Provoost) 8314c23 [depends] boost: patch unused variable in boost_process (Sjors Provoost) Pull request description: Prerequisite for external signer support in #16546. Big picture overview in [this gist](https://gist.github.com/Sjors/29d06728c685e6182828c1ce9b74483d). This adds a new dependency [boost process](https://github.com/boostorg/process/tree/boost-1.64.0). This is part of Boost since 1.64 which is part of `depends`. Because the minimum Boost version is 1.47, this functionality is skipped for older versions of Boost. Use `./configure --with-boost-process` to opt in, which checks for the presence of Boost::Process. We add `UniValue runCommandParseJSON(const std::string& strCommand)` to `system.{h,cpp}` which calls an arbitrary command and processes the JSON returned by it. This is currently only called by the test suite. ~For testing purposes this adds a new regtest-only RPC method `runcommand`, as well as `test/mocks/command.py` used by functional tests.~ (this is no longer the case) TODO: - [ ] review boost process in #15440 ACKs for top commit: achow101: ACK 31cf68a hebasto: re-ACK 31cf68a, only rebased (verified with `git range-diff`) and removed an unintentional tab character since the [previous](bitcoin/bitcoin#15382 (review)) review. meshcollider: Very light utACK 31cf68a, although I am not very confident with build stuff. promag: Code review ACK 31cf68a, don't mind the nit. ryanofsky: Code review ACK 31cf68a. I left some comments below that could be ignored or followed up later. The current change is clean and comprehensive. Tree-SHA512: c506e747014b263606e1f538ed4624a8ad7bcf4e025cb700c12cc5739964e254dc04a2bbb848996b170e2ccec3fbfa4fe9e2b3976b191222cfb82fc3e6ab182d
2 parents 65e4eca + 31cf68a commit e4df534

24 files changed

+295
-15
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ jobs:
8080
QEMU_USER_CMD=""
8181
8282
- stage: test
83-
name: 'Win64 [GOAL: deploy] [unit tests, no gui, no functional tests]'
83+
name: 'Win64 [GOAL: deploy] [unit tests, no gui, no boost::process, no functional tests]'
8484
env: >-
8585
FILE_ENV="./ci/test/00_setup_env_win64.sh"
8686

build-aux/m4/ax_boost_process.m4

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# ===========================================================================
2+
# https://www.gnu.org/software/autoconf-archive/ax_boost_process.html
3+
# ===========================================================================
4+
#
5+
# SYNOPSIS
6+
#
7+
# AX_BOOST_PROCESS
8+
#
9+
# DESCRIPTION
10+
#
11+
# Test for Process library from the Boost C++ libraries. The macro
12+
# requires a preceding call to AX_BOOST_BASE. Further documentation is
13+
# available at <http://randspringer.de/boost/index.html>.
14+
#
15+
# This macro calls:
16+
#
17+
# AC_SUBST(BOOST_PROCESS_LIB)
18+
#
19+
# And sets:
20+
#
21+
# HAVE_BOOST_PROCESS
22+
#
23+
# LICENSE
24+
#
25+
# Copyright (c) 2008 Thomas Porschberg <[email protected]>
26+
# Copyright (c) 2008 Michael Tindal
27+
# Copyright (c) 2008 Daniel Casimiro <[email protected]>
28+
#
29+
# Copying and distribution of this file, with or without modification, are
30+
# permitted in any medium without royalty provided the copyright notice
31+
# and this notice are preserved. This file is offered as-is, without any
32+
# warranty.
33+
34+
#serial 2
35+
36+
AC_DEFUN([AX_BOOST_PROCESS],
37+
[
38+
AC_ARG_WITH([boost-process],
39+
AS_HELP_STRING([--with-boost-process@<:@=special-lib@:>@],
40+
[use the Process library from boost - it is possible to specify a certain library for the linker
41+
e.g. --with-boost-process=boost_process-gcc-mt ]),
42+
[
43+
if test "$withval" = "no"; then
44+
want_boost_process="no"
45+
elif test "$withval" = "yes"; then
46+
want_boost_process="yes"
47+
ax_boost_user_process_lib=""
48+
else
49+
want_boost_process="yes"
50+
ax_boost_user_process_lib="$withval"
51+
fi
52+
],
53+
[want_boost_process="yes"]
54+
)
55+
56+
if test "x$want_boost_process" = "xyes"; then
57+
AC_REQUIRE([AC_PROG_CC])
58+
AC_REQUIRE([AC_CANONICAL_BUILD])
59+
CPPFLAGS_SAVED="$CPPFLAGS"
60+
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
61+
export CPPFLAGS
62+
63+
LDFLAGS_SAVED="$LDFLAGS"
64+
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
65+
export LDFLAGS
66+
67+
AC_CACHE_CHECK(whether the Boost::Process library is available,
68+
ax_cv_boost_process,
69+
[AC_LANG_PUSH([C++])
70+
CXXFLAGS_SAVE=$CXXFLAGS
71+
CXXFLAGS=
72+
73+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <boost/process.hpp>]],
74+
[[boost::process::child* child = new boost::process::child; delete child;]])],
75+
ax_cv_boost_process=yes, ax_cv_boost_process=no)
76+
CXXFLAGS=$CXXFLAGS_SAVE
77+
AC_LANG_POP([C++])
78+
])
79+
if test "x$ax_cv_boost_process" = "xyes"; then
80+
AC_SUBST(BOOST_CPPFLAGS)
81+
82+
AC_DEFINE(HAVE_BOOST_PROCESS,,[define if the Boost::Process library is available])
83+
BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
84+
85+
LDFLAGS_SAVE=$LDFLAGS
86+
if test "x$ax_boost_user_process_lib" = "x"; then
87+
for libextension in `ls -r $BOOSTLIBDIR/libboost_process* 2>/dev/null | sed 's,.*/lib,,' | sed 's,\..*,,'` ; do
88+
ax_lib=${libextension}
89+
AC_CHECK_LIB($ax_lib, exit,
90+
[BOOST_PROCESS_LIB="-l$ax_lib"; AC_SUBST(BOOST_PROCESS_LIB) link_process="yes"; break],
91+
[link_process="no"])
92+
done
93+
if test "x$link_process" != "xyes"; then
94+
for libextension in `ls -r $BOOSTLIBDIR/boost_process* 2>/dev/null | sed 's,.*/,,' | sed -e 's,\..*,,'` ; do
95+
ax_lib=${libextension}
96+
AC_CHECK_LIB($ax_lib, exit,
97+
[BOOST_PROCESS_LIB="-l$ax_lib"; AC_SUBST(BOOST_PROCESS_LIB) link_process="yes"; break],
98+
[link_process="no"])
99+
done
100+
fi
101+
102+
else
103+
for ax_lib in $ax_boost_user_process_lib boost_process-$ax_boost_user_process_lib; do
104+
AC_CHECK_LIB($ax_lib, exit,
105+
[BOOST_PROCESS_LIB="-l$ax_lib"; AC_SUBST(BOOST_PROCESS_LIB) link_process="yes"; break],
106+
[link_process="no"])
107+
done
108+
109+
fi
110+
if test "x$ax_lib" = "x"; then
111+
AC_MSG_ERROR(Could not find a version of the Boost::Process library!)
112+
fi
113+
if test "x$link_process" = "xno"; then
114+
AC_MSG_ERROR(Could not link against $ax_lib !)
115+
fi
116+
fi
117+
118+
CPPFLAGS="$CPPFLAGS_SAVED"
119+
LDFLAGS="$LDFLAGS_SAVED"
120+
fi
121+
])

build_msvc/bitcoin_config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@
4747
/* define if the Boost::Filesystem library is available */
4848
#define HAVE_BOOST_FILESYSTEM /**/
4949

50+
/* define if the Boost::Process library is available */
51+
#define HAVE_BOOST_PROCESS /**/
52+
5053
/* define if the Boost::System library is available */
5154
#define HAVE_BOOST_SYSTEM /**/
5255

build_msvc/vcpkg-packages.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
berkeleydb boost-filesystem boost-multi-index boost-signals2 boost-test boost-thread libevent[thread] zeromq double-conversion
1+
berkeleydb boost-filesystem boost-multi-index boost-process boost-signals2 boost-test boost-thread libevent[thread] zeromq double-conversion

ci/test/00_setup_env_arm.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ export RUN_FUNCTIONAL_TESTS=true
2525
export GOAL="install"
2626
# -Wno-psabi is to disable ABI warnings: "note: parameter passing for argument of type ... changed in GCC 7.1"
2727
# This could be removed once the ABI change warning does not show up by default
28-
export BITCOIN_CONFIG="--enable-glibc-back-compat --enable-reduce-exports CXXFLAGS=-Wno-psabi --enable-werror"
28+
export BITCOIN_CONFIG="--enable-glibc-back-compat --enable-reduce-exports CXXFLAGS=-Wno-psabi --enable-werror --with-boost-process"

ci/test/00_setup_env_i686_centos.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ export CONTAINER_NAME=ci_i686_centos_7
1111
export DOCKER_NAME_TAG=centos:7
1212
export DOCKER_PACKAGES="gcc-c++ glibc-devel.x86_64 libstdc++-devel.x86_64 glibc-devel.i686 libstdc++-devel.i686 ccache libtool make git python3 python36-zmq which patch lbzip2 dash"
1313
export GOAL="install"
14-
export BITCOIN_CONFIG="--enable-zmq --with-gui=qt5 --enable-reduce-exports"
14+
export BITCOIN_CONFIG="--enable-zmq --with-gui=qt5 --enable-reduce-exports --with-boost-process"
1515
export CONFIG_SHELL="/bin/dash"

ci/test/00_setup_env_mac.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ export XCODE_BUILD_ID=11C505
1414
export RUN_UNIT_TESTS=false
1515
export RUN_FUNCTIONAL_TESTS=false
1616
export GOAL="deploy"
17-
export BITCOIN_CONFIG="--with-gui --enable-reduce-exports --enable-werror"
17+
export BITCOIN_CONFIG="--with-gui --enable-reduce-exports --enable-werror --with-boost-process"

ci/test/00_setup_env_mac_host.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export HOST=x86_64-apple-darwin16
1010
export DOCKER_NAME_TAG=ubuntu:18.04 # Check that bionic can cross-compile to macos (bionic is used in the gitian build as well)
1111
export PIP_PACKAGES="zmq"
1212
export GOAL="install"
13-
export BITCOIN_CONFIG="--with-gui --enable-reduce-exports --enable-werror"
13+
export BITCOIN_CONFIG="--with-gui --enable-reduce-exports --enable-werror --with-boost-process"
1414
export NO_DEPENDS=1
1515
export OSX_SDK=""
1616
export CCACHE_SIZE=300M

ci/test/00_setup_env_native_asan.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ export DOCKER_NAME_TAG=ubuntu:20.04
1212
export NO_DEPENDS=1
1313
export TEST_RUNNER_EXTRA="--timeout-factor=4" # Increase timeout because sanitizers slow down
1414
export GOAL="install"
15-
export BITCOIN_CONFIG="--enable-zmq --with-incompatible-bdb --with-gui=qt5 CPPFLAGS='-DARENA_DEBUG -DDEBUG_LOCKORDER' --with-sanitizers=address,integer,undefined CC=clang CXX=clang++"
15+
export BITCOIN_CONFIG="--enable-zmq --with-incompatible-bdb --with-gui=qt5 CPPFLAGS='-DARENA_DEBUG -DDEBUG_LOCKORDER' --with-sanitizers=address,integer,undefined CC=clang CXX=clang++ --with-boost-process"

ci/test/00_setup_env_native_fuzz.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ export RUN_UNIT_TESTS=false
1414
export RUN_FUNCTIONAL_TESTS=false
1515
export RUN_FUZZ_TESTS=true
1616
export GOAL="install"
17-
export BITCOIN_CONFIG="--enable-fuzz --with-sanitizers=fuzzer,address,undefined CC=clang CXX=clang++"
17+
export BITCOIN_CONFIG="--enable-fuzz --with-sanitizers=fuzzer,address,undefined CC=clang CXX=clang++ --with-boost-process"
1818
export CCACHE_SIZE=200M

0 commit comments

Comments
 (0)