Skip to content

Commit a92ffd7

Browse files
authored
Merge pull request #46 from yabjames/enabler-improve-file-structure
[ENABLER] Improve file structure
2 parents 60ee932 + 0137738 commit a92ffd7

File tree

5 files changed

+30
-17
lines changed

5 files changed

+30
-17
lines changed

CMakeLists.txt

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
cmake_minimum_required(VERSION 3.15)
2-
project(http_server VERSION 1.0 LANGUAGES C CXX)
2+
project(http_server_library VERSION 1.0 LANGUAGES C CXX)
3+
4+
add_subdirectory(demo)
35

46
set(LIBRARY "server_library")
57
set(TEST_TARGET "server_tests_bin")
6-
set(TARGET "server_impl_bin")
78
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
89

910
# Override Debug flags
@@ -17,7 +18,7 @@ find_package(Threads REQUIRED)
1718

1819

1920
# server library
20-
add_library(${LIBRARY}
21+
add_library(${LIBRARY} STATIC
2122
src/HttpServer.cpp
2223
src/HttpParser.cpp
2324
src/PathParams.cpp
@@ -47,14 +48,6 @@ include(GoogleTest)
4748
gtest_discover_tests(${TEST_TARGET})
4849

4950

50-
# server implementation executable
51-
add_executable(${TARGET}
52-
src/main.cpp
53-
)
54-
target_link_options(${TARGET} PRIVATE -O0 -g --coverage)
55-
target_link_libraries(${TARGET} PRIVATE ${LIBRARY})
56-
57-
5851
# coverage target
5952
# find required tools
6053
find_program(LCOV lcov REQUIRED)

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,9 @@ try {
139139
.
140140
├── src/ # Server implementation
141141
├── include/ # Public headers
142-
├── tests/ # gtest-based test suite
143-
├── cmake/ # CMake helpers
142+
├── test/ # gtest-based test suite
143+
├── demo/ # demo of the library implementation
144+
├── benchmarks/ # k6 performance benchmark outputs with a node server comparison
144145
├── .github/ # GitHub Actions workflows
145146
└── README.md
146147
```
@@ -186,16 +187,16 @@ conan build . --build=missing -s build_type=Debug
186187

187188
---
188189

189-
## Running the Server
190+
## Running the Server Demo
190191

191192
Command to run the HTTP server implementation example:
192193

193194
```bash
194195
# in release mode
195-
./build/Release/server_impl_bin
196+
./build/Release/demo/server_demo_bin
196197

197198
# in debug mode
198-
./build/Debug/server_impl_bin
199+
./build/Debug/demo/server_demo_bin
199200
```
200201

201202
---

demo/CMakeLists.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
cmake_minimum_required(VERSION 3.15)
2+
project(server_demo VERSION 1.0 LANGUAGES C CXX)
3+
4+
set(LIBRARY "server_library")
5+
set(TARGET "server_demo_bin")
6+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
7+
8+
# Override Debug flags
9+
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 --coverage")
10+
set(CMAKE_C_FLAGS_DEBUG "-g -O0 --coverage")
11+
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "--coverage")
12+
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "--coverage")
13+
14+
15+
# server implementation executable
16+
add_executable(${TARGET}
17+
main.cpp
18+
)
19+
target_link_libraries(${TARGET} PRIVATE ${LIBRARY})
File renamed without changes.

test/HttpParserTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include <gtest/gtest.h>
2-
#include "../include/HttpParser.h"
2+
#include "HttpParser.h"
33

44
#include <arpa/inet.h>
55
#include <netinet/in.h>

0 commit comments

Comments
 (0)