From 2b0dc93c0e5ebc75193db026035551eea654adb8 Mon Sep 17 00:00:00 2001 From: Benjamin Morgan Date: Fri, 5 Jul 2024 15:25:09 +0200 Subject: [PATCH 1/4] fable: Implement clang-tidy suggestions --- fable/examples/contacts/src/main.cpp | 13 ++++++------- fable/examples/simple_config/src/main.cpp | 2 +- fable/include/fable/conf.hpp | 1 - fable/include/fable/schema/factory.hpp | 1 - 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/fable/examples/contacts/src/main.cpp b/fable/examples/contacts/src/main.cpp index 6e4dc6adb..d09417a0b 100644 --- a/fable/examples/contacts/src/main.cpp +++ b/fable/examples/contacts/src/main.cpp @@ -63,14 +63,13 @@ #include // for std::{cout, cerr} #include // for std::string<> #include // for std::vector<> +#include // for std::optional<> #include // for fmt::format #include // for CLI::App -#include // for boost::optional<> #include // for fable::{Confable, CONFABLE_SCHEMA} #include // for fable::{Schema, String} -#include // for fable::{Optional, make_schema} #include // for fable::{read_conf} // All structs that are used directly with fable for serialization and @@ -170,16 +169,16 @@ struct Contact : public fable::Confable { std::string firstName; std::string lastName; bool isAlive{false}; - boost::optional age{0}; + std::optional age{0}; - boost::optional
address; + std::optional
address; std::vector phoneNumbers; std::vector children; - boost::optional spouse; + std::optional spouse; Contact() = default; Contact( - std::string first, std::string last, bool alive, boost::optional age) noexcept + std::string first, std::string last, bool alive, std::optional age) noexcept : firstName(std::move(first)), lastName(std::move(last)), isAlive(alive), age(age) {} Contact with_address(Address&& addr) && { @@ -222,7 +221,7 @@ int main(int argc, char** argv) { Contact("John", "Smith", true, 42) .with_address({"Generate Road 12", "Nowhere", "NA", "00000"}) .with_phone({PhoneType::Home, "+1 650 0000 000"}), - Contact("Jane", "Doe", false, boost::none), + Contact("Jane", "Doe", false, std::nullopt), }; // If we don't have a Confable, we can create a Schema on the fly and pass diff --git a/fable/examples/simple_config/src/main.cpp b/fable/examples/simple_config/src/main.cpp index 2f4fea83e..5d82381cb 100644 --- a/fable/examples/simple_config/src/main.cpp +++ b/fable/examples/simple_config/src/main.cpp @@ -84,7 +84,7 @@ int main(int argc, char **argv) { try { std::cout << fmt::format("Loading config from {}", filename) << std::endl; config.from_conf(fable::read_conf(filename)); - } catch (fable::Error e) { + } catch (fable::Error& e) { std::cerr << fmt::format("\n\n{0:=^{1}}\n", " JSON-Validation ", header_width) << std::endl; std::cerr << fmt::format("Error: {}", e.what()) << std::endl; return 1; diff --git a/fable/include/fable/conf.hpp b/fable/include/fable/conf.hpp index a41a5a41a..014cdeed8 100644 --- a/fable/include/fable/conf.hpp +++ b/fable/include/fable/conf.hpp @@ -57,7 +57,6 @@ #include // for vector<> #include // for fmt::format - #include // for ConfError #include // for Json diff --git a/fable/include/fable/schema/factory.hpp b/fable/include/fable/schema/factory.hpp index 53eec4898..c757c86dd 100644 --- a/fable/include/fable/schema/factory.hpp +++ b/fable/include/fable/schema/factory.hpp @@ -23,7 +23,6 @@ #pragma once #include // for function<> -#include // for numeric_limits<> #include // for map<> #include // for shared_ptr<> #include // for string From 7a5c99a1706dbc7544ee67de212a6dafaad77fb5 Mon Sep 17 00:00:00 2001 From: Benjamin Morgan Date: Tue, 9 Jul 2024 12:17:20 +0200 Subject: [PATCH 2/4] stack: Refactor stack into its own library Move nop controller and simulator plugin to models where all the other Nop classes are. --- CMakeLists.txt | 1 + Makefile.all | 4 +- engine/CMakeLists.txt | 72 ++------------- engine/conanfile.py | 1 + engine/src/lua_setup.cpp | 2 +- engine/src/lua_setup_stack.cpp | 2 +- engine/src/lua_setup_test.cpp | 5 +- engine/src/lua_stack_test.cpp | 4 +- engine/src/main.cpp | 2 +- engine/src/main_check.cpp | 2 +- engine/src/main_commands.cpp | 12 +-- engine/src/main_commands.hpp | 5 +- engine/src/main_dump.cpp | 2 +- engine/src/main_run.cpp | 5 +- engine/src/main_shell.cpp | 10 +-- engine/src/main_usage.cpp | 2 +- engine/src/main_version.cpp | 2 +- engine/src/registrar.hpp | 6 +- engine/src/server.hpp | 2 +- engine/src/simulation.hpp | 3 +- engine/src/simulation_context.hpp | 2 +- models/CMakeLists.txt | 2 + .../include/cloe}/plugins/nop_controller.hpp | 17 ++-- .../include/cloe}/plugins/nop_simulator.hpp | 18 ++-- .../src/cloe}/plugins/nop_controller.cpp | 14 ++- .../src/cloe}/plugins/nop_simulator.cpp | 23 +++-- stack/CMakeLists.txt | 81 +++++++++++++++++ stack/Makefile | 1 + stack/conanfile.py | 87 +++++++++++++++++++ .../include/cloe/plugin_loader.hpp | 5 +- {engine/src => stack/include/cloe}/stack.hpp | 12 +-- .../include/cloe/stack_config.hpp | 0 .../include/cloe}/stack_factory.hpp | 0 .../src/cloe/plugin_loader.cpp | 6 +- {engine/src => stack/src/cloe}/stack.cpp | 4 +- .../src/cloe}/stack_component_test.cpp | 15 ++-- .../src => stack/src/cloe}/stack_factory.cpp | 16 ++-- {engine/src => stack/src/cloe}/stack_test.cpp | 15 ++-- 38 files changed, 292 insertions(+), 170 deletions(-) rename {engine/src => models/include/cloe}/plugins/nop_controller.hpp (69%) rename {engine/src => models/include/cloe}/plugins/nop_simulator.hpp (74%) rename {engine/src => models/src/cloe}/plugins/nop_controller.cpp (81%) rename {engine/src => models/src/cloe}/plugins/nop_simulator.cpp (91%) create mode 100644 stack/CMakeLists.txt create mode 100644 stack/Makefile create mode 100644 stack/conanfile.py rename engine/src/plugin.hpp => stack/include/cloe/plugin_loader.hpp (99%) rename {engine/src => stack/include/cloe}/stack.hpp (99%) rename engine/src/config.hpp => stack/include/cloe/stack_config.hpp (100%) rename {engine/src => stack/include/cloe}/stack_factory.hpp (100%) rename engine/src/plugin.cpp => stack/src/cloe/plugin_loader.cpp (98%) rename {engine/src => stack/src/cloe}/stack.cpp (99%) rename {engine/src => stack/src/cloe}/stack_component_test.cpp (96%) rename {engine/src => stack/src/cloe}/stack_factory.cpp (91%) rename {engine/src => stack/src/cloe}/stack_test.cpp (94%) diff --git a/CMakeLists.txt b/CMakeLists.txt index d50488e7d..adb1e464b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/Makefile.all b/Makefile.all index c6756f0e1..97b5c99f1 100644 --- a/Makefile.all +++ b/Makefile.all @@ -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 diff --git a/engine/CMakeLists.txt b/engine/CMakeLists.txt index 2eb8b2806..a4d9a5ac3 100644 --- a/engine/CMakeLists.txt +++ b/engine/CMakeLists.txt @@ -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 diff --git a/engine/conanfile.py b/engine/conanfile.py index 5ab39b51c..f012f381b 100644 --- a/engine/conanfile.py +++ b/engine/conanfile.py @@ -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: diff --git a/engine/src/lua_setup.cpp b/engine/src/lua_setup.cpp index e1cdf1146..691186e49 100644 --- a/engine/src/lua_setup.cpp +++ b/engine/src/lua_setup.cpp @@ -28,12 +28,12 @@ #include // for split_string +#include #include // for Json(sol::object) #include // 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, diff --git a/engine/src/lua_setup_stack.cpp b/engine/src/lua_setup_stack.cpp index da563a32f..c5eb8088b 100644 --- a/engine/src/lua_setup_stack.cpp +++ b/engine/src/lua_setup_stack.cpp @@ -17,10 +17,10 @@ */ #include +#include #include "lua_api.hpp" #include "lua_setup.hpp" -#include "stack.hpp" namespace cloe { diff --git a/engine/src/lua_setup_test.cpp b/engine/src/lua_setup_test.cpp index 2d5fd8372..dd81feac7 100644 --- a/engine/src/lua_setup_test.cpp +++ b/engine/src/lua_setup_test.cpp @@ -23,11 +23,11 @@ #include #include +#include // for Stack #include #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(), + ASSERT_EQ(lua.script("local cloe = require('cloe'); return cloe.inspect(cloe.LogLevel.CRITICAL)") + .get(), std::string("\"critical\"")); } diff --git a/engine/src/lua_stack_test.cpp b/engine/src/lua_stack_test.cpp index 7b96d08ce..40ac6a78b 100644 --- a/engine/src/lua_stack_test.cpp +++ b/engine/src/lua_stack_test.cpp @@ -22,13 +22,13 @@ #include -#include // for Json +#include // for Json +#include // for Stack #include #include // for assert_from_conf #include #include "lua_setup.hpp" -#include "stack.hpp" // for Stack using namespace cloe; // NOLINT(build/namespaces) TEST(cloe_lua_stack, deserialize_vehicle_conf) { diff --git a/engine/src/main.cpp b/engine/src/main.cpp index 918eef30a..da35c2f0c 100644 --- a/engine/src/main.cpp +++ b/engine/src/main.cpp @@ -24,8 +24,8 @@ #include #include +#include -#include "config.hpp" #include "main_commands.hpp" int main(int argc, char** argv) { diff --git a/engine/src/main_check.cpp b/engine/src/main_check.cpp index 774df6c79..46ef96971 100644 --- a/engine/src/main_check.cpp +++ b/engine/src/main_check.cpp @@ -21,9 +21,9 @@ #include // for vector<> #include +#include #include "main_commands.hpp" -#include "stack.hpp" namespace engine { diff --git a/engine/src/main_commands.cpp b/engine/src/main_commands.cpp index 1172727eb..ae0ecd7bd 100644 --- a/engine/src/main_commands.cpp +++ b/engine/src/main_commands.cpp @@ -37,11 +37,11 @@ #include #include // for logger::get +#include // for Stack #include // 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 std::tuple handle_config_impl(const Options& opt, - const std::vector& filepaths) { + const std::vector& 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 handle_config_impl(const Options& opt, return {std::move(stack), std::move(lua_state)}; } -std::tuple handle_config( - const RunOptions& opt, const std::vector& filepaths) { +std::tuple handle_config(const RunOptions& opt, + const std::vector& filepaths) { return handle_config_impl(opt, filepaths); } -std::tuple handle_config( - const ProbeOptions& opt, const std::vector& filepaths) { +std::tuple handle_config(const ProbeOptions& opt, + const std::vector& filepaths) { return handle_config_impl(opt, filepaths); } diff --git a/engine/src/main_commands.hpp b/engine/src/main_commands.hpp index 910c1a53c..a6592e5f7 100644 --- a/engine/src/main_commands.hpp +++ b/engine/src/main_commands.hpp @@ -24,9 +24,10 @@ #include #include -#include "config.hpp" +#include +#include + #include "lua_setup.hpp" -#include "stack_factory.hpp" namespace engine { diff --git a/engine/src/main_dump.cpp b/engine/src/main_dump.cpp index 2894c9372..27055cf3a 100644 --- a/engine/src/main_dump.cpp +++ b/engine/src/main_dump.cpp @@ -21,9 +21,9 @@ #include // for vector<> #include +#include // for Stack #include "main_commands.hpp" // for DumpOptions, new_stack -#include "stack.hpp" // for Stack namespace engine { diff --git a/engine/src/main_run.cpp b/engine/src/main_run.cpp index 0097f6a4c..bf5544356 100644 --- a/engine/src/main_run.cpp +++ b/engine/src/main_run.cpp @@ -17,13 +17,14 @@ */ #include // for signal -#include // for tuple +#include // for tuple + +#include // 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 { diff --git a/engine/src/main_shell.cpp b/engine/src/main_shell.cpp index 09776d397..eb45bb412 100644 --- a/engine/src/main_shell.cpp +++ b/engine/src/main_shell.cpp @@ -25,11 +25,11 @@ #include #include +#include #include // 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& actions, - bool ignore_errors) { +int noninteractive_shell(sol::state_view lua, std::ostream& os, + const std::vector& 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& actions, - bool ignore_errors) { +void interactive_shell(sol::state_view lua, std::ostream& os, + const std::vector& actions, bool ignore_errors) { constexpr auto PROMPT = "> "; constexpr auto PROMPT_CONTINUE = ">> "; constexpr auto PROMPT_HISTORY = "< "; diff --git a/engine/src/main_usage.cpp b/engine/src/main_usage.cpp index 64cb96e8e..78913dad4 100644 --- a/engine/src/main_usage.cpp +++ b/engine/src/main_usage.cpp @@ -22,10 +22,10 @@ #include // for pair<>, move #include // for vector<> +#include // for Stack #include // for find_all_config #include "main_commands.hpp" // for new_stack -#include "stack.hpp" // for Stack namespace engine { diff --git a/engine/src/main_version.cpp b/engine/src/main_version.cpp index 87e9db335..b9532f66f 100644 --- a/engine/src/main_version.cpp +++ b/engine/src/main_version.cpp @@ -20,9 +20,9 @@ #include #include // for CLOE_PLUGIN_MANIFEST_VERSION +#include // for CLOE_STACK_VERSION #include // for inja_env -#include "config.hpp" // for CLOE_STACK_VERSION #include "main_commands.hpp" // for VersionOptions namespace engine { diff --git a/engine/src/registrar.hpp b/engine/src/registrar.hpp index abc47ed5a..8d401b086 100644 --- a/engine/src/registrar.hpp +++ b/engine/src/registrar.hpp @@ -25,10 +25,10 @@ #include // for string #include // for string_view -#include // for logger::get -#include // for cloe::Registrar +#include // for logger::get +#include // for cloe::Registrar +#include // for CLOE_TRIGGER_PATH_DELIMITER, ... -#include "config.hpp" // for CLOE_TRIGGER_PATH_DELIMITER, ... #include "coordinator.hpp" // for Coordinator #include "server.hpp" // for Server, ServerRegistrar diff --git a/engine/src/server.hpp b/engine/src/server.hpp index 3cfc0cccf..e065777df 100644 --- a/engine/src/server.hpp +++ b/engine/src/server.hpp @@ -25,8 +25,8 @@ #include // for unique_ptr<> #include // for Registrar +#include -#include "stack.hpp" // for ServerConf #include "utility/defer.hpp" // for Defer namespace engine { diff --git a/engine/src/simulation.hpp b/engine/src/simulation.hpp index f661eb2b6..8c1fa14e9 100644 --- a/engine/src/simulation.hpp +++ b/engine/src/simulation.hpp @@ -26,10 +26,9 @@ #include // for function<> #include // for optional<> +#include // for Stack #include // for state_view -#include "stack.hpp" // for Stack - namespace engine { class SimulationContext; diff --git a/engine/src/simulation_context.hpp b/engine/src/simulation_context.hpp index 360cc5feb..30fad7980 100644 --- a/engine/src/simulation_context.hpp +++ b/engine/src/simulation_context.hpp @@ -32,6 +32,7 @@ #include // for state_view #include // for Simulator, Controller, Registrar, Vehicle, Duration +#include // for Stack #include // for DurationTimer #include "simulation_events.hpp" // for LoopCallback, ... @@ -41,7 +42,6 @@ #include "simulation_result.hpp" // for SimulationResult #include "simulation_statistics.hpp" // for SimulationStatistics #include "simulation_sync.hpp" // for SimulationSync -#include "stack.hpp" // for Stack namespace engine { diff --git a/models/CMakeLists.txt b/models/CMakeLists.txt index 173e7aacf..79e2819b2 100644 --- a/models/CMakeLists.txt +++ b/models/CMakeLists.txt @@ -23,6 +23,8 @@ add_library(cloe-models src/cloe/component/utility/steering_utils.cpp src/cloe/utility/actuation_state.cpp src/cloe/utility/lua_types.cpp + src/cloe/plugins/nop_controller.cpp + src/cloe/plugins/nop_simulator.cpp # For IDE integration ${cloe-models_PUBLIC_HEADERS} diff --git a/engine/src/plugins/nop_controller.hpp b/models/include/cloe/plugins/nop_controller.hpp similarity index 69% rename from engine/src/plugins/nop_controller.hpp rename to models/include/cloe/plugins/nop_controller.hpp index f5514622d..68f330394 100644 --- a/engine/src/plugins/nop_controller.hpp +++ b/models/include/cloe/plugins/nop_controller.hpp @@ -16,19 +16,18 @@ * SPDX-License-Identifier: Apache-2.0 */ /** - * \file plugins/nop_controller.hpp - * \see plugins/nop_controller.cpp + * \file cloe/plugins/nop_controller.hpp + * \see cloe/plugins/nop_controller.cpp */ #pragma once #include // for DEFINE_CONTROLLER_FACTORY, Json, ... -namespace cloe { -namespace controller { +namespace cloe::plugins { -struct NopConfiguration : public Confable { - CONFABLE_FRIENDS(NopConfiguration) +struct NopControllerConfiguration : public Confable { + CONFABLE_FRIENDS(NopControllerConfiguration) }; /** @@ -36,7 +35,7 @@ struct NopConfiguration : public Confable { * * This is useful for smoke-test testing. */ -DEFINE_CONTROLLER_FACTORY(NopFactory, NopConfiguration, "nop", "stand-in that does nothing") +DEFINE_CONTROLLER_FACTORY(NopControllerFactory, NopControllerConfiguration, "nop", + "stand-in that does nothing") -} // namespace controller -} // namespace cloe +} // namespace cloe::plugins diff --git a/engine/src/plugins/nop_simulator.hpp b/models/include/cloe/plugins/nop_simulator.hpp similarity index 74% rename from engine/src/plugins/nop_simulator.hpp rename to models/include/cloe/plugins/nop_simulator.hpp index 12f34d360..76878203e 100644 --- a/engine/src/plugins/nop_simulator.hpp +++ b/models/include/cloe/plugins/nop_simulator.hpp @@ -16,25 +16,23 @@ * SPDX-License-Identifier: Apache-2.0 */ /** - * \file plugins/nop_simulator.hpp - * \see plugins/nop_simulator.cpp + * \file cloe/plugins/nop_simulator.hpp + * \see cloe/plugins/nop_simulator.cpp */ #pragma once -#include // for unique_ptr<> #include // for string #include // for vector #include // for Simulator, SimulatorFactory, ... -namespace cloe { -namespace simulator { +namespace cloe::plugins { -struct NopConfiguration : public Confable { +struct NopSimulatorConfiguration : public Confable { std::vector vehicles{"default"}; - CONFABLE_SCHEMA(NopConfiguration) { + CONFABLE_SCHEMA(NopSimulatorConfiguration) { return Schema{ {"vehicles", Schema(&vehicles, "list of vehicle names to make available")}, }; @@ -47,7 +45,7 @@ struct NopConfiguration : public Confable { } }; -DEFINE_SIMULATOR_FACTORY(NopFactory, NopConfiguration, "nop", "stand-in no-operation simulator") +DEFINE_SIMULATOR_FACTORY(NopSimulatorFactory, NopSimulatorConfiguration, "nop", + "stand-in no-operation simulator") -} // namespace simulator -} // namespace cloe +} // namespace cloe::plugins diff --git a/engine/src/plugins/nop_controller.cpp b/models/src/cloe/plugins/nop_controller.cpp similarity index 81% rename from engine/src/plugins/nop_controller.cpp rename to models/src/cloe/plugins/nop_controller.cpp index 695374c32..1e6c4871a 100644 --- a/engine/src/plugins/nop_controller.cpp +++ b/models/src/cloe/plugins/nop_controller.cpp @@ -16,18 +16,17 @@ * SPDX-License-Identifier: Apache-2.0 */ /** - * \file plugins/nop_controller.cpp - * \see plugins/nop_controller.hpp + * \file cloe/plugins/nop_controller.cpp + * \see cloe/plugins/nop_controller.hpp */ -#include "plugins/nop_controller.hpp" +#include #include // for unique_ptr<>, make_unique<> #include // for Sync -namespace cloe { -namespace controller { +namespace cloe::plugins { class NopController : public Controller { public: @@ -46,9 +45,8 @@ class NopController : public Controller { Duration process(const Sync& sync) override { return sync.time(); } }; -std::unique_ptr NopFactory::make(const Conf&) const { +std::unique_ptr NopControllerFactory::make(const Conf&) const { return std::make_unique(this->name()); } -} // namespace controller -} // namespace cloe +} // namespace cloe::plugins diff --git a/engine/src/plugins/nop_simulator.cpp b/models/src/cloe/plugins/nop_simulator.cpp similarity index 91% rename from engine/src/plugins/nop_simulator.cpp rename to models/src/cloe/plugins/nop_simulator.cpp index 671ffbce6..205c5736a 100644 --- a/engine/src/plugins/nop_simulator.cpp +++ b/models/src/cloe/plugins/nop_simulator.cpp @@ -16,11 +16,11 @@ * SPDX-License-Identifier: Apache-2.0 */ /** - * \file plugins/nop_simulator.cpp - * \see plugins/nop_simulator.hpp + * \file cloe/plugins/nop_simulator.cpp + * \see cloe/plugins/nop_simulator.hpp */ -#include "plugins/nop_simulator.hpp" +#include #include // for function<> #include // for unique_ptr<> @@ -45,8 +45,7 @@ #include // for Sync #include // for Vehicle -namespace cloe { -namespace simulator { +namespace cloe::plugins { struct NopVehicle : public Vehicle { NopVehicle(uint64_t id, const std::string& name) : Vehicle(id, name) { @@ -86,7 +85,7 @@ struct NopVehicle : public Vehicle { class NopSimulator : public Simulator { public: - explicit NopSimulator(const std::string& name, const NopConfiguration& c) + explicit NopSimulator(const std::string& name, const NopSimulatorConfiguration& c) : Simulator(name), config_(c) {} virtual ~NopSimulator() noexcept = default; @@ -109,8 +108,9 @@ class NopSimulator : public Simulator { void enroll(Registrar& r) override { r.register_api_handler("/state", HandlerType::BUFFERED, handler::ToJson(this)); - r.register_api_handler( - "/configuration", HandlerType::BUFFERED, handler::ToJson(&config_)); + r.register_api_handler("/configuration", + HandlerType::BUFFERED, + handler::ToJson(&config_)); } size_t num_vehicles() const override { @@ -154,12 +154,11 @@ class NopSimulator : public Simulator { } private: - NopConfiguration config_; + NopSimulatorConfiguration config_; std::vector> vehicles_; std::function finfunc_; }; -DEFINE_SIMULATOR_FACTORY_MAKE(NopFactory, NopSimulator) +DEFINE_SIMULATOR_FACTORY_MAKE(NopSimulatorFactory, NopSimulator) -} // namespace simulator -} // namespace cloe +} // namespace cloe::plugins diff --git a/stack/CMakeLists.txt b/stack/CMakeLists.txt new file mode 100644 index 000000000..f62ddae9a --- /dev/null +++ b/stack/CMakeLists.txt @@ -0,0 +1,81 @@ +cmake_minimum_required(VERSION 3.15...3.27 FATAL_ERROR) + +project(cloe_stack LANGUAGES CXX) + +include(GNUInstallDirs) +include(TargetLinting) + +# Module ------------------------------------------------------------- +set(CLOE_FIND_PACKAGES ON CACHE BOOL "Call find_package() for cloe packages") +if(CLOE_FIND_PACKAGES) + find_package(cloe-runtime REQUIRED QUIET) + find_package(cloe-models REQUIRED QUIET) +endif() +set(THREADS_PREFER_PTHREAD_FLAG ON) +find_package(Threads REQUIRED QUIET) +find_package(Boost COMPONENTS headers REQUIRED QUIET) + +message(STATUS "Building cloe-stack library.") +file(GLOB cloe-stack_PUBLIC_HEADERS "include/**/*.hpp") +add_library(cloe-stack STATIC + ${cloe-stack_PUBLIC_HEADERS} + src/cloe/stack.cpp + src/cloe/stack_factory.cpp + src/cloe/plugin_loader.cpp +) +add_library(cloe::stack ALIAS cloe-stack) +set_target_properties(cloe-stack PROPERTIES + CXX_STANDARD 17 + CXX_STANDARD_REQUIRED ON +) +target_include_directories(cloe-stack + PUBLIC + "$" + "$" +) +target_link_libraries(cloe-stack + PUBLIC + cloe::runtime + cloe::models + fable::fable + Boost::headers + Threads::Threads + ${CMAKE_DL_LIBS} +) + +# Testing ------------------------------------------------------------- +include(CTest) +if(BUILD_TESTING) + find_package(GTest REQUIRED QUIET) + include(GoogleTest) + message(STATUS "Building test-stack executable.") + add_executable(test-stack + src/cloe/stack_test.cpp + src/cloe/stack_component_test.cpp + ) + set_target_properties(test-stack PROPERTIES + CXX_STANDARD 17 + CXX_STANDARD_REQUIRED ON + ) + target_link_libraries(test-stack + PRIVATE + GTest::gtest + GTest::gtest_main + Boost::boost + cloe::models + cloe::stack + ) + gtest_add_tests(TARGET test-stack) +endif() + +# Installation ------------------------------------------------------- +install(TARGETS cloe-stack + LIBRARY + DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE + DESTINATION ${CMAKE_INSTALL_LIBDIR} +) +install( + DIRECTORY include/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +) diff --git a/stack/Makefile b/stack/Makefile new file mode 100644 index 000000000..87c6e44df --- /dev/null +++ b/stack/Makefile @@ -0,0 +1 @@ +include ../Makefile.package diff --git a/stack/conanfile.py b/stack/conanfile.py new file mode 100644 index 000000000..603698d98 --- /dev/null +++ b/stack/conanfile.py @@ -0,0 +1,87 @@ +# mypy: ignore-errors +# pylint: skip-file + +from pathlib import Path + +from conan import ConanFile +from conan.tools import cmake, files, scm + +required_conan_version = ">=1.52.0" + +class CloeStack(ConanFile): + name = "cloe-stack" + url = "https://github.com/eclipse/cloe" + description = "Cloe stack library" + license = "Apache-2.0" + settings = "os", "compiler", "build_type", "arch" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + generators = "CMakeDeps" + no_copy_source = True + exports_sources = [ + "include/*", + "src/*", + "CMakeLists.txt", + ] + + def set_version(self): + version_file = Path(self.recipe_folder) / "../VERSION" + if version_file.exists(): + self.version = files.load(self, version_file).strip() + else: + git = scm.Git(self, self.recipe_folder) + self.version = git.run("describe --dirty=-dirty")[1:] + + def requirements(self): + self.requires(f"cloe-runtime/{self.version}@cloe/develop") + self.requires(f"cloe-models/{self.version}@cloe/develop") + self.requires("boost/1.74.0") + + def build_requirements(self): + self.test_requires("gtest/1.14.0") + + def layout(self): + cmake.cmake_layout(self) + + def generate(self): + tc = cmake.CMakeToolchain(self) + tc.cache_variables["CMAKE_EXPORT_COMPILE_COMMANDS"] = True + tc.cache_variables["CLOE_PROJECT_VERSION"] = self.version + tc.generate() + + def build(self): + cm = cmake.CMake(self) + if self.should_configure: + cm.configure() + if self.should_build: + cm.build() + if self.should_test: + cm.test() + + def package(self): + cm = cmake.CMake(self) + if self.should_install: + cm.install() + + def package_id(self): + self.info.requires["boost"].full_package_mode() + del self.info.options.pedantic + + def package_info(self): + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_file_name", "cloe-stack") + self.cpp_info.set_property("cmake_target_name", "cloe::stack") + self.cpp_info.set_property("pkg_config_name", "cloe-stack") + + # Make sure we can find the library, both in editable mode and in the + # normal package mode: + if not self.in_local_cache: + self.cpp_info.libs = ["cloe-stack"] + else: + self.cpp_info.libs = files.collect_libs(self) diff --git a/engine/src/plugin.hpp b/stack/include/cloe/plugin_loader.hpp similarity index 99% rename from engine/src/plugin.hpp rename to stack/include/cloe/plugin_loader.hpp index e51291cf2..e799e0585 100644 --- a/engine/src/plugin.hpp +++ b/stack/include/cloe/plugin_loader.hpp @@ -16,9 +16,8 @@ * SPDX-License-Identifier: Apache-2.0 */ /** - * \file plugin.hpp - * \see plugin.cpp - * \see version.hpp + * \file cloe/plugin_laoder.hpp + * \see cloe/plugin_loader.cpp */ #pragma once diff --git a/engine/src/stack.hpp b/stack/include/cloe/stack.hpp similarity index 99% rename from engine/src/stack.hpp rename to stack/include/cloe/stack.hpp index a650678c8..04a50fb56 100644 --- a/engine/src/stack.hpp +++ b/stack/include/cloe/stack.hpp @@ -32,8 +32,8 @@ #include // for move #include // for vector<> -#include // for CustomDeserializer -#include // for Factory +#include // for CustomDeserializer +#include // for Factory #include // for ComponentFactory #include // for ControllerFactory @@ -42,8 +42,8 @@ #include // for Source #include // for Command -#include "config.hpp" -#include "plugin.hpp" // for Plugin +#include // for Plugin +#include namespace cloe { @@ -870,7 +870,9 @@ class StackIncompleteError : public Error { explicit StackIncompleteError(std::vector&& missing); [[nodiscard]] std::string all_sections_missing(const std::string& sep = ", ") const; - [[nodiscard]] const std::vector& sections_missing() const { return sections_missing_; } + [[nodiscard]] const std::vector& sections_missing() const { + return sections_missing_; + } private: std::vector sections_missing_; diff --git a/engine/src/config.hpp b/stack/include/cloe/stack_config.hpp similarity index 100% rename from engine/src/config.hpp rename to stack/include/cloe/stack_config.hpp diff --git a/engine/src/stack_factory.hpp b/stack/include/cloe/stack_factory.hpp similarity index 100% rename from engine/src/stack_factory.hpp rename to stack/include/cloe/stack_factory.hpp diff --git a/engine/src/plugin.cpp b/stack/src/cloe/plugin_loader.cpp similarity index 98% rename from engine/src/plugin.cpp rename to stack/src/cloe/plugin_loader.cpp index 874b1e415..a2ade57dd 100644 --- a/engine/src/plugin.cpp +++ b/stack/src/cloe/plugin_loader.cpp @@ -16,11 +16,11 @@ * SPDX-License-Identifier: Apache-2.0 */ /** - * \file plugin.cpp - * \see plugin.hpp + * \file cloe/plugin_loader.cpp + * \see cloe/plugin_loader.hpp */ -#include "plugin.hpp" +#include "cloe/plugin_loader.hpp" #include // for dlopen, dlsym, RTLD_NOW, ... #include // for unique_ptr<> diff --git a/engine/src/stack.cpp b/stack/src/cloe/stack.cpp similarity index 99% rename from engine/src/stack.cpp rename to stack/src/cloe/stack.cpp index 6b6b9b620..7eee50fea 100644 --- a/engine/src/stack.cpp +++ b/stack/src/cloe/stack.cpp @@ -21,7 +21,7 @@ * \see stack_test.cpp */ -#include "stack.hpp" +#include "cloe/stack.hpp" #include // for transform, swap #include // for filesystem @@ -36,6 +36,8 @@ namespace fs = std::filesystem; #include // for indent_string #include // for starts_with +#include "cloe/plugin_loader.hpp" + namespace cloe { StackIncompleteError::StackIncompleteError(std::vector&& missing) diff --git a/engine/src/stack_component_test.cpp b/stack/src/cloe/stack_component_test.cpp similarity index 96% rename from engine/src/stack_component_test.cpp rename to stack/src/cloe/stack_component_test.cpp index 0889fb165..a3a41bf16 100644 --- a/engine/src/stack_component_test.cpp +++ b/stack/src/cloe/stack_component_test.cpp @@ -16,9 +16,9 @@ * SPDX-License-Identifier: Apache-2.0 */ /** - * \file stack_component_test.cpp - * \see stack.hpp - * \see stack.cpp + * \file cloe/stack_component_test.cpp + * \see cloe/stack.hpp + * \see cloe/stack.cpp */ #include @@ -30,8 +30,9 @@ #include // for ObjectSensor #include // for Json #include // for assert_from_conf -#include "stack.hpp" // for Stack -using namespace cloe; // NOLINT(build/namespaces) + +#include "cloe/stack.hpp" // for Stack +using namespace cloe; // NOLINT(build/namespaces) namespace { @@ -65,7 +66,7 @@ DEFINE_COMPONENT_FACTORY(DummySensorFactory, DummySensorConf, "dummy_object_sens DEFINE_COMPONENT_FACTORY_MAKE(DummySensorFactory, DummySensor, cloe::ObjectSensor) -} +} // namespace TEST(cloe_stack, deserialization_of_component) { // Create a sensor component from the given configuration. @@ -137,7 +138,7 @@ std::unique_ptr<::cloe::Component> FusionSensorFactory::make( return std::make_unique(this->name(), conf, obj_sensors, ego_sensors.front()); } -} +} // namespace TEST(cloe_stack, deserialization_of_fusion_component) { // Create a sensor component from the given configuration. diff --git a/engine/src/stack_factory.cpp b/stack/src/cloe/stack_factory.cpp similarity index 91% rename from engine/src/stack_factory.cpp rename to stack/src/cloe/stack_factory.cpp index a729dc74b..61b51aa2b 100644 --- a/engine/src/stack_factory.cpp +++ b/stack/src/cloe/stack_factory.cpp @@ -20,22 +20,22 @@ * \see stack_factory.hpp */ -#include "stack_factory.hpp" +#include "cloe/stack_factory.hpp" #include // for path #include // for ostream, cerr #include // for string #include // for vector<> +#include // for NopControllerFactory +#include // for NopControllerFactory #include // for split_string #include // for merge_config #include // for Environment #include // for pretty_print, read_conf_from_file -#include "config.hpp" // for CLOE_PLUGIN_PATH -#include "plugins/nop_controller.hpp" // for NopFactory -#include "plugins/nop_simulator.hpp" // for NopFactory -#include "stack.hpp" // for Stack +#include "cloe/stack.hpp" // for Stack +#include "cloe/stack_config.hpp" // for CLOE_PLUGIN_PATH namespace cloe { @@ -129,8 +129,10 @@ Stack new_stack(const StackOptions& opt) { // Insert built-in plugins: if (!opt.no_builtin_plugins) { - s.insert_plugin(make_plugin(), PluginConf{"builtin://controller/nop"}); - s.insert_plugin(make_plugin(), PluginConf{"builtin://simulator/nop"}); + s.insert_plugin(make_plugin(), + PluginConf{"builtin://controller/nop"}); + s.insert_plugin(make_plugin(), + PluginConf{"builtin://simulator/nop"}); } // Setup plugin path: diff --git a/engine/src/stack_test.cpp b/stack/src/cloe/stack_test.cpp similarity index 94% rename from engine/src/stack_test.cpp rename to stack/src/cloe/stack_test.cpp index 38b3f226f..536272d7c 100644 --- a/engine/src/stack_test.cpp +++ b/stack/src/cloe/stack_test.cpp @@ -16,19 +16,20 @@ * SPDX-License-Identifier: Apache-2.0 */ /** - * \file stack_test.cpp - * \see stack.hpp - * \see stack.cpp + * \file cloe/stack_test.cpp + * \see cloe/stack.hpp + * \see cloe/stack.cpp */ #include #include #include -#include // for Json -#include // for assert_from_conf -#include "stack.hpp" // for Stack -using namespace cloe; // NOLINT(build/namespaces) +#include // for Json +#include // for assert_from_conf + +#include "cloe/stack.hpp" // for Stack +using namespace cloe; // NOLINT(build/namespaces) TEST(cloe_stack, serialization_of_empty_stack) { Stack s; From 63969458effcd1a50077e794d801a1f1a75280d4 Mon Sep 17 00:00:00 2001 From: Benjamin Morgan Date: Tue, 9 Jul 2024 12:18:07 +0200 Subject: [PATCH 3/4] osi: Fix compatiblity with protobuf > v25 --- osi/src/cloe/utility/osi_utils.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/osi/src/cloe/utility/osi_utils.cpp b/osi/src/cloe/utility/osi_utils.cpp index 1015bdab1..4ed349879 100644 --- a/osi/src/cloe/utility/osi_utils.cpp +++ b/osi/src/cloe/utility/osi_utils.cpp @@ -26,6 +26,7 @@ #include // for Isometry3d, Vector3d +#include // for GOOGLE_PROTOBUF_VERSION #include // for JsonPrint #include // for quaternion_from_rpy @@ -41,8 +42,10 @@ template void osi_to_json(const OSI_T& msg, std::string* json_string) { google::protobuf::util::JsonPrintOptions options; options.add_whitespace = true; +#if GOOGLE_PROTOBUF_VERSION < 5026000 options.always_print_primitive_fields = true; - google::protobuf::util::MessageToJsonString(msg, json_string, options); +#endif + std::ignore = google::protobuf::util::MessageToJsonString(msg, json_string, options); } template void osi_to_json(const osi3::SensorData& msg, std::string* json_string); From 2cdac8c4d7fcee25e2b4f2641882c8bd113996f9 Mon Sep 17 00:00:00 2001 From: Benjamin Morgan Date: Fri, 5 Jul 2024 15:24:56 +0200 Subject: [PATCH 4/4] tooling: Add Bazel support --- .bazelrc | 14 ++++ .gitignore | 14 ++++ BUILD.bazel | 8 ++ MODULE.bazel | 31 ++++++++ README.md | 31 ++++++++ WORKSPACE.bazel | 0 cloe_shell.sh | 18 +++++ engine/BUILD.bazel | 65 ++++++++++++++++ engine/vendor/linenoise/BUILD.bazel | 16 ++++ engine/vendor/lrdb/BUILD.bazel | 23 ++++++ fable/BUILD.bazel | 38 +++++++++ fable/examples/contacts/BUILD.bazel | 21 +++++ fable/examples/simple_config/BUILD.bazel | 20 +++++ models/BUILD.bazel | 21 +++++ oak/BUILD.bazel | 20 +++++ oak/src/oak/registrar.cpp | 7 +- oak/src/oak/route_muxer_test.cpp | 2 +- oak/src/oak/server.cpp | 5 +- oak/src/oak/server_test.cpp | 7 +- osi/BUILD.bazel | 25 ++++++ plugin.bzl | 98 ++++++++++++++++++++++++ plugins/basic/BUILD.bazel | 38 +++++++++ plugins/clothoid_fit/BUILD.bazel | 61 +++++++++++++++ plugins/gndtruth_extractor/BUILD.bazel | 27 +++++++ plugins/minimator/BUILD.bazel | 30 ++++++++ plugins/mocks/BUILD.bazel | 23 ++++++ plugins/noisy_sensor/BUILD.bazel | 38 +++++++++ plugins/speedometer/BUILD.bazel | 12 +++ plugins/virtue/BUILD.bazel | 12 +++ runtime/BUILD.bazel | 55 +++++++++++++ stack/BUILD.bazel | 27 +++++++ version.bzl | 2 + 32 files changed, 800 insertions(+), 9 deletions(-) create mode 100644 .bazelrc create mode 100644 BUILD.bazel create mode 100644 MODULE.bazel create mode 100644 WORKSPACE.bazel create mode 100755 cloe_shell.sh create mode 100644 engine/BUILD.bazel create mode 100644 engine/vendor/linenoise/BUILD.bazel create mode 100644 engine/vendor/lrdb/BUILD.bazel create mode 100644 fable/BUILD.bazel create mode 100644 fable/examples/contacts/BUILD.bazel create mode 100644 fable/examples/simple_config/BUILD.bazel create mode 100644 models/BUILD.bazel create mode 100644 oak/BUILD.bazel create mode 100644 osi/BUILD.bazel create mode 100644 plugin.bzl create mode 100644 plugins/basic/BUILD.bazel create mode 100644 plugins/clothoid_fit/BUILD.bazel create mode 100644 plugins/gndtruth_extractor/BUILD.bazel create mode 100644 plugins/minimator/BUILD.bazel create mode 100644 plugins/mocks/BUILD.bazel create mode 100644 plugins/noisy_sensor/BUILD.bazel create mode 100644 plugins/speedometer/BUILD.bazel create mode 100644 plugins/virtue/BUILD.bazel create mode 100644 runtime/BUILD.bazel create mode 100644 stack/BUILD.bazel create mode 100644 version.bzl diff --git a/.bazelrc b/.bazelrc new file mode 100644 index 000000000..24f085b0d --- /dev/null +++ b/.bazelrc @@ -0,0 +1,14 @@ +common --enable_bzlmod +common --registry=https://bcr.bazel.build +try-import %workspace%/.bazelrc.user + +# bazel from apt needs access to this cacerts location +startup --host_jvm_args=-Djavax.net.ssl.trustStore=/etc/ssl/certs/java/cacerts + +# So we can support private dependencies +build --experimental_cc_implementation_deps + +build --action_env=BAZEL_CXXOPTS="-std=c++17" +build --strip=never +build --copt='-O2' +build --conlyopt='-std=c11' diff --git a/.gitignore b/.gitignore index 6cd13c76c..c97e8cf42 100644 --- a/.gitignore +++ b/.gitignore @@ -58,3 +58,17 @@ callgrind.out.* # Miscellaneous *.log /.gtm/ + +# Ignore all bazel-* symlinks. There is no full list since this can change +# based on the name of the directory bazel is cloned into. +/bazel-* +MODULE.bazel.lock +.bazelrc.user +external/ + +# Directories for the Bazel IntelliJ plugin containing the generated +# IntelliJ project files and plugin configuration. Seperate directories are +# for the IntelliJ, Android Studio and CLion versions of the plugin. +/.ijwb/ +/.aswb/ +/.clwb/ diff --git a/BUILD.bazel b/BUILD.bazel new file mode 100644 index 000000000..d357b8612 --- /dev/null +++ b/BUILD.bazel @@ -0,0 +1,8 @@ +load("//:plugin.bzl", "CLOE_PLUGINS") + +sh_binary( + name = "cloe_shell", + srcs = ["cloe_shell.sh"], + args = ["$(location //engine:cloe-engine)"] + ["$(location {})".format(p) for p in CLOE_PLUGINS], + data = ["//engine:cloe-engine"] + CLOE_PLUGINS + glob(["tests/*"]), +) diff --git a/MODULE.bazel b/MODULE.bazel new file mode 100644 index 000000000..d3d1b98e2 --- /dev/null +++ b/MODULE.bazel @@ -0,0 +1,31 @@ +module(name = "cloe", version = "0.25.0") + +# Build dependencies: +bazel_dep(name = "cmake_configure_file", version = "0.1.0") +bazel_dep(name = "rules_cc", version = "0.0.9") + +# Test dependencies: +bazel_dep(name = "googletest", version = "1.14.0", repo_name = "gtest") + +# Library dependencies: +bazel_dep(name = "boost", version = "1.83.0.bcr.1") +bazel_dep(name = "cli11", version = "2.3.2") +bazel_dep(name = "eigen", version = "3.4.0.bcr.1") +bazel_dep(name = "fmt", version = "10.2.1") +bazel_dep(name = "incbin", version = "20211106.0") +bazel_dep(name = "inja", version = "3.4.0") +bazel_dep(name = "lua", version = "5.4.6") +bazel_dep(name = "nlohmann_json", version = "3.11.3") +bazel_dep(name = "oatpp", version = "1.3.0") +bazel_dep(name = "sol", version = "3.3.1") +bazel_dep(name = "spdlog", version = "1.13.0") +bazel_dep(name = "open-simulation-interface", version = "3.5.0") +bazel_dep(name = "protobuf", version = "26.0") + +# Tooling dependencies: +bazel_dep(name = "hedron_compile_commands", dev_dependency = True) +git_override( + module_name = "hedron_compile_commands", + remote = "https://github.com/hedronvision/bazel-compile-commands-extractor.git", + commit = "1e08f8e0507b6b6b1f4416a9a22cf5c28beaba93", # 2024-07-04 +) diff --git a/README.md b/README.md index 092c93472..79ed33133 100644 --- a/README.md +++ b/README.md @@ -194,6 +194,37 @@ When using `make` to build the project, add this to the command line: CONAN_OPTIONS="-c tools.build:skip_test=1" +## Building with Bazel + +Bazel tooling is currently experimental, and is meant to support users +who already are using Bazel in their projects and are not afraid of +providing their own registries and modules for Cloe's dependencies. + +(That allows us to not have to vendor massive amounts of Bazel modules +in this repository, of which Boost is the main problematic point. +Once Boost makes it into the Bazel Central Registry, it may be worthwhile +to vendor the remaining libraries in this repository.) + +You will need to create a `.bazelrc.user` file in the repository root +with the following contents: + + common --registry=file:///path/to/your/bazel/registry + +This file is ignored by Git to prevent you from exposing your secrets. +The registry should contain the following modules: + + boost + cli11 + esmini + incbin + inja + luajit (optional) + oatpp + open-simulation-interface + sol + +The rest of the dependencies are taken from the Bazel Central Registry. +See `MODULE.bazel` for the full list. ### Building Docker Images diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel new file mode 100644 index 000000000..e69de29bb diff --git a/cloe_shell.sh b/cloe_shell.sh new file mode 100755 index 000000000..9275dd172 --- /dev/null +++ b/cloe_shell.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +export CLOE_LOG_LEVEL=debug +export CLOE_STRICT_MODE=1 +export CLOE_ROOT="$(pwd)" +export CLOE_ENGINE="${CLOE_ROOT}/$1" +export CLOE_LUA_PATH="${CLOE_ROOT}/engine/lua" +export PATH="$(dirname "$CLOE_ENGINE"):$PATH" + +# Set plugin paths +shift 1 +while [[ $# -ne 0 ]]; do + CLOE_PLUGIN_PATH="${CLOE_ROOT}/$(dirname "$1"):$CLOE_PLUGIN_PATH" + shift 1 +done +export CLOE_PLUGIN_PATH + +exec $SHELL diff --git a/engine/BUILD.bazel b/engine/BUILD.bazel new file mode 100644 index 000000000..d514ac890 --- /dev/null +++ b/engine/BUILD.bazel @@ -0,0 +1,65 @@ +load("//:version.bzl", "PROJECT_VERSION") + +cc_library( + name = "enginelib", + hdrs = glob(["src/**/*.hpp"], exclude=["src/main*.hpp"]), + srcs = glob( + ["src/**/*.cpp"], + exclude=[ + "src/main*.cpp", + "src/**/*_test.cpp", + "src/server_mock.cpp", + ] + ), + data = glob(["lua/**"]), + includes = ["src"], + additional_compiler_inputs = glob(["webui/**"]), + deps = [ + "//engine/vendor/lrdb", + "//engine/vendor/linenoise", + "//stack", + "//fable", + "//runtime", + "//models", + "//oak", + "@boost//:algorithm", + "@boost//:conversion", + "@boost//:optional", + "@boost//:process", + "@boost//:uuid", + "@sol", + ], + defines = [ + "CLOE_ENGINE_VERSION=\\\"{}\\\"".format(PROJECT_VERSION), + "CLOE_ENGINE_TIMESTAMP=\\\"unknown\\\"", + "CLOE_ENGINE_WITH_SERVER=1", + "CLOE_ENGINE_WITH_LRDB=1", + "PROJECT_SOURCE_DIR=\\\"engine\\\"", + ], + linkopts = [ + "-lpthread", + ], +) + +cc_test( + name = "engine_test", + srcs = glob(["src/**/*_test.cpp"]), + defines = [ + "CLOE_LUA_PATH=\\\"" + package_name() + "/lua\\\"", + ], + deps = [ + ":enginelib", + "@gtest//:gtest_main", + ], +) + +cc_binary( + name = "cloe-engine", + srcs = glob(["src/main*.hpp", "src/main*.cpp"]), + includes = ["src"], + deps = [ + ":enginelib", + "@cli11", + ], + visibility = ["//visibility:public"], +) diff --git a/engine/vendor/linenoise/BUILD.bazel b/engine/vendor/linenoise/BUILD.bazel new file mode 100644 index 000000000..e2e354ae4 --- /dev/null +++ b/engine/vendor/linenoise/BUILD.bazel @@ -0,0 +1,16 @@ +cc_library( + name = "linenoise", + hdrs = ["linenoise.h"], + srcs = ["linenoise.c"], + includes = ["."], + local_defines = [ + "__STDC_WANT_LIB_EXT2__=1", + ], + visibility = ["//visibility:public"], +) + +cc_test( + name = "linenoise_example", + srcs = ["example.c"], + deps = [":linenoise"], +) diff --git a/engine/vendor/lrdb/BUILD.bazel b/engine/vendor/lrdb/BUILD.bazel new file mode 100644 index 000000000..d81fd7d03 --- /dev/null +++ b/engine/vendor/lrdb/BUILD.bazel @@ -0,0 +1,23 @@ +cc_library( + name = "lrdb", + hdrs = glob(["include/**/*.hpp"]), + includes = ["include"], + defines = [ + "LRDB_USE_BOOST_ASIO=1", + ], + deps = [ + ":picojson", + "@lua", + "@boost//:asio", + ], + linkopts = [ + "-lpthread", + ], + visibility = ["//visibility:public"], +) + +cc_library( + name = "picojson", + hdrs = ["third_party/picojson/picojson.h"], + includes = ["third_party/picojson"], +) diff --git a/fable/BUILD.bazel b/fable/BUILD.bazel new file mode 100644 index 000000000..bebdf8000 --- /dev/null +++ b/fable/BUILD.bazel @@ -0,0 +1,38 @@ +load( + "@cmake_configure_file//:cmake_configure_file.bzl", + "cmake_configure_file", +) +load("//:version.bzl", "PROJECT_VERSION", "PROJECT_VERSION_U32") + +cmake_configure_file( + name = "fable_version_hpp", + src = "src/fable/version.hpp.in", + out = "include/fable/version.hpp", + defines = [ + "FABLE_VERSION={}".format(PROJECT_VERSION), + "FABLE_VERSION_U32={}".format(PROJECT_VERSION_U32), + ] +) + +cc_library( + name = "fable", + srcs = glob(["src/**/*.cpp"], exclude=["src/**/*_test.cpp"]), + hdrs = glob(["include/**/*.hpp"]) + [":fable_version_hpp"], + includes = [ "include" ], + deps = [ + "@fmt", + "@nlohmann_json//:json", + ], + visibility = ["//visibility:public"], +) + +cc_test( + name = "fable_test", + srcs = glob(["src/**/*_test.cpp"]), + deps = [ + ":fable", + "@sol", + "@boost//:optional", + "@gtest//:gtest_main", + ], +) diff --git a/fable/examples/contacts/BUILD.bazel b/fable/examples/contacts/BUILD.bazel new file mode 100644 index 000000000..d5414fd0f --- /dev/null +++ b/fable/examples/contacts/BUILD.bazel @@ -0,0 +1,21 @@ +filegroup( + name = "inputs", + srcs = [ + "example_addressbook.json", + "invalid_addressbook.json", + ] +) + +cc_binary( + name = "contacts", + srcs = [ + "src/main.cpp", + ], + deps = [ + "//fable", + "@cli11", + ], + data = [ + ":inputs", + ] +) diff --git a/fable/examples/simple_config/BUILD.bazel b/fable/examples/simple_config/BUILD.bazel new file mode 100644 index 000000000..939f33973 --- /dev/null +++ b/fable/examples/simple_config/BUILD.bazel @@ -0,0 +1,20 @@ +filegroup( + name = "inputs", + srcs = [ + "example_input.json", + ] +) + +cc_binary( + name = "simple_config", + srcs = [ + "src/main.cpp", + ], + deps = [ + "//fable", + "@cli11", + ], + data = [ + ":inputs", + ] +) diff --git a/models/BUILD.bazel b/models/BUILD.bazel new file mode 100644 index 000000000..bdc57a024 --- /dev/null +++ b/models/BUILD.bazel @@ -0,0 +1,21 @@ +cc_library( + name = "models", + hdrs = glob(["include/**/*.hpp"]), + srcs = glob(["src/**/*.cpp"], exclude=["src/**/*_test.cpp"]), + includes = [ "include" ], + deps = [ + "//runtime", + "@boost//:optional", + "@eigen", + ], + visibility = ["//visibility:public"], +) + +cc_test( + name = "models_test", + srcs = glob(["src/**/*_test.cpp"]), + deps = [ + ":models", + "@gtest//:gtest_main", + ], +) diff --git a/oak/BUILD.bazel b/oak/BUILD.bazel new file mode 100644 index 000000000..5f19730a0 --- /dev/null +++ b/oak/BUILD.bazel @@ -0,0 +1,20 @@ +cc_library( + name = "oak", + hdrs = glob(["include/**/*.hpp"]), + srcs = glob(["src/**"], exclude=["src/**/*_test.cpp"]), + includes = [ "include" ], + deps = [ + "//runtime", + "@oatpp", + ], + visibility = ["//visibility:public"], +) + +cc_test( + name = "models_test", + srcs = glob(["src/**/*_test.cpp", "src/**/*.hpp"]), + deps = [ + ":oak", + "@gtest//:gtest_main", + ], +) diff --git a/oak/src/oak/registrar.cpp b/oak/src/oak/registrar.cpp index f7a5b54c9..1878ad5c4 100644 --- a/oak/src/oak/registrar.cpp +++ b/oak/src/oak/registrar.cpp @@ -20,7 +20,7 @@ * \see oak/registrar.hpp */ -#include "oak/registrar.hpp" +#include #include #include @@ -30,8 +30,9 @@ #include // for Request, Response, Handler -#include "oak/request_stub.hpp" // for RequestStub -#include "oak/server.hpp" // for Server +#include // for Server + +#include "request_stub.hpp" // for RequestStub namespace oak { diff --git a/oak/src/oak/route_muxer_test.cpp b/oak/src/oak/route_muxer_test.cpp index 56c385d08..9ed9f0ce1 100644 --- a/oak/src/oak/route_muxer_test.cpp +++ b/oak/src/oak/route_muxer_test.cpp @@ -28,7 +28,7 @@ #include // for vector<> using namespace std; // NOLINT(build/namespaces) -#include "oak/route_muxer.hpp" // for Muxer<> +#include // for Muxer<> using oak::Muxer; using oak::Parameters; diff --git a/oak/src/oak/server.cpp b/oak/src/oak/server.cpp index 07c8e54c1..6a2cb119d 100644 --- a/oak/src/oak/server.cpp +++ b/oak/src/oak/server.cpp @@ -38,8 +38,9 @@ #include // for Json using namespace cloe; // NOLINT(build/namespaces) -#include "oak/request_stub.hpp" // for RequestStub -#include "oak/route_muxer.hpp" // for Muxer<> +#include // for Muxer<> + +#include "request_stub.hpp" // for RequestStub namespace oak { diff --git a/oak/src/oak/server_test.cpp b/oak/src/oak/server_test.cpp index 79aee30e3..ce6bb4980 100644 --- a/oak/src/oak/server_test.cpp +++ b/oak/src/oak/server_test.cpp @@ -38,9 +38,10 @@ #include #include -#include "oak/curl.hpp" // for Curl -#include "oak/registrar.hpp" // for Registrar -#include "oak/server.hpp" // for Server +#include // for Registrar +#include // for Server + +#include "curl.hpp" // for Curl using namespace std; // NOLINT(build/namespaces) diff --git a/osi/BUILD.bazel b/osi/BUILD.bazel new file mode 100644 index 000000000..7414803e8 --- /dev/null +++ b/osi/BUILD.bazel @@ -0,0 +1,25 @@ +cc_library( + name = "osi", + srcs = glob(["src/**/*.cpp"], exclude=["src/**/*_test.cpp"]), + hdrs = glob(["include/**/*.hpp"]), + includes = [ "include" ], + deps = [ + "//fable", + "//models", + "//runtime", + "@boost//:asio", + "@eigen", + "@open-simulation-interface//:osi_cc_proto", + "@protobuf", + ], + visibility = ["//visibility:public"], +) + +cc_test( + name = "osi_test", + srcs = glob(["src/**/*_test.cpp"]), + deps = [ + ":osi", + "@gtest//:gtest_main", + ], +) diff --git a/plugin.bzl b/plugin.bzl new file mode 100644 index 000000000..f90b3b624 --- /dev/null +++ b/plugin.bzl @@ -0,0 +1,98 @@ +CLOE_PLUGINS = [ + "//plugins/basic", + "//plugins/clothoid_fit", + # "//plugins/esmini", + "//plugins/gndtruth_extractor", + "//plugins/minimator", + "//plugins/mocks:demo_stuck", + "//plugins/mocks:demo_printer", + "//plugins/noisy_sensor:noisy_object_sensor", + "//plugins/noisy_sensor:noisy_lane_sensor", + "//plugins/speedometer", + "//plugins/virtue", +] + +def cloe_plugin( + name, + copts = None, + visibility = None, + **kwargs, +): + """ + Defines a cc_binary target for a cloe plugin. + + See: https://docs.bazel.build/versions/master/be/c-cpp.html#cc_binary + + Args: + name: plugin name + **kwargs: additional cc_binary args + + Defaults: + copts: ["-fvisibility=hidden", "-fvisibility-inlines-hidden"] + visibility: ["//visibility:public"] + linkshared: True (forced) + """ + + # Set default for copts: + if copts == None: + copts = [] + copts += [ + "-fvisibility=hidden", + "-fvisibility-inlines-hidden", + ] + + # Set default for visibility: + if visibility == None: + visibility = ["//visibility:public"] + + # Check correct usage: + if "linkshared" in kwargs: + fail("cloe_plugin: linkshared must be True, do not set it yourself") + + # Create target: + native.cc_binary( + name = name, + copts = copts, + linkshared = True, + visibility = visibility, + **kwargs, + ) + +def cloe_plugin_library( + name, + copts = None, + **kwargs, +): + """ + Defines a cc_library target for a cloe plugin. + + See: https://docs.bazel.build/versions/master/be/c-cpp.html#cc_library + + Args: + name: plugin name + **kwargs: additional cc_binary args + + Defaults: + copts: ["-fvisibility=hidden", "-fvisibility-inlines-hidden"] + alwayslink: True (forced) + """ + + # Set default for copts: + if copts == None: + copts = [] + copts += [ + "-fvisibility=hidden", + "-fvisibility-inlines-hidden", + ] + + # Check correct usage: + if "alwayslink" in kwargs: + fail("cloe_plugin_library: alwayslink must be True, do not set it yourself") + + # Create target: + native.cc_library( + name = name, + copts = copts, + alwayslink = True, + **kwargs, + ) diff --git a/plugins/basic/BUILD.bazel b/plugins/basic/BUILD.bazel new file mode 100644 index 000000000..91f1fc592 --- /dev/null +++ b/plugins/basic/BUILD.bazel @@ -0,0 +1,38 @@ +load("//:plugin.bzl", "cloe_plugin", "cloe_plugin_library") + +cloe_plugin( + name = "basic", + deps = [ + ":basic_impl", + ], +) + +cloe_plugin_library( + name = "basic_impl", + hdrs = glob(["src/*.hpp"]), + srcs = glob(["src/*.cpp"], exclude=["src/*_test.cpp", "src/plugin.cpp"]), + additional_compiler_inputs = [":basic_ui"], + includes = ["src"], + local_defines = [ + "PROJECT_SOURCE_DIR=\\\"" + package_name() + "\\\"", + ], + data = [":basic_ui"], + deps = [ + "//runtime", + "//models", + ], +) + +filegroup( + name = "basic_ui", + srcs = glob(["ui/**"]), +) + +cc_test( + name = "basic_test", + srcs = glob(["src/*_test.cpp", "src/*.hpp"]), + deps = [ + ":basic_impl", + "@gtest//:gtest_main", + ] +) diff --git a/plugins/clothoid_fit/BUILD.bazel b/plugins/clothoid_fit/BUILD.bazel new file mode 100644 index 000000000..d485afd43 --- /dev/null +++ b/plugins/clothoid_fit/BUILD.bazel @@ -0,0 +1,61 @@ +load("//:plugin.bzl", "cloe_plugin", "cloe_plugin_library") + +cloe_plugin( + name = "clothoid_fit", + deps = [ + ":clothoid_fit_impl", + ], +) + +cloe_plugin_library( + name = "clothoid_fit_impl", + hdrs = [ + "src/clothoid_fit.hpp" + ], + srcs = [ + "src/clothoid_fit.cpp" + ], + includes = [ + "src" + ], + deps = [ + ":g1_fitting", + "//runtime", + "//models", + "@eigen", + ], +) + +cc_test( + name = "clothoid_fit_test", + srcs = ["src/clothoid_fit.cpp"], + deps = [ + ":clothoid_fit_impl", + "@gtest//:gtest_main", + ] +) + +cc_library( + name = "g1_fitting", + hdrs = [ + "src/g1_fitting.hpp", + ], + srcs = [ + "src/g1_fitting.cpp" + ], + deps = [ + "@eigen", + ], + includes = [ + "src", + ], +) + +cc_test( + name = "g1_fitting_test", + srcs = ["src/g1_fitting_test.cpp"], + deps = [ + ":g1_fitting", + "@gtest//:gtest_main", + ] +) diff --git a/plugins/gndtruth_extractor/BUILD.bazel b/plugins/gndtruth_extractor/BUILD.bazel new file mode 100644 index 000000000..5e5ea7048 --- /dev/null +++ b/plugins/gndtruth_extractor/BUILD.bazel @@ -0,0 +1,27 @@ +load("//:plugin.bzl", "cloe_plugin", "cloe_plugin_library") + +cloe_plugin( + name = "gndtruth_extractor", + deps = [ + ":gndtruth_extractor_impl", + ] +) + +cloe_plugin_library( + name = "gndtruth_extractor_impl", + srcs = glob(["src/*.cpp", "src/*.hpp"], exclude=["src/*_test.cpp"]), + includes = ["src"], + deps = [ + "//runtime", + "//models", + ], +) + +cc_test( + name = "gndtruth_extractor_test", + srcs = glob(["src/*_test.cpp"]), + deps = [ + ":gndtruth_extractor_impl", + "@gtest//:gtest_main", + ] +) diff --git a/plugins/minimator/BUILD.bazel b/plugins/minimator/BUILD.bazel new file mode 100644 index 000000000..d6d23666d --- /dev/null +++ b/plugins/minimator/BUILD.bazel @@ -0,0 +1,30 @@ +load("//:plugin.bzl", "cloe_plugin", "cloe_plugin_library") + +cloe_plugin( + name = "minimator", + deps = [ + ":minimator_impl", + ], +) + +cloe_plugin_library( + name = "minimator_impl", + hdrs = glob(["include/**"]), + srcs = glob(["src/**"], exclude=["src/*_test.cpp"]), + includes = ["include"], + deps = [ + "//runtime", + "//models", + ], +) + +cc_test( + name = "minimator_test", + srcs = [ + "src/minimator_config_test.cpp", + ], + deps = [ + ":minimator_impl", + "@gtest//:gtest_main", + ] +) diff --git a/plugins/mocks/BUILD.bazel b/plugins/mocks/BUILD.bazel new file mode 100644 index 000000000..19fcefd8f --- /dev/null +++ b/plugins/mocks/BUILD.bazel @@ -0,0 +1,23 @@ +load("//:plugin.bzl", "cloe_plugin") + +cloe_plugin( + name = "demo_stuck", + srcs = [ + "src/demo_stuck.cpp", + ], + deps = [ + "//runtime", + "//models", + ], +) + +cloe_plugin( + name = "demo_printer", + srcs = [ + "src/demo_printer.cpp", + ], + deps = [ + "//runtime", + "//models", + ], +) diff --git a/plugins/noisy_sensor/BUILD.bazel b/plugins/noisy_sensor/BUILD.bazel new file mode 100644 index 000000000..613966f8c --- /dev/null +++ b/plugins/noisy_sensor/BUILD.bazel @@ -0,0 +1,38 @@ +load("//:plugin.bzl", "cloe_plugin") + +cloe_plugin( + name = "noisy_object_sensor", + srcs = [ + "src/noise_data.hpp", + "src/noisy_object_sensor.cpp", + ], + deps = [ + "//runtime", + "//models", + ], +) + +cloe_plugin( + name = "noisy_lane_sensor", + srcs = [ + "src/noise_data.hpp", + "src/noisy_lane_sensor.cpp", + ], + deps = [ + "//runtime", + "//models", + ], +) + +cc_test( + name = "noisy_sensor_test", + srcs = [ + "src/noise_data.hpp", + "src/noisy_sensor_test.cpp", + ], + deps = [ + "//runtime", + "//models", + "@gtest//:gtest_main", + ] +) diff --git a/plugins/speedometer/BUILD.bazel b/plugins/speedometer/BUILD.bazel new file mode 100644 index 000000000..0cc6ee2df --- /dev/null +++ b/plugins/speedometer/BUILD.bazel @@ -0,0 +1,12 @@ +load("//:plugin.bzl", "cloe_plugin") + +cloe_plugin( + name = "speedometer", + srcs = [ + "src/speedometer.cpp", + ], + deps = [ + "//runtime", + "//models", + ], +) diff --git a/plugins/virtue/BUILD.bazel b/plugins/virtue/BUILD.bazel new file mode 100644 index 000000000..27c113356 --- /dev/null +++ b/plugins/virtue/BUILD.bazel @@ -0,0 +1,12 @@ +load("//:plugin.bzl", "cloe_plugin") + +cloe_plugin( + name = "virtue", + srcs = [ + "src/virtue.cpp", + ], + deps = [ + "//runtime", + "//models", + ], +) diff --git a/runtime/BUILD.bazel b/runtime/BUILD.bazel new file mode 100644 index 000000000..2c7d14c98 --- /dev/null +++ b/runtime/BUILD.bazel @@ -0,0 +1,55 @@ +load( + "@cmake_configure_file//:cmake_configure_file.bzl", + "cmake_configure_file", +) +load("//:version.bzl", "PROJECT_VERSION", "PROJECT_VERSION_U32") + +cmake_configure_file( + name = "cloe_version_hpp", + src = "src/cloe/version.hpp.in", + out = "include/cloe/version.hpp", + defines = [ + "CLOE_VERSION={}".format(PROJECT_VERSION), + "CLOE_VERSION_U32={}".format(PROJECT_VERSION_U32), + ] +) + +cc_library( + name = "runtime", + srcs = glob(["src/**/*.cpp"], exclude=["src/**/*_test.cpp"]), + hdrs = glob(["include/**/*.hpp"]) + [":cloe_version_hpp"], + includes = [ "include" ], + deps = [ + "//fable", + "@boost//:accumulators", + "@boost//:algorithm", + "@boost//:assign", + "@boost//:bimap", + "@boost//:conversion", + "@boost//:filesystem", + "@boost//:iostreams", + "@boost//:optional", + "@boost//:process", + "@boost//:range", + "@boost//:system", + "@fmt", + "@incbin", + "@inja", + "@sol", + "@spdlog", + ], + defines = [ + "_USE_MATH_DEFINES=1", + ], + visibility = ["//visibility:public"], + linkstatic = False, +) + +cc_test( + name = "runtime_test", + srcs = glob(["src/**/*_test.cpp"]), + deps = [ + ":runtime", + "@gtest//:gtest_main", + ], +) diff --git a/stack/BUILD.bazel b/stack/BUILD.bazel new file mode 100644 index 000000000..854e8f138 --- /dev/null +++ b/stack/BUILD.bazel @@ -0,0 +1,27 @@ +cc_library( + name = "stack", + hdrs = glob(["include/**/*.hpp"]), + srcs = glob(["src/**/*.cpp"], exclude=["src/**/*_test.cpp"]), + includes = ["include"], + deps = [ + "//fable", + "//runtime", + "//models", + "@boost//:algorithm", + "@boost//:optional", + "@boost//:filesystem", + ], + linkopts = [ + "-ldl", + ], + visibility = ["//visibility:public"], +) + +cc_test( + name = "stack_test", + srcs = glob(["src/**/*_test.cpp"]), + deps = [ + ":stack", + "@gtest//:gtest_main", + ], +) diff --git a/version.bzl b/version.bzl new file mode 100644 index 000000000..21e5dc2ed --- /dev/null +++ b/version.bzl @@ -0,0 +1,2 @@ +PROJECT_VERSION = "0.25.0" +PROJECT_VERSION_U32 = (0<<24) | (0 << 16) | (25 << 8) | 0