Skip to content

Commit 55dc93e

Browse files
committed
stack: Refactor stack into its own library
Move nop controller and simulator plugin to models where all the other Nop classes are.
1 parent 3f017f3 commit 55dc93e

38 files changed

+292
-170
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ add_subdirectory(runtime)
3232
add_subdirectory(models)
3333
add_subdirectory(osi)
3434
add_subdirectory(oak)
35+
add_subdirectory(stack)
3536
add_subdirectory(engine)
3637
add_subdirectory(plugins)
3738

Makefile.all

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ ALL_PKGS := \
5050
fable \
5151
runtime \
5252
models \
53+
stack \
5354
osi \
5455
oak \
5556
engine \
@@ -77,7 +78,8 @@ runtime: fable
7778
models: runtime
7879
osi: runtime models
7980
oak: runtime
80-
engine: models oak
81+
stack: runtime models
82+
engine: models oak stack
8183
$(PLUGIN_PKGS): runtime models
8284
plugins/esmini: osi
8385

engine/CMakeLists.txt

Lines changed: 8 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ if(CLOE_FIND_PACKAGES)
77
find_package(fable REQUIRED QUIET)
88
find_package(cloe-runtime REQUIRED QUIET)
99
find_package(cloe-models REQUIRED QUIET)
10+
find_package(cloe-stack REQUIRED QUIET)
1011
endif()
1112
find_package(Boost REQUIRED QUIET)
1213
find_package(CLI11 REQUIRED QUIET)
@@ -22,67 +23,6 @@ string(TIMESTAMP CLOE_ENGINE_TIMESTAMP "%Y-%m-%d")
2223
set(CLOE_ENGINE_VERSION ${CLOE_PROJECT_VERSION})
2324
set(PROJECT_GIT_REF "unknown")
2425

25-
# Library libstack ---------------------------------------------------
26-
message(STATUS "Building cloe-stacklib library.")
27-
add_library(cloe-stacklib STATIC
28-
src/config.hpp
29-
src/stack.hpp
30-
src/stack.cpp
31-
src/stack_factory.hpp
32-
src/stack_factory.cpp
33-
src/plugin.hpp
34-
src/plugin.cpp
35-
36-
# Built-in plugins:
37-
src/plugins/nop_controller.cpp
38-
src/plugins/nop_controller.hpp
39-
src/plugins/nop_simulator.cpp
40-
src/plugins/nop_simulator.hpp
41-
)
42-
add_library(cloe::stacklib ALIAS cloe-stacklib)
43-
set_target_properties(cloe-stacklib PROPERTIES
44-
CXX_STANDARD 17
45-
CXX_STANDARD_REQUIRED ON
46-
OUTPUT_NAME stack
47-
)
48-
target_include_directories(cloe-stacklib
49-
PRIVATE
50-
src
51-
)
52-
target_link_libraries(cloe-stacklib
53-
PUBLIC
54-
cloe::runtime
55-
cloe::models
56-
fable::fable
57-
Boost::headers
58-
Threads::Threads
59-
${CMAKE_DL_LIBS}
60-
)
61-
62-
include(CTest)
63-
if(BUILD_TESTING)
64-
find_package(GTest REQUIRED QUIET)
65-
include(GoogleTest)
66-
67-
message(STATUS "Building test-stacklib executable.")
68-
add_executable(test-stacklib
69-
src/stack_test.cpp
70-
src/stack_component_test.cpp
71-
)
72-
set_target_properties(test-stacklib PROPERTIES
73-
CXX_STANDARD 17
74-
CXX_STANDARD_REQUIRED ON
75-
)
76-
target_link_libraries(test-stacklib
77-
GTest::gtest
78-
GTest::gtest_main
79-
Boost::boost
80-
cloe::models
81-
cloe::stacklib
82-
)
83-
gtest_add_tests(TARGET test-stacklib)
84-
endif()
85-
8626
# Library libengine ----------------------------------------------
8727
message(STATUS "Building cloe-enginelib library.")
8828
add_library(cloe-enginelib STATIC
@@ -157,7 +97,7 @@ target_include_directories(cloe-enginelib
15797
)
15898
target_link_libraries(cloe-enginelib
15999
PUBLIC
160-
cloe::stacklib
100+
cloe::stack
161101
cloe::models
162102
cloe::runtime
163103
fable::fable
@@ -189,8 +129,11 @@ else()
189129
target_compile_definitions(cloe-enginelib PUBLIC CLOE_ENGINE_WITH_LRDB=0)
190130
endif()
191131

132+
include(CTest)
192133
if(BUILD_TESTING)
193134
message(STATUS "Building test-enginelib executable.")
135+
find_package(GTest REQUIRED QUIET)
136+
include(GoogleTest)
194137
add_executable(test-enginelib
195138
src/lua_stack_test.cpp
196139
src/lua_setup_test.cpp
@@ -204,11 +147,12 @@ if(BUILD_TESTING)
204147
CXX_STANDARD_REQUIRED ON
205148
)
206149
target_link_libraries(test-enginelib
150+
PRIVATE
207151
GTest::gtest
208152
GTest::gtest_main
209153
Boost::boost
210154
cloe::models
211-
cloe::stacklib
155+
cloe::stack
212156
cloe::enginelib
213157
)
214158
gtest_add_tests(TARGET test-enginelib)
@@ -245,7 +189,7 @@ target_include_directories(cloe-engine
245189
)
246190
target_link_libraries(cloe-engine
247191
PRIVATE
248-
cloe::stacklib
192+
cloe::stack
249193
cloe::enginelib
250194
CLI11::CLI11
251195
linenoise::linenoise

engine/conanfile.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def set_version(self):
5757
def requirements(self):
5858
self.requires(f"cloe-runtime/{self.version}@cloe/develop")
5959
self.requires(f"cloe-models/{self.version}@cloe/develop")
60+
self.requires(f"cloe-stack/{self.version}@cloe/develop")
6061
self.requires("cli11/2.3.2", private=True)
6162
self.requires("sol2/3.3.1")
6263
if self.options.server:

engine/src/lua_setup.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@
2828

2929
#include <cloe/utility/std_extensions.hpp> // for split_string
3030

31+
#include <cloe/stack.hpp>
3132
#include <fable/utility/sol.hpp> // for Json(sol::object)
3233
#include <fable/utility/string.hpp> // for join_vector
3334

3435
#include "error_handler.hpp" // for format_cloe_error
3536
#include "lua_api.hpp"
36-
#include "stack.hpp"
3737
#include "utility/command.hpp" // for CommandExecuter, CommandResult
3838

3939
// This variable is set from CMakeLists.txt, but in case it isn't,

engine/src/lua_setup_stack.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
*/
1818

1919
#include <fable/utility/sol.hpp>
20+
#include <cloe/stack.hpp>
2021

2122
#include "lua_api.hpp"
2223
#include "lua_setup.hpp"
23-
#include "stack.hpp"
2424

2525
namespace cloe {
2626

engine/src/lua_setup_test.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
#include <fstream>
2424
#include <string_view>
2525

26+
#include <cloe/stack.hpp> // for Stack
2627
#include <sol/state.hpp>
2728

2829
#include "lua_api.hpp" // for lua_safe_script_file
2930
#include "lua_setup.hpp" // for setup_lua
30-
#include "stack.hpp" // for Stack
3131
using namespace cloe; // NOLINT(build/namespaces)
3232

3333
#ifndef CLOE_LUA_PATH
@@ -87,7 +87,8 @@ TEST_F(cloe_lua_setup, cloe_engine_is_available) {
8787

8888
TEST_F(cloe_lua_setup, describe_cloe) {
8989
setup_lua(lua, opt, stack);
90-
ASSERT_EQ(lua.script("local cloe = require('cloe'); return cloe.inspect(cloe.LogLevel.CRITICAL)").get<std::string>(),
90+
ASSERT_EQ(lua.script("local cloe = require('cloe'); return cloe.inspect(cloe.LogLevel.CRITICAL)")
91+
.get<std::string>(),
9192
std::string("\"critical\""));
9293
}
9394

engine/src/lua_stack_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222

2323
#include <sol/state.hpp>
2424

25-
#include <cloe/core.hpp> // for Json
25+
#include <cloe/core.hpp> // for Json
26+
#include <cloe/stack.hpp> // for Stack
2627
#include <fable/utility.hpp>
2728
#include <fable/utility/gtest.hpp> // for assert_from_conf
2829
#include <fable/utility/sol.hpp>
2930

3031
#include "lua_setup.hpp"
31-
#include "stack.hpp" // for Stack
3232
using namespace cloe; // NOLINT(build/namespaces)
3333

3434
TEST(cloe_lua_stack, deserialize_vehicle_conf) {

engine/src/main.cpp

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

2525
#include <cloe/core/error.hpp>
2626
#include <cloe/core/logger.hpp>
27+
#include <cloe/stack_config.hpp>
2728

28-
#include "config.hpp"
2929
#include "main_commands.hpp"
3030

3131
int main(int argc, char** argv) {

engine/src/main_check.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
#include <vector> // for vector<>
2222

2323
#include <cloe/core/fable.hpp>
24+
#include <cloe/stack.hpp>
2425

2526
#include "main_commands.hpp"
26-
#include "stack.hpp"
2727

2828
namespace engine {
2929

0 commit comments

Comments
 (0)