From 2cdac8c4d7fcee25e2b4f2641882c8bd113996f9 Mon Sep 17 00:00:00 2001 From: Benjamin Morgan Date: Fri, 5 Jul 2024 15:24:56 +0200 Subject: [PATCH] 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