Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Bazel tooling support #248

Merged
merged 4 commits into from
Jul 12, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
stack: Refactor stack into its own library
Move nop controller and simulator plugin to models where all
the other Nop classes are.
cassava committed Jul 10, 2024
commit 7a5c99a1706dbc7544ee67de212a6dafaad77fb5
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -32,6 +32,7 @@ add_subdirectory(runtime)
add_subdirectory(models)
add_subdirectory(osi)
add_subdirectory(oak)
add_subdirectory(stack)
add_subdirectory(engine)
add_subdirectory(plugins)

4 changes: 3 additions & 1 deletion Makefile.all
Original file line number Diff line number Diff line change
@@ -50,6 +50,7 @@ ALL_PKGS := \
fable \
runtime \
models \
stack \
osi \
oak \
engine \
@@ -77,7 +78,8 @@ runtime: fable
models: runtime
osi: runtime models
oak: runtime
engine: models oak
stack: runtime models
engine: models oak stack
$(PLUGIN_PKGS): runtime models
plugins/esmini: osi

72 changes: 8 additions & 64 deletions engine/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ if(CLOE_FIND_PACKAGES)
find_package(fable REQUIRED QUIET)
find_package(cloe-runtime REQUIRED QUIET)
find_package(cloe-models REQUIRED QUIET)
find_package(cloe-stack REQUIRED QUIET)
endif()
find_package(Boost REQUIRED QUIET)
find_package(CLI11 REQUIRED QUIET)
@@ -22,67 +23,6 @@ string(TIMESTAMP CLOE_ENGINE_TIMESTAMP "%Y-%m-%d")
set(CLOE_ENGINE_VERSION ${CLOE_PROJECT_VERSION})
set(PROJECT_GIT_REF "unknown")

# Library libstack ---------------------------------------------------
message(STATUS "Building cloe-stacklib library.")
add_library(cloe-stacklib STATIC
src/config.hpp
src/stack.hpp
src/stack.cpp
src/stack_factory.hpp
src/stack_factory.cpp
src/plugin.hpp
src/plugin.cpp

# Built-in plugins:
src/plugins/nop_controller.cpp
src/plugins/nop_controller.hpp
src/plugins/nop_simulator.cpp
src/plugins/nop_simulator.hpp
)
add_library(cloe::stacklib ALIAS cloe-stacklib)
set_target_properties(cloe-stacklib PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
OUTPUT_NAME stack
)
target_include_directories(cloe-stacklib
PRIVATE
src
)
target_link_libraries(cloe-stacklib
PUBLIC
cloe::runtime
cloe::models
fable::fable
Boost::headers
Threads::Threads
${CMAKE_DL_LIBS}
)

include(CTest)
if(BUILD_TESTING)
find_package(GTest REQUIRED QUIET)
include(GoogleTest)

message(STATUS "Building test-stacklib executable.")
add_executable(test-stacklib
src/stack_test.cpp
src/stack_component_test.cpp
)
set_target_properties(test-stacklib PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
)
target_link_libraries(test-stacklib
GTest::gtest
GTest::gtest_main
Boost::boost
cloe::models
cloe::stacklib
)
gtest_add_tests(TARGET test-stacklib)
endif()

# Library libengine ----------------------------------------------
message(STATUS "Building cloe-enginelib library.")
add_library(cloe-enginelib STATIC
@@ -157,7 +97,7 @@ target_include_directories(cloe-enginelib
)
target_link_libraries(cloe-enginelib
PUBLIC
cloe::stacklib
cloe::stack
cloe::models
cloe::runtime
fable::fable
@@ -189,8 +129,11 @@ else()
target_compile_definitions(cloe-enginelib PUBLIC CLOE_ENGINE_WITH_LRDB=0)
endif()

include(CTest)
if(BUILD_TESTING)
message(STATUS "Building test-enginelib executable.")
find_package(GTest REQUIRED QUIET)
include(GoogleTest)
add_executable(test-enginelib
src/lua_stack_test.cpp
src/lua_setup_test.cpp
@@ -204,11 +147,12 @@ if(BUILD_TESTING)
CXX_STANDARD_REQUIRED ON
)
target_link_libraries(test-enginelib
PRIVATE
GTest::gtest
GTest::gtest_main
Boost::boost
cloe::models
cloe::stacklib
cloe::stack
cloe::enginelib
)
gtest_add_tests(TARGET test-enginelib)
@@ -245,7 +189,7 @@ target_include_directories(cloe-engine
)
target_link_libraries(cloe-engine
PRIVATE
cloe::stacklib
cloe::stack
cloe::enginelib
CLI11::CLI11
linenoise::linenoise
1 change: 1 addition & 0 deletions engine/conanfile.py
Original file line number Diff line number Diff line change
@@ -57,6 +57,7 @@ def set_version(self):
def requirements(self):
self.requires(f"cloe-runtime/{self.version}@cloe/develop")
self.requires(f"cloe-models/{self.version}@cloe/develop")
self.requires(f"cloe-stack/{self.version}@cloe/develop")
self.requires("cli11/2.3.2", private=True)
self.requires("sol2/3.3.1")
if self.options.server:
2 changes: 1 addition & 1 deletion engine/src/lua_setup.cpp
Original file line number Diff line number Diff line change
@@ -28,12 +28,12 @@

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

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

#include "error_handler.hpp" // for format_cloe_error
#include "lua_api.hpp"
#include "stack.hpp"
#include "utility/command.hpp" // for CommandExecuter, CommandResult

// This variable is set from CMakeLists.txt, but in case it isn't,
2 changes: 1 addition & 1 deletion engine/src/lua_setup_stack.cpp
Original file line number Diff line number Diff line change
@@ -17,10 +17,10 @@
*/

#include <fable/utility/sol.hpp>
#include <cloe/stack.hpp>

#include "lua_api.hpp"
#include "lua_setup.hpp"
#include "stack.hpp"

namespace cloe {

5 changes: 3 additions & 2 deletions engine/src/lua_setup_test.cpp
Original file line number Diff line number Diff line change
@@ -23,11 +23,11 @@
#include <fstream>
#include <string_view>

#include <cloe/stack.hpp> // for Stack
#include <sol/state.hpp>

#include "lua_api.hpp" // for lua_safe_script_file
#include "lua_setup.hpp" // for setup_lua
#include "stack.hpp" // for Stack
using namespace cloe; // NOLINT(build/namespaces)

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

TEST_F(cloe_lua_setup, describe_cloe) {
setup_lua(lua, opt, stack);
ASSERT_EQ(lua.script("local cloe = require('cloe'); return cloe.inspect(cloe.LogLevel.CRITICAL)").get<std::string>(),
ASSERT_EQ(lua.script("local cloe = require('cloe'); return cloe.inspect(cloe.LogLevel.CRITICAL)")
.get<std::string>(),
std::string("\"critical\""));
}

4 changes: 2 additions & 2 deletions engine/src/lua_stack_test.cpp
Original file line number Diff line number Diff line change
@@ -22,13 +22,13 @@

#include <sol/state.hpp>

#include <cloe/core.hpp> // for Json
#include <cloe/core.hpp> // for Json
#include <cloe/stack.hpp> // for Stack
#include <fable/utility.hpp>
#include <fable/utility/gtest.hpp> // for assert_from_conf
#include <fable/utility/sol.hpp>

#include "lua_setup.hpp"
#include "stack.hpp" // for Stack
using namespace cloe; // NOLINT(build/namespaces)

TEST(cloe_lua_stack, deserialize_vehicle_conf) {
2 changes: 1 addition & 1 deletion engine/src/main.cpp
Original file line number Diff line number Diff line change
@@ -24,8 +24,8 @@

#include <cloe/core/error.hpp>
#include <cloe/core/logger.hpp>
#include <cloe/stack_config.hpp>

#include "config.hpp"
#include "main_commands.hpp"

int main(int argc, char** argv) {
2 changes: 1 addition & 1 deletion engine/src/main_check.cpp
Original file line number Diff line number Diff line change
@@ -21,9 +21,9 @@
#include <vector> // for vector<>

#include <cloe/core/fable.hpp>
#include <cloe/stack.hpp>

#include "main_commands.hpp"
#include "stack.hpp"

namespace engine {

12 changes: 6 additions & 6 deletions engine/src/main_commands.cpp
Original file line number Diff line number Diff line change
@@ -37,11 +37,11 @@
#include <boost/uuid/uuid_io.hpp>

#include <cloe/core.hpp> // for logger::get
#include <cloe/stack.hpp> // for Stack
#include <fable/utility.hpp> // for read_conf

#include "error_handler.hpp" // for conclude_error
#include "simulation.hpp" // for Simulation
#include "stack.hpp" // for Stack

namespace engine {

@@ -89,7 +89,7 @@ std::string handle_uuid(const ProbeOptions& opt) { return handle_uuid_impl(opt);

template <typename Options>
std::tuple<cloe::Stack, sol::state> handle_config_impl(const Options& opt,
const std::vector<std::string>& filepaths) {
const std::vector<std::string>& filepaths) {
assert(opt.output != nullptr && opt.error != nullptr);
auto log = cloe::logger::get("cloe");
cloe::logger::get("cloe")->info("Cloe {}", CLOE_ENGINE_VERSION);
@@ -122,13 +122,13 @@ std::tuple<cloe::Stack, sol::state> handle_config_impl(const Options& opt,
return {std::move(stack), std::move(lua_state)};
}

std::tuple<cloe::Stack, sol::state> handle_config(
const RunOptions& opt, const std::vector<std::string>& filepaths) {
std::tuple<cloe::Stack, sol::state> handle_config(const RunOptions& opt,
const std::vector<std::string>& filepaths) {
return handle_config_impl(opt, filepaths);
}

std::tuple<cloe::Stack, sol::state> handle_config(
const ProbeOptions& opt, const std::vector<std::string>& filepaths) {
std::tuple<cloe::Stack, sol::state> handle_config(const ProbeOptions& opt,
const std::vector<std::string>& filepaths) {
return handle_config_impl(opt, filepaths);
}

5 changes: 3 additions & 2 deletions engine/src/main_commands.hpp
Original file line number Diff line number Diff line change
@@ -24,9 +24,10 @@
#include <string>
#include <vector>

#include "config.hpp"
#include <cloe/stack_config.hpp>
#include <cloe/stack_factory.hpp>

#include "lua_setup.hpp"
#include "stack_factory.hpp"

namespace engine {

2 changes: 1 addition & 1 deletion engine/src/main_dump.cpp
Original file line number Diff line number Diff line change
@@ -21,9 +21,9 @@
#include <vector> // for vector<>

#include <cloe/core/error.hpp>
#include <cloe/stack.hpp> // for Stack

#include "main_commands.hpp" // for DumpOptions, new_stack
#include "stack.hpp" // for Stack

namespace engine {

5 changes: 3 additions & 2 deletions engine/src/main_run.cpp
Original file line number Diff line number Diff line change
@@ -17,13 +17,14 @@
*/

#include <csignal> // for signal
#include <tuple> // for tuple
#include <tuple> // for tuple

#include <cloe/stack.hpp> // for Stack

#include "error_handler.hpp" // for conclude_error
#include "main_commands.hpp" // for RunOptions, handle_*
#include "simulation.hpp" // for Simulation
#include "simulation_result.hpp" // for SimulationResult
#include "stack.hpp" // for Stack

namespace engine {

10 changes: 5 additions & 5 deletions engine/src/main_shell.cpp
Original file line number Diff line number Diff line change
@@ -25,11 +25,11 @@
#include <linenoise.h>

#include <fmt/format.h>
#include <cloe/stack.hpp>
#include <fable/utility/string.hpp> // for ends_with

#include "lua_api.hpp" // for lua_safe_script_file
#include "main_commands.hpp" // for Stack, new_stack, LuaOptions, new_lua
#include "stack.hpp" // for Stack

namespace engine {

@@ -53,8 +53,8 @@ bool evaluate(sol::state_view lua, std::ostream& os, const char* buf) {
return true;
}

int noninteractive_shell(sol::state_view lua, std::ostream& os, const std::vector<std::string>& actions,
bool ignore_errors) {
int noninteractive_shell(sol::state_view lua, std::ostream& os,
const std::vector<std::string>& actions, bool ignore_errors) {
int errors = 0;
for (const auto& action : actions) {
auto ok = evaluate(lua, os, action.c_str());
@@ -68,8 +68,8 @@ int noninteractive_shell(sol::state_view lua, std::ostream& os, const std::vecto
return errors;
}

void interactive_shell(sol::state_view lua, std::ostream& os, const std::vector<std::string>& actions,
bool ignore_errors) {
void interactive_shell(sol::state_view lua, std::ostream& os,
const std::vector<std::string>& actions, bool ignore_errors) {
constexpr auto PROMPT = "> ";
constexpr auto PROMPT_CONTINUE = ">> ";
constexpr auto PROMPT_HISTORY = "< ";
2 changes: 1 addition & 1 deletion engine/src/main_usage.cpp
Original file line number Diff line number Diff line change
@@ -22,10 +22,10 @@
#include <utility> // for pair<>, move
#include <vector> // for vector<>

#include <cloe/stack.hpp> // for Stack
#include <cloe/utility/xdg.hpp> // for find_all_config

#include "main_commands.hpp" // for new_stack
#include "stack.hpp" // for Stack

namespace engine {

2 changes: 1 addition & 1 deletion engine/src/main_version.cpp
Original file line number Diff line number Diff line change
@@ -20,9 +20,9 @@

#include <cloe/core/fable.hpp>
#include <cloe/plugin.hpp> // for CLOE_PLUGIN_MANIFEST_VERSION
#include <cloe/stack_config.hpp> // for CLOE_STACK_VERSION
#include <cloe/utility/inja.hpp> // for inja_env

#include "config.hpp" // for CLOE_STACK_VERSION
#include "main_commands.hpp" // for VersionOptions

namespace engine {
6 changes: 3 additions & 3 deletions engine/src/registrar.hpp
Original file line number Diff line number Diff line change
@@ -25,10 +25,10 @@
#include <string> // for string
#include <string_view> // for string_view

#include <cloe/core/logger.hpp> // for logger::get
#include <cloe/registrar.hpp> // for cloe::Registrar
#include <cloe/core/logger.hpp> // for logger::get
#include <cloe/registrar.hpp> // for cloe::Registrar
#include <cloe/stack_config.hpp> // for CLOE_TRIGGER_PATH_DELIMITER, ...

#include "config.hpp" // for CLOE_TRIGGER_PATH_DELIMITER, ...
#include "coordinator.hpp" // for Coordinator
#include "server.hpp" // for Server, ServerRegistrar

Loading