Skip to content

Commit 2dc5ab6

Browse files
committed
Merge #13482: Remove boost::program_options dependency
f447a0a Remove program options from build system (Chun Kuan Lee) 11588c6 Replace boost program_options (Chun Kuan Lee) Pull request description: Concept from #12744, but without parsing negated options. Tree-SHA512: 7f418744bb8934e313d77a5f162633746ef5d043de802b9c9cd9f7c1842e7e566eb5f171cd9e2cc13317281b2449c6fbd553fa4f09b837e6af2f5d2b2aabdca2
2 parents dcc0cff + f447a0a commit 2dc5ab6

File tree

7 files changed

+42
-123
lines changed

7 files changed

+42
-123
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ env:
3636
# x86_64 Linux (uses qt5 dev package instead of depends Qt to speed up build and avoid timeout)
3737
- HOST=x86_64-unknown-linux-gnu PACKAGES="python3-zmq qtbase5-dev qttools5-dev-tools protobuf-compiler libdbus-1-dev libharfbuzz-dev libprotobuf-dev" DEP_OPTS="NO_QT=1 NO_UPNP=1 DEBUG=1 ALLOW_HOST_PACKAGES=1" RUN_TESTS=true GOAL="install" BITCOIN_CONFIG="--enable-zmq --with-gui=qt5 --enable-glibc-back-compat --enable-reduce-exports --enable-debug"
3838
# x86_64 Linux (Qt5 & system libs)
39-
- HOST=x86_64-unknown-linux-gnu PACKAGES="python3-zmq qtbase5-dev qttools5-dev-tools libssl1.0-dev libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-program-options-dev libboost-test-dev libboost-thread-dev libdb5.3++-dev libminiupnpc-dev libzmq3-dev libprotobuf-dev protobuf-compiler libqrencode-dev" NO_DEPENDS=1 RUN_TESTS=true GOAL="install" BITCOIN_CONFIG="--enable-zmq --with-incompatible-bdb --enable-glibc-back-compat --enable-reduce-exports --with-gui=qt5 CPPFLAGS=-DDEBUG_LOCKORDER"
39+
- HOST=x86_64-unknown-linux-gnu PACKAGES="python3-zmq qtbase5-dev qttools5-dev-tools libssl1.0-dev libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev libdb5.3++-dev libminiupnpc-dev libzmq3-dev libprotobuf-dev protobuf-compiler libqrencode-dev" NO_DEPENDS=1 RUN_TESTS=true GOAL="install" BITCOIN_CONFIG="--enable-zmq --with-incompatible-bdb --enable-glibc-back-compat --enable-reduce-exports --with-gui=qt5 CPPFLAGS=-DDEBUG_LOCKORDER"
4040
# x86_64 Linux, No wallet
4141
- HOST=x86_64-unknown-linux-gnu PACKAGES="python3" DEP_OPTS="NO_WALLET=1" RUN_TESTS=true GOAL="install" BITCOIN_CONFIG="--enable-glibc-back-compat --enable-reduce-exports"
4242
# Cross-Mac

build-aux/m4/ax_boost_program_options.m4

Lines changed: 0 additions & 108 deletions
This file was deleted.

configure.ac

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,6 @@ if test x$want_boost = xno; then
893893
fi
894894
AX_BOOST_SYSTEM
895895
AX_BOOST_FILESYSTEM
896-
AX_BOOST_PROGRAM_OPTIONS
897896
AX_BOOST_THREAD
898897
AX_BOOST_CHRONO
899898

@@ -962,7 +961,7 @@ fi
962961

963962
if test x$use_boost = xyes; then
964963

965-
BOOST_LIBS="$BOOST_LDFLAGS $BOOST_SYSTEM_LIB $BOOST_FILESYSTEM_LIB $BOOST_PROGRAM_OPTIONS_LIB $BOOST_THREAD_LIB $BOOST_CHRONO_LIB"
964+
BOOST_LIBS="$BOOST_LDFLAGS $BOOST_SYSTEM_LIB $BOOST_FILESYSTEM_LIB $BOOST_THREAD_LIB $BOOST_CHRONO_LIB"
966965

967966

968967
dnl If boost (prior to 1.57) was built without c++11, it emulated scoped enums

depends/packages/boost.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ $(package)_toolset_$(host_os)=gcc
1919
$(package)_archiver_$(host_os)=$($(package)_ar)
2020
$(package)_toolset_darwin=darwin
2121
$(package)_archiver_darwin=$($(package)_libtool)
22-
$(package)_config_libraries=chrono,filesystem,program_options,system,thread,test
22+
$(package)_config_libraries=chrono,filesystem,system,thread,test
2323
$(package)_cxxflags=-std=c++11 -fvisibility=hidden
2424
$(package)_cxxflags_linux=-fPIC
2525
endef

doc/build-unix.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ tuned to conserve memory with additional CXXFLAGS:
7070

7171
Build requirements:
7272

73-
sudo apt-get install build-essential libtool autotools-dev automake pkg-config libssl-dev libevent-dev bsdmainutils python3 libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-program-options-dev libboost-test-dev libboost-thread-dev
73+
sudo apt-get install build-essential libtool autotools-dev automake pkg-config libssl-dev libevent-dev bsdmainutils python3 libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev
7474

7575
BerkeleyDB is required for the wallet.
7676

src/util.cpp

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@
7272
#endif
7373

7474
#include <boost/interprocess/sync/file_lock.hpp>
75-
#include <boost/program_options/detail/config_file.hpp>
7675
#include <boost/thread.hpp>
7776
#include <openssl/crypto.h>
7877
#include <openssl/rand.h>
@@ -811,17 +810,47 @@ fs::path GetConfigFile(const std::string& confPath)
811810
return AbsPathForConfigVal(fs::path(confPath), false);
812811
}
813812

813+
static std::string TrimString(const std::string& str, const std::string& pattern)
814+
{
815+
std::string::size_type front = str.find_first_not_of(pattern);
816+
if (front == std::string::npos) {
817+
return std::string();
818+
}
819+
std::string::size_type end = str.find_last_not_of(pattern);
820+
return str.substr(front, end - front + 1);
821+
}
822+
823+
static std::vector<std::pair<std::string, std::string>> GetConfigOptions(std::istream& stream)
824+
{
825+
std::vector<std::pair<std::string, std::string>> options;
826+
std::string str, prefix;
827+
std::string::size_type pos;
828+
while (std::getline(stream, str)) {
829+
if ((pos = str.find('#')) != std::string::npos) {
830+
str = str.substr(0, pos);
831+
}
832+
const static std::string pattern = " \t\r\n";
833+
str = TrimString(str, pattern);
834+
if (!str.empty()) {
835+
if (*str.begin() == '[' && *str.rbegin() == ']') {
836+
prefix = str.substr(1, str.size() - 2) + '.';
837+
} else if ((pos = str.find('=')) != std::string::npos) {
838+
std::string name = prefix + TrimString(str.substr(0, pos), pattern);
839+
std::string value = TrimString(str.substr(pos + 1), pattern);
840+
options.emplace_back(name, value);
841+
}
842+
}
843+
}
844+
return options;
845+
}
846+
814847
bool ArgsManager::ReadConfigStream(std::istream& stream, std::string& error, bool ignore_invalid_keys)
815848
{
816849
LOCK(cs_args);
817850

818-
std::set<std::string> setOptions;
819-
setOptions.insert("*");
820-
821-
for (boost::program_options::detail::config_file_iterator it(stream, setOptions), end; it != end; ++it)
822-
{
823-
std::string strKey = std::string("-") + it->string_key;
824-
std::string strValue = it->value[0];
851+
for (const std::pair<std::string, std::string>& option : GetConfigOptions(stream)) {
852+
std::string strKey = std::string("-") + option.first;
853+
std::string strValue = option.second;
825854

826855
if (InterpretNegatedOption(strKey, strValue)) {
827856
m_config_args[strKey].clear();
@@ -831,7 +860,7 @@ bool ArgsManager::ReadConfigStream(std::istream& stream, std::string& error, boo
831860

832861
// Check that the arg is known
833862
if (!IsArgKnown(strKey, error) && !ignore_invalid_keys) {
834-
error = strprintf("Invalid configuration value %s", it->string_key.c_str());
863+
error = strprintf("Invalid configuration value %s", option.first.c_str());
835864
return false;
836865
}
837866
}

test/lint/lint-includes.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ EXPECTED_BOOST_INCLUDES=(
6767
boost/optional.hpp
6868
boost/preprocessor/cat.hpp
6969
boost/preprocessor/stringize.hpp
70-
boost/program_options/detail/config_file.hpp
7170
boost/scoped_array.hpp
7271
boost/signals2/connection.hpp
7372
boost/signals2/last_value.hpp

0 commit comments

Comments
 (0)