Skip to content

Commit ed76af9

Browse files
Merge pull request #52 from zerodha/v2
feat: v2
2 parents 6ea9d1f + 97da449 commit ed76af9

134 files changed

Lines changed: 8000 additions & 44369 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.clang-format

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ AllowShortIfStatementsOnASingleLine: WithoutElse
1313
AllowShortLambdasOnASingleLine: All
1414
AllowShortLoopsOnASingleLine: 'true'
1515
AlwaysBreakBeforeMultilineStrings: 'false'
16+
AlwaysBreakTemplateDeclarations: 'Yes'
1617
BinPackArguments: 'true'
1718
BinPackParameters: 'true'
1819
BreakBeforeBraces: Attach
1920
BreakBeforeTernaryOperators: 'false'
20-
ColumnLimit: '120'
21+
ColumnLimit: '80'
2122
CompactNamespaces: 'false'
2223
Cpp11BracedListStyle: 'false'
2324
FixNamespaceComments: 'true'

.clang-tidy

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
Checks: '*, -modernize-use-trailing-return-type, -fuchsia*, -google-runtime-references, -google-readability-todo'
2-
CheckOptions: 'IgnoreClassesWithAllMemberVariablesBeingPublic'
1+
Checks: '*, -modernize-use-trailing-return-type, -fuchsia*, -google-runtime-references, -google-readability-todo, -llvmlibc-*, -altera*, -readability-function-cognitive-complexity, -misc-non-private-member-variables-in-classes, -cppcoreguidelines-non-private-member-variables-in-classes, -cppcoreguidelines-pro-bounds-pointer-arithmetic'
2+
CheckOptions:
3+
- key: 'misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic'
4+
value: 'true'

.git-blame-ignore-revs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# change column limit to 80
2+
39cd0478af477b63ecc925fa8af8b0c82e4566e6

.github/workflows/cppkiteconnect-test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ jobs:
3737
git clone https://github.com/hoytech/uWebSockets.git
3838
cd uWebSockets && make && sudo make install && cd ..
3939
mkdir build && cd build
40-
cmake .. && make && make test ARGS="-V"
40+
cmake .. -DBUILD_EXAMPLES=ON -DBUILD_TESTS=ON && make && make test ARGS="-V"
4141
4242
# Build & test on macOS
4343
- name: Build and test on macOS
4444
if: startsWith(matrix.config.name, 'macOS')
4545
run: |
46-
brew install googletest libuv
46+
brew extract --version=1.10.0 googletest homebrew/cask && brew install googletest@1.10.0 libuv
4747
export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig"
4848
4949
curl -L https://github.com/hoytech/uWebSockets/archive/refs/tags/v0.14.8.tar.gz > uWebSocketsv-0.14.8.tar.gz
@@ -52,4 +52,4 @@ jobs:
5252
make && make installDarwin && cd ..
5353
5454
mkdir build && cd build
55-
cmake .. && make && make test ARGS="-V"
55+
cmake .. -DBUILD_EXAMPLES=ON -DBUILD_TESTS=ON && make && make test ARGS="-V"

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ build/
88
compile_commands.json
99

1010
#generated docs
11-
docs/**
1211
!docs/config.doxygen
1312
!docs/mainpage.dox
1413
!docs/CMakeLists.txt

.gitmodules

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
11
[submodule "tests/mock_responses"]
22
path = tests/mock_responses
33
url = https://github.com/zerodha/kiteconnect-mocks
4+
[submodule "include/PicoSHA2"]
5+
path = include/PicoSHA2
6+
url = https://github.com/okdshin/PicoSHA2.git
7+
[submodule "include/fmt"]
8+
path = include/fmt
9+
url = https://github.com/fmtlib/fmt.git
10+
[submodule "include/rapidjson"]
11+
path = include/rapidjson
12+
url = https://github.com/Tencent/rapidjson.git
13+
[submodule "include/cpp-httplib"]
14+
path = include/cpp-httplib
15+
url = https://github.com/yhirose/cpp-httplib.git
16+
[submodule "doxygen-awesome-css"]
17+
path = doxygen-awesome-css
18+
url = https://github.com/jothepro/doxygen-awesome-css.git
19+
[submodule "docs/doxygen-awesome-css"]
20+
path = docs/doxygen-awesome-css
21+
url = https://github.com/jothepro/doxygen-awesome-css.git
22+
[submodule "include/uri-parser"]
23+
path = include/uri-parser
24+
url = git@github.com:bhumitattarde/uri-parser.git
25+
[submodule "include/rapidcsv"]
26+
path = include/rapidcsv
27+
url = git@github.com:d99kris/rapidcsv.git

CMakeLists.txt

Lines changed: 105 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,118 @@
11
cmake_minimum_required(VERSION 3.10)
2-
project(kitepp)
2+
project(CppKiteConnect)
33

4-
#detect Linux (for optional linking of libuv)
4+
# set variables
5+
set(CMAKE_CXX_STANDARD 17)
6+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
7+
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
8+
9+
# detect Linux (for optional linking of libuv)
510
if(UNIX AND NOT APPLE)
11+
message(STATUS "environment set to linux")
612
set(LINUX TRUE)
713
endif()
814

9-
#set variables
10-
set(CMAKE_CXX_STANDARD 11)
11-
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
12-
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
13-
14-
#set project include directory
15+
# set project include directory
1516
include_directories("${CMAKE_SOURCE_DIR}/include")
1617

17-
#build examples
18-
add_subdirectory("examples/example1")
19-
add_subdirectory("examples/example2")
20-
add_subdirectory("examples/example3")
21-
add_subdirectory("examples/example4")
18+
# find deps
19+
set(LINUX_AND_UV_NOT_FOUND false)
20+
21+
if(BUILD_EXAMPLES OR BUILD_TESTS)
22+
find_package(Threads REQUIRED)
23+
find_package(OpenSSL REQUIRED)
24+
find_package(ZLIB REQUIRED)
25+
find_library(UWS_LIB uWS REQUIRED)
26+
find_path(UWS_INCLUDE uWS REQUIRED)
27+
28+
if(DEFINED LINUX)
29+
find_library(UV_LIB uv)
30+
find_path(UV_INCLUDE "uv.h")
31+
else()
32+
find_library(UV_LIB uv REQUIRED)
33+
find_path(UV_INCLUDE "uv.h" REQUIRED)
34+
endif()
35+
36+
if(BUILD_TESTS)
37+
find_package(GTest REQUIRED)
38+
find_package(GMock REQUIRED)
39+
endif()
40+
41+
if((NOT UV_LIB OR NOT UV_INCLUDE) AND DEFINED LINUX)
42+
set(LINUX_AND_UV_NOT_FOUND true)
43+
message(STATUS "couldn't find libuv")
44+
endif()
45+
endif()
46+
47+
# build examples
48+
if(BUILD_EXAMPLES)
49+
function(build_exmaple example_name)
50+
add_executable(${example_name} "${CMAKE_SOURCE_DIR}/examples/${example_name}.cpp")
51+
52+
if(LINUX_AND_UV_NOT_FOUND)
53+
target_include_directories(${example_name} PUBLIC ${UWS_INCLUDE})
54+
target_link_libraries(${example_name} PUBLIC Threads::Threads OpenSSL::SSL OpenSSL::Crypto ZLIB::ZLIB ${UWS_LIB})
55+
else()
56+
target_include_directories(${example_name} PUBLIC ${UWS_INCLUDE} ${UV_INCLUDE})
57+
target_link_libraries(${example_name} PUBLIC Threads::Threads OpenSSL::SSL OpenSSL::Crypto ZLIB::ZLIB ${UWS_LIB} ${UV_LIB})
58+
endif()
59+
endfunction(build_exmaple)
60+
61+
build_exmaple(example1)
62+
build_exmaple(example2)
63+
build_exmaple(example3)
64+
build_exmaple(example4)
65+
endif()
66+
67+
# build tests
68+
if(BUILD_TESTS)
69+
include(CTest)
70+
option(CMAKE_USE_WIN32_THREADS_INIT "using WIN32 threads" ON)
71+
option(gtest_disable_pthreads "disabling pthreads in gtest" ON)
72+
73+
# kite-test
74+
set(KITE_TEST_BINARY_NAME kiteTest)
75+
file(GLOB test_files
76+
"${CMAKE_SOURCE_DIR}/tests/unit/kite/*.cpp"
77+
)
78+
add_executable(${KITE_TEST_BINARY_NAME} ${test_files})
79+
target_include_directories(${KITE_TEST_BINARY_NAME} PUBLIC ${GTEST_INCLUDE_DIRS} ${GMOCK_INCLUDE_DIRS})
80+
target_link_libraries(${KITE_TEST_BINARY_NAME} PUBLIC OpenSSL::SSL OpenSSL::Crypto ${GTEST_BOTH_LIBRARIES} ${GMOCK_BOTH_LIBRARIES} Threads::Threads)
81+
add_test(NAME kite-test COMMAND ${KITE_TEST_BINARY_NAME})
82+
83+
# ticker-test
84+
set(TICKER_TEST_BINARY_NAME tickerTest)
85+
add_executable(${TICKER_TEST_BINARY_NAME} "${CMAKE_SOURCE_DIR}/tests/unit/tickertest.cpp")
86+
87+
if(LINUX_AND_UV_NOT_FOUND)
88+
target_include_directories(${TICKER_TEST_BINARY_NAME} PUBLIC ${UWS_INCLUDE} ${GTEST_INCLUDE_DIRS})
89+
target_link_libraries(${TICKER_TEST_BINARY_NAME} PUBLIC OpenSSL::SSL OpenSSL::Crypto ZLIB::ZLIB ${UWS_LIB} ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES} Threads::Threads)
90+
else()
91+
target_include_directories(${TICKER_TEST_BINARY_NAME} PUBLIC ${UV_INCLUDE} ${UWS_INCLUDE} ${GTEST_INCLUDE_DIRS})
92+
target_link_libraries(${TICKER_TEST_BINARY_NAME} PUBLIC OpenSSL::SSL OpenSSL::Crypto ZLIB::ZLIB ${UV_LIB} ${UWS_LIB} ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES} Threads::Threads)
93+
endif()
2294

23-
#build tests
24-
include(CTest)
25-
if(BUILD_TESTING)
26-
add_subdirectory("tests")
95+
add_test(NAME ticker-test COMMAND ${TICKER_TEST_BINARY_NAME})
2796
endif()
2897

29-
#generate documentation
30-
add_subdirectory("docs")
98+
# generate docs
99+
if(BUILD_DOCS)
100+
find_package(Doxygen)
31101

102+
if(DOXYGEN_FOUND)
103+
# set io files and configure doxyfile
104+
set(DOXY_FILE Doxyfile.in)
105+
set(DOXYGEN_IN ${CMAKE_SOURCE_DIR}/cmake/templates/${DOXY_FILE})
106+
set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile.out)
107+
configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
32108

109+
# ! don't add to the `all` target. doing so will build build docs everytime.
110+
add_custom_target(docs
111+
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
112+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
113+
COMMENT "generating documentation with doxygen"
114+
VERBATIM)
115+
else(DOXYGEN_FOUND)
116+
message(FATAL_ERROR "doxygen is required for generating documentation")
117+
endif(DOXYGEN_FOUND)
118+
endif()

0 commit comments

Comments
 (0)