Skip to content

Commit 886ba49

Browse files
committed
use system lib instead of submodules when possibile
1 parent d3af92d commit 886ba49

File tree

10 files changed

+51
-85
lines changed

10 files changed

+51
-85
lines changed

CMakeLists.txt

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ project (openat VERSION 1.0.0 DESCRIPTION "OpenAT: Open Source Algorithmic Tradi
66
#
77

88
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
9+
910
# Create compile_commands.json in build dir while compiling
1011
set(CMAKE_EXPORT_COMPILE_COMMANDS ON )
1112

@@ -25,52 +26,15 @@ endif()
2526
# Build and setup the correct cmake variables for third-party libraries
2627
#
2728

28-
# Enable ExternalProject CMake module
29-
include(ExternalProject)
30-
3129
# Build Curlpp
3230
set(CURLPP "${PROJECT_SOURCE_DIR}/libs/curlpp")
3331
set(CURLPP_INCLUDE_DIR "${CURLPP}/include")
3432
add_subdirectory(${CURLPP})
3533

36-
# Json is a header-only library
37-
set(JSON "${PROJECT_SOURCE_DIR}/libs/nlohmann")
38-
set(JSON_INCLUDE_DIR "${JSON}")
39-
40-
# Spdlog is a header-only library
41-
set(SPDLOG "${PROJECT_SOURCE_DIR}/libs/spdlog")
42-
set(SPDLOG_INCLUDE_DIR "${SPDLOG}/include")
43-
4434
# Rapidxml is a header-only library
4535
set(RAPIDXML "${PROJECT_SOURCE_DIR}/libs/rapidxml")
4636
set(RAPIDXML_INCLUDE_DIR "${RAPIDXML}")
4737

48-
# GumboParser uses autogen
49-
set(GUMBOPARSER "${PROJECT_SOURCE_DIR}/libs/gumbo/parser")
50-
set(GUMBOPARSER_INCLUDE_DIR "${GUMBOPARSER}/include")
51-
# The compilation creates the include dir ${GUMBOPARSER}/include
52-
# and the lib dir ${GUMBOPARSER}/lib
53-
ExternalProject_Add(gumbo_parser
54-
SOURCE_DIR ${GUMBOPARSER}
55-
# Compile gumbo-parser
56-
CONFIGURE_COMMAND ${GUMBOPARSER}/autogen.sh COMMAND ./configure --prefix=${GUMBOPARSER}
57-
PREFIX ${GUMBOPARSER}
58-
BUILD_COMMAND ${MAKE}
59-
BUILD_IN_SOURCE 1)
60-
61-
62-
# Build gumbo-query that uses gumbo and cmake
63-
set(GUMBOQUERY "${PROJECT_SOURCE_DIR}/libs/gumbo/query")
64-
set(GUMBOQUERY_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/libs/gumbo") # keep structured includes
65-
# set variables needed by gumboquery cmakelists
66-
set(Gumbo_INCLUDE_DIR "${GUMBOPARSER_INCLUDE_DIR}")
67-
set(Gumbo_static_LIBRARY "${GUMBOPARSER}/lib/libgumbo.a")
68-
set(Gumbo_LIBRARY "${GUMBOPARSER}/lib/libgumbo.so")
69-
if(APPLE)
70-
set (Gumbo_LIBRARY "${GUMBOPARSER}/lib/libgumbo.dylib")
71-
endif()
72-
add_subdirectory(${GUMBOQUERY})
73-
7438
#
7539
# Build project
7640
#

README.md

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,22 @@ Clone the repository and make sure to clone the submodules too:
263263
git clone --recursive https://github.com/galeone/openat
264264
```
265265

266-
### Building on UNIX
266+
### Building on (Arch)linux
267267

268268
```
269+
# Install the required dependencies
270+
271+
sudo pacman -S spdlog nlohmann-json gumbo-parser sqlite
272+
# install gumbo query to your system
273+
cd libs/gumbo/query/build
274+
cmake ..
275+
make
276+
sudo make install
277+
# if there are problem with the static library, remove the last line
278+
# `libfind_process(Gumbo)`
279+
# from libs/gumbo/query/cmake/FindGumbo.cmake
280+
cd -
281+
# i
269282
mkdir build
270283
cd build
271284
cmake ..
@@ -274,16 +287,9 @@ CC=clang CXX=clang++ make
274287

275288
### Building on macOS
276289

277-
As of october 2017, the version of clang shipped with XCode 9 does not fully
278-
support C++17. You will need to install gcc from HomeBrew; it will be available
279-
as `gcc-7` and `g++-7`. Note that the gcc included in XCode is just a gcc
280-
frontend with an LLVM (clang) backend; it will not be able to build `at`.
281-
```
282-
brew install gcc
283-
```
284-
285290
Install the needed dependencies and remember to link them:
286291
```
292+
brew install gcc
287293
brew install openssl sqlite
288294
brew link sqlite --force
289295
```
@@ -339,14 +345,14 @@ target_link_libraries(project_name LINK_PUBLIC
339345

340346
The best way to contribute to OpenAT is via pull request and issues, here on GitHub.
341347

342-
There are a lot of things to do to improve OpenAT (and [openatd: OpenAT Daemon](https://github.com/galeone/openatd/) too!):
348+
There are a lot of things to do to improve OpenAT (and [openatd: OpenAT Daemon](https://github.com/galeone/openatd/) too!):
343349

344350
1. **Add implementations of the Market interface**: this is the most important part. More market are implemented and more OpenAT can be useful.
345351
With more implementation with can easily write trading bot for arbitrage in the easiest way ever.
346352
2. **Add data sources**: coinmarketcap is a good data source and it works well. But we can try to make OpenAT smarter, collecting any other data that talks about crypto currencies (just think, train a ML model with the stream of collected tweets and news feed... we can do sentiment analysis and many other cool things: a lot of (high quality) data is everything.
347353
3. **Improve the documentation**: at the time of writing, the only documentation is the README and the comments in the header files. We can do better.
348-
4. **Unit test**: test the server response it's something hard (especially when you work with idiotic APIs like the shapeshift ones, where a field change it's type from request to reuest): we have to create a mock server and test everything.
349-
5. **OMG you're using double and not integers everywere!**: yes you're right. But since OpenAT basically collects data and send request to API that accepts JSON, using doubles and integer changes nothing (you have to convert the data to a string in every case). But if you want to change OpenAT making it use integer and the information about the number of meaningful digits you're welcome.
354+
4. **Unit test**: test the server response it's something hard (especially when you work with idiotic APIs like the shapeshift ones, where a field change it's type from request to request): we have to create a mock server and test everything.
355+
5. **OMG you're using double and not integers everywhere!**: yes you're right. But since OpenAT basically collects data and send request to API that accepts JSON, using doubles and integer changes nothing (you have to convert the data to a string in every case). But if you want to change OpenAT making it use integer and the information about the number of meaningful digits you're welcome.
350356

351357
Also, if you want to donate instead of contributing with code, feel free do donate ETH at this address: `0xa1d283e77f8308559f62909526ccb2d9444d96fc`
352358

cmake/FindGumboQuery.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
find_path(GUMBO_QUERY_INCLUDE_DIR gq/Document.h)
2+
find_library(GUMBO_QUERY_SHARED_LIB libgq.so)
3+
4+
include(FindPackageHandleStandardArgs)
5+
find_package_handle_standard_args(GumboQuery REQUIRED_VARS
6+
GUMBO_QUERY_SHARED_LIB GUMBO_QUERY_INCLUDE_DIR)

include/at/coinmarketcap.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
#ifndef AT_COINMARKETCAP_H_
1616
#define AT_COINMARKETCAP_H_
1717

18-
#include <query/src/Document.h>
19-
#include <query/src/Node.h>
18+
#include <gq/Document.h>
19+
#include <gq/Node.h>
20+
2021
#include <at/exceptions.hpp>
2122
#include <at/market.hpp>
2223
#include <at/types.hpp>

include/at/exchange.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
#include <at/request.hpp>
1919
#include <at/types.hpp>
20-
#include <json.hpp>
2120
#include <map>
21+
#include <nlohmann/json.hpp>
2222
#include <string>
2323
#include <utility>
2424

include/at/market.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
#include <at/request.hpp>
1919
#include <at/types.hpp>
20-
#include <json.hpp>
2120
#include <map>
21+
#include <nlohmann/json.hpp>
2222
#include <string>
2323
#include <utility>
2424

include/at/request.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@
1616
#define AT_REQUEST_H_
1717

1818
#include <curl/curl.h>
19+
1920
#include <at/types.hpp>
2021
#include <cstring>
2122
#include <curlpp/Easy.hpp>
2223
#include <curlpp/Infos.hpp>
2324
#include <curlpp/Options.hpp>
2425
#include <curlpp/cURLpp.hpp>
2526
#include <iostream>
26-
#include <json.hpp>
27+
#include <nlohmann/json.hpp>
2728
#include <sstream>
2829
#include <stdexcept>
2930
#include <utility>

include/at/types.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
#ifndef AT_TYPE_H_
1616
#define AT_TYPE_H_
1717

18+
#include <ctime>
1819
#include <exception>
19-
#include <json.hpp>
20+
#include <nlohmann/json.hpp>
2021
#include <sstream>
2122
#include <stdexcept>
2223
#include <string>

openat.pc.in

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

src/CMakeLists.txt

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,36 +6,35 @@ file(GLOB_RECURSE CURRENT_SRC "*.cc")
66

77
# Find OpenSSL
88
find_package(OpenSSL REQUIRED)
9+
# sdplog
10+
find_package(spdlog REQUIRED)
11+
# gumbo query
12+
find_package(GumboQuery REQUIRED)
13+
# JSON
14+
find_package(nlohmann_json REQUIRED)
915

1016
# Executable at is the compilation of every .cc in this folder
1117
# and its subfolders
1218

1319
add_library (openat SHARED "${CURRENT_SRC}")
1420
set(OPENAT_REQUIRED_INCLUDES
1521
${OPENAT_INCLUDE_DIR}
16-
${OPENSSL_INCLUDE_DIR}
17-
${JSON_INCLUDE_DIR}
1822
${RAPIDXML_INCLUDE_DIR}
19-
${SPDLOG_INCLUDE_DIR}
2023
${CURLPP_INCLUDE_DIR}
21-
${GUMBOPARSER_INCLUDE_DIR}
22-
${GUMBOQUERY_INCLUDE_DIR}
24+
${GUMBO_QUERY_INCLUDE_DIR}
2325
)
2426
include_directories(${OPENAT_REQUIRED_INCLUDES})
2527
# Allows include directories outside this CMake
2628
set( OPENAT_REQUIRED_INCLUDES ${OPENAT_REQUIRED_INCLUDES} PARENT_SCOPE )
2729

28-
target_link_libraries (openat LINK_PUBLIC
29-
curlpp
30-
${CMAKE_THREAD_LIBS_INIT}
31-
gumbo_query_shared #defined in CMakeLists of libs/gumbo/query
32-
${OPENSSL_CRYPTO_LIBRARY}
30+
target_link_libraries (openat PUBLIC
31+
curlpp # from submodule
32+
Threads::Threads
33+
${GUMBO_QUERY_SHARED_LIB}
34+
OpenSSL::SSL
35+
OpenSSL::Crypto
36+
PRIVATE
37+
spdlog::spdlog
38+
nlohmann_json::nlohmann_json
39+
${GUMBO_PARSER_SHARED_LIB}
3340
)
34-
35-
include(GNUInstallDirs)
36-
configure_file("${PROJECT_SOURCE_DIR}/openat.pc.in" openat.pc @ONLY)
37-
install(TARGETS openat
38-
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
39-
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
40-
install(FILES ${CMAKE_BINARY_DIR}/src/openat.pc
41-
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig)

0 commit comments

Comments
 (0)