Skip to content

Commit

Permalink
Remove Boost filesystem and system (#2747)
Browse files Browse the repository at this point in the history
* Forbid fs::path(std::string) and fs::path::string(). Add AbsPathJoin.

* Remove Boost filesystem and system

* Fix symbolic link support

* lint: set correct include names

* lint: format Python

* Fix compilation on Windows

* Move AbsPathJoin so Windows can find it

* Correctly decode literal string

---------

Co-authored-by: Prasanna Loganathar <[email protected]>
  • Loading branch information
Bushstar and prasannavl authored Mar 22, 2024
1 parent fe1a87d commit 3134753
Show file tree
Hide file tree
Showing 47 changed files with 530 additions and 592 deletions.
119 changes: 0 additions & 119 deletions build-aux/m4/ax_boost_filesystem.m4

This file was deleted.

121 changes: 0 additions & 121 deletions build-aux/m4/ax_boost_system.m4

This file was deleted.

4 changes: 1 addition & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1012,8 +1012,6 @@ AX_BOOST_BASE([MINIMUM_REQUIRED_BOOST])
if test x$want_boost = xno; then
AC_MSG_ERROR([[cannot be built without boost]])
fi
AX_BOOST_SYSTEM
AX_BOOST_FILESYSTEM

dnl Boost 1.56 through 1.62 allow using std::atomic instead of its own atomic
dnl counter implementations. In 1.63 and later the std::atomic approach is default.
Expand Down Expand Up @@ -1068,7 +1066,7 @@ if test x$use_boost = xyes; then
AX_CHECK_PREPROC_FLAG([-DBOOST_NO_CXX98_FUNCTION_BASE], [BOOST_CPPFLAGS="$BOOST_CPPFLAGS -DBOOST_NO_CXX98_FUNCTION_BASE"], [], [$CXXFLAG_WERROR],
[AC_LANG_PROGRAM([[#include <boost/config.hpp>]])])

BOOST_LIBS="$BOOST_LDFLAGS $BOOST_SYSTEM_LIB $BOOST_FILESYSTEM_LIB"
BOOST_LIBS="$BOOST_LDFLAGS"
LIBS="$BOOST_LIBS $LIBS"
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ RUN apk add --update alpine-sdk
RUN apk add --no-cache bash gcc git libffi musl-dev libffi-dev autoconf automake
RUN apk add --no-cache openssh-client make db-dev openssl openssl-dev
RUN apk add --no-cache libtool libevent libevent-dev
RUN apk add --no-cache boost boost-dev boost-system boost-filesystem
RUN apk add --no-cache boost boost-dev

COPY . .

Expand Down
2 changes: 1 addition & 1 deletion depends/packages/boost.mk
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ $(package)_toolset_$(host_os)=gcc
$(package)_archiver_$(host_os)=$($(package)_ar)
$(package)_toolset_darwin=darwin
$(package)_archiver_darwin=$($(package)_libtool)
$(package)_config_libraries=filesystem,system,test
$(package)_config_libraries=test
$(package)_cxxflags_linux=-fPIC
endef

Expand Down
2 changes: 1 addition & 1 deletion doc/build-unix.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Build requirements:

Now, you can either build from self-compiled [depends](/depends/README.md) or install the required dependencies:

sudo apt-get install libssl-dev libevent-dev libboost-system-dev libboost-filesystem-dev libboost-test-dev
sudo apt-get install libssl-dev libevent-dev libboost-test-dev

Rust toolchain is necessary for the build:

Expand Down
4 changes: 2 additions & 2 deletions make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -690,8 +690,8 @@ pkg_install_deps() {
# python3-venv for settings up all python deps
apt-get install -y \
software-properties-common build-essential git libtool autotools-dev automake \
pkg-config bsdmainutils python3 python3-pip python3-venv libssl-dev libevent-dev libboost-system-dev \
libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev \
pkg-config bsdmainutils python3 python3-pip python3-venv libssl-dev libevent-dev \
libboost-chrono-dev libboost-test-dev libboost-thread-dev \
libminiupnpc-dev libzmq3-dev libqrencode-dev wget ccache \
libdb-dev libdb++-dev libdb5.3 libdb5.3-dev libdb5.3++ libdb5.3++-dev \
curl cmake zip unzip libc6-dev gcc-multilib locales locales-all
Expand Down
2 changes: 2 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ DEFI_CORE_H = \
util/bytevectorhash.h \
util/error.h \
util/fees.h \
util/getuniquepath.h \
util/system.h \
util/moneystr.h \
util/rbf.h \
Expand Down Expand Up @@ -699,6 +700,7 @@ libdefi_util_a_SOURCES = \
util/bytevectorhash.cpp \
util/error.cpp \
util/fees.cpp \
util/getuniquepath.cpp \
util/system.cpp \
util/moneystr.cpp \
util/rbf.cpp \
Expand Down
7 changes: 4 additions & 3 deletions src/addrdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <addrman.h>
#include <chainparams.h>
#include <clientversion.h>
#include <fs.h>
#include <hash.h>
#include <random.h>
#include <streams.h>
Expand Down Expand Up @@ -47,7 +48,7 @@ bool SerializeFileDB(const std::string& prefix, const fs::path& path, const Data
if (fileout.IsNull()) {
fileout.fclose();
remove(pathTmp);
return error("%s: Failed to open file %s", __func__, pathTmp.string());
return error("%s: Failed to open file %s", __func__, fs::PathToString(pathTmp));
}

// Serialize
Expand All @@ -59,7 +60,7 @@ bool SerializeFileDB(const std::string& prefix, const fs::path& path, const Data
if (!FileCommit(fileout.Get())) {
fileout.fclose();
remove(pathTmp);
return error("%s: Failed to flush file %s", __func__, pathTmp.string());
return error("%s: Failed to flush file %s", __func__, fs::PathToString(pathTmp));
}
fileout.fclose();

Expand Down Expand Up @@ -110,7 +111,7 @@ bool DeserializeFileDB(const fs::path& path, Data& data)
FILE *file = fsbridge::fopen(path, "rb");
CAutoFile filein(file, SER_DISK, CLIENT_VERSION);
if (filein.IsNull())
return error("%s: Failed to open file %s", __func__, path.string());
return error("%s: Failed to open file %s", __func__, fs::PathToString(path));

return DeserializeDB(filein, data);
}
Expand Down
3 changes: 2 additions & 1 deletion src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include <algorithm>
#include <cassert>
#include <fstream>

#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
Expand Down Expand Up @@ -1478,7 +1479,7 @@ void ClearCheckpoints(CChainParams &params) {
}

Res UpdateCheckpointsFromFile(CChainParams &params, const std::string &fileName) {
std::ifstream file(fileName);
std::ifstream file(fs::PathFromString(fileName));
if (!file.good()) {
return Res::Err("Could not read %s. Ensure it exists and has read permissions", fileName);
}
Expand Down
Loading

0 comments on commit 3134753

Please sign in to comment.