Skip to content

Commit

Permalink
refactor: replace boost filesystem with std filesystem
Browse files Browse the repository at this point in the history
  • Loading branch information
edubart committed Oct 31, 2023
1 parent 90bd22d commit 48c727f
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 26 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ third-party/cryptopp-CRYPTOPP_7_0_0
third-party/downloads
third-party/grpc
third-party/mongoose-*
src/remote-cartesi-machine-proxy
src/remote-cartesi-machine
src/jsonrpc-remote-cartesi-machine
src/merkle-tree-hash
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ ARG SANITIZE=no
RUN apt-get update && \
DEBIAN_FRONTEND="noninteractive" apt-get install --no-install-recommends -y \
build-essential vim wget git clang-tidy-15 clang-format-15 lcov \
libreadline-dev libboost-filesystem1.81-dev libssl-dev libc-ares-dev zlib1g-dev \
ca-certificates automake libtool patchelf cmake pkg-config lua5.4 liblua5.4-dev \
libboost1.81-dev libssl-dev \
ca-certificates automake libtool patchelf pkg-config lua5.4 liblua5.4-dev \
libgrpc++-dev libprotobuf-dev protobuf-compiler-grpc \
luarocks libcrypto++-dev && \
update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-15 120 && \
Expand Down
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ Obs: Please note that Apple Clang Version number does not follow upstream LLVM/C

```
apt-get install build-essential wget git clang-tidy-15 clang-format-15 \
libreadline-dev libboost-context1.81-dev \
libboost-filesystem1.81-dev libssl-dev libc-ares-dev zlib1g-dev \
ca-certificates automake libtool patchelf cmake pkg-config lua5.4 liblua5.4-dev \
libboost1.81-dev libssl-dev \
ca-certificates automake libtool patchelf pkg-config lua5.4 liblua5.4-dev \
libgrpc++-dev libprotobuf-dev protobuf-compiler-grpc \
luarocks libcrypto++-dev
Expand All @@ -48,7 +47,7 @@ sudo luarocks install --lua-version=5.4 luaposix

##### MacPorts
```
sudo port install clang-15 automake boost libtool wget cmake pkgconfig grpc zlib openssl lua libcryptopp lua-luarocks
sudo port install clang-15 automake boost libtool wget pkgconfig grpc openssl lua libcryptopp lua-luarocks
sudo luarocks install --lua-version=5.4 lpeg
sudo luarocks install --lua-version=5.4 dkjson
Expand All @@ -59,7 +58,7 @@ sudo luarocks install --lua-version=5.4 luaposix

##### Homebrew
```
brew install llvm@15 automake boost libomp wget cmake cryptopp pkg-config grpc zlib openssl [email protected] luarocks
brew install llvm@15 automake boost wget cryptopp pkg-config grpc openssl [email protected] luarocks
luarocks --lua-dir=$(brew --prefix)/opt/[email protected] install lpeg
luarocks --lua-dir=$(brew --prefix)/opt/[email protected] install dkjson
luarocks --lua-dir=$(brew --prefix)/opt/[email protected] install luasocket
Expand Down
15 changes: 6 additions & 9 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ $(error Neither Homebrew nor MacPorts is installed)
endif
endif

BOOST_FILESYSTEM_LIB_Darwin:=$(BOOST_LIB_DIR_Darwin) -lboost_system-mt -lboost_filesystem-mt
BOOST_PROCESS_LIB_Darwin:=-lpthread
PTHREAD_LIB_Darwin:=-lpthread
LIBCARTESI_Darwin=libcartesi-$(EMULATOR_VERSION_MAJOR).$(EMULATOR_VERSION_MINOR).dylib
LIBCARTESI_LDFLAGS_Darwin=-dynamiclib -undefined dynamic_lookup -install_name '@rpath/$(LIBCARTESI_Darwin)'
LIBCARTESI_TESTS_LDFLAGS_Darwin=-Wl,-rpath,$(CURDIR)
Expand All @@ -105,9 +104,8 @@ CC_Linux=gcc
CXX_Linux=g++
INCS_Linux=
FS_LIB_Linux=-lstdc++fs
BOOST_FILESYSTEM_LIB_Linux:=-lboost_system -lboost_filesystem
BOOST_PROCESS_LIB_Linux:=-lpthread
BOOST_INC_Linux=
PTHREAD_LIB_Linux:=-lpthread
BOOST_INC_Linux:=
CRYPTOPP_LIB_Linux:=-lcryptopp
CRYPTOPP_INC_Linux:=
GRPC_INC_Linux:=$(shell pkg-config --cflags-only-I grpc++)
Expand All @@ -129,9 +127,8 @@ PROFILE_DATA_Linux=
CC=$(CC_$(UNAME))
CXX=$(CXX_$(UNAME))
SOLDFLAGS:=$(SOLDFLAGS_$(UNAME)) $(GCLDFLAGS)
BOOST_PROCESS_LIB=$(BOOST_PROCESS_LIB_$(UNAME))
BOOST_FILESYSTEM_LIB=$(BOOST_FILESYSTEM_LIB_$(UNAME))
BOOST_INC=$(BOOST_INC_$(UNAME))
PTHREAD_LIB:=$(PTHREAD_LIB_$(UNAME))
BOOST_INC:=$(BOOST_INC_$(UNAME))
CRYPTOPP_LIB=$(CRYPTOPP_LIB_$(UNAME))
CRYPTOPP_INC=$(CRYPTOPP_INC_$(UNAME))
GRPC_INC:=$(GRPC_INC_$(UNAME))
Expand All @@ -156,7 +153,7 @@ LUACARTESI_GRPC_LIBS:=$(LIBCARTESI_LIB) $(CRYPTOPP_LIB) $(LIBCARTESI_GRPC_LIB)
LUACARTESI_JSONRPC_LIBS:=$(LIBCARTESI_LIB) $(CRYPTOPP_LIB)
REMOTE_CARTESI_MACHINE_LIBS:=$(CRYPTOPP_LIB) $(GRPC_LIB) $(PROTOBUF_LIB)
JSONRPC_REMOTE_CARTESI_MACHINE_LIBS:=$(CRYPTOPP_LIB)
TEST_MACHINE_C_API_LIBS:=$(LIBCARTESI_LIB) $(CRYPTOPP_LIB) $(LIBCARTESI_GRPC_LIB) $(BOOST_PROCESS_LIB) $(BOOST_FILESYSTEM_LIB)
TEST_MACHINE_C_API_LIBS:=$(LIBCARTESI_LIB) $(CRYPTOPP_LIB) $(LIBCARTESI_GRPC_LIB) $(PTHREAD_LIB)
HASH_LIBS:=$(CRYPTOPP_LIB)

#DEFS+= -DMT_ALL_DIRTY
Expand Down
17 changes: 9 additions & 8 deletions src/test-machine-c-api.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#define BOOST_TEST_MODULE Machine C API test // NOLINT(cppcoreguidelines-macro-usage)
#define BOOST_TEST_NO_OLD_TOOLS

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#include <boost/endian/conversion.hpp>
#include <boost/filesystem.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/process.hpp>
#include <boost/process/search_path.hpp>
#include <boost/test/included/unit_test.hpp>
Expand Down Expand Up @@ -424,8 +423,7 @@ std::ostream &boost_test_print_type(std::ostream &ostr, const cm_machine_config
// NOLINTNEXTLINE(cppcoreguidelines-special-member-functions)
class serialized_machine_fixture : public ordinary_machine_fixture {
public:
serialized_machine_fixture() :
_machine_config_path{boost::filesystem::temp_directory_path() / boost::filesystem::unique_path()} {
serialized_machine_fixture() : _machine_config_path{std::filesystem::temp_directory_path() / "machine"} {
char *err_msg{};
int error_code = cm_store(_machine, _machine_config_path.string().c_str(), &err_msg);
BOOST_CHECK_EQUAL(error_code, CM_ERROR_OK);
Expand All @@ -437,7 +435,7 @@ class serialized_machine_fixture : public ordinary_machine_fixture {
}

protected:
boost::filesystem::path _machine_config_path;
std::filesystem::path _machine_config_path;

auto _load_config() const {
std::ifstream ifs(_config_dir(), std::ios::binary);
Expand Down Expand Up @@ -478,8 +476,7 @@ BOOST_FIXTURE_TEST_CASE_NOLINT(load_machine_invalid_config_version_test, seriali

class store_file_fixture : public ordinary_machine_fixture {
public:
store_file_fixture() :
_broken_machine_path{(boost::filesystem::temp_directory_path() / boost::filesystem::unique_path()).string()} {}
store_file_fixture() : _broken_machine_path{(std::filesystem::temp_directory_path() / "machine").string()} {}

~store_file_fixture() {
std::filesystem::remove_all(_broken_machine_path);
Expand Down Expand Up @@ -2462,7 +2459,11 @@ static bool wait_for_server(cm_grpc_machine_stub *stub, int retries = 10) {
class grpc_machine_fixture_with_server : public grpc_machine_fixture {
public:
grpc_machine_fixture_with_server() {
boost::process::spawn(boost::process::search_path("remote-cartesi-machine"), "127.0.0.1:5001", m_server_group);
auto process_path = std::filesystem::current_path() / "remote-cartesi-machine";
if (!std::filesystem::exists(process_path)) {
process_path = "/usr/bin/remote-cartesi-machine";
}
boost::process::spawn(process_path.string(), "127.0.0.1:5001", m_server_group);
BOOST_CHECK(wait_for_server(m_stub));
}
~grpc_machine_fixture_with_server() override = default;
Expand Down
2 changes: 1 addition & 1 deletion tools/template/control.template
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Homepage: https://docs.cartesi.io/machine/host/cmdline/
Architecture: ARG_ARCH
Maintainer: Machine Reference Unit <https://discord.com/channels/600597137524391947/1107965671976992878>
Provides: machine-emulator
Depends: libboost-context1.81.0, libboost-filesystem1.81.0, libreadline8, openssl, libc-ares2, zlib1g, ca-certificates, libgomp1, lua5.4, libcrypto++8, libprotobuf32, libgrpc++1.51
Depends: lua5.4, libcrypto++8, libprotobuf32, libgrpc++1.51
Section: devel
Priority: optional
Multi-Arch: foreign
Expand Down

0 comments on commit 48c727f

Please sign in to comment.