diff --git a/modules/lanelet2/1.2.2/MODULE.bazel b/modules/lanelet2/1.2.2/MODULE.bazel new file mode 100644 index 00000000000..240fe8b54e6 --- /dev/null +++ b/modules/lanelet2/1.2.2/MODULE.bazel @@ -0,0 +1,30 @@ +module( + name = "lanelet2", + version = "1.2.2", +) + +BOOST_VERSION = "1.83.0" + +bazel_dep(name = "boost.config", version = BOOST_VERSION + ".bcr.1") +bazel_dep(name = "boost.core", version = BOOST_VERSION + ".bcr.1") +bazel_dep(name = "boost.filesystem", version = BOOST_VERSION + ".bcr.1") +bazel_dep(name = "boost.format", version = BOOST_VERSION + ".bcr.1") +bazel_dep(name = "boost.geometry", version = BOOST_VERSION + ".bcr.1") +bazel_dep(name = "boost.graph", version = BOOST_VERSION + ".bcr.1") +bazel_dep(name = "boost.iterator", version = BOOST_VERSION + ".bcr.1") +bazel_dep(name = "boost.lexical_cast", version = BOOST_VERSION + ".bcr.1") +bazel_dep(name = "boost.optional", version = BOOST_VERSION + ".bcr.1") +bazel_dep(name = "boost.polygon", version = BOOST_VERSION + ".bcr.1") +bazel_dep(name = "boost.program_options", version = BOOST_VERSION + ".bcr.1") +bazel_dep(name = "boost.property_map", version = BOOST_VERSION + ".bcr.1") +bazel_dep(name = "boost.serialization", version = BOOST_VERSION + ".bcr.1") +bazel_dep(name = "boost.type_traits", version = BOOST_VERSION + ".bcr.1") +bazel_dep(name = "boost.units", version = BOOST_VERSION) +bazel_dep(name = "boost.variant", version = BOOST_VERSION + ".bcr.1") +bazel_dep(name = "eigen", version = "3.4.0.bcr.1") +bazel_dep(name = "geographiclib", version = "2.4.0.bcr.1") +bazel_dep(name = "googletest", version = "1.15.2", repo_name = "com_google_googletest") +bazel_dep(name = "platforms", version = "0.0.9") +bazel_dep(name = "pugixml", version = "1.14.bcr.1") +bazel_dep(name = "rules_cc", version = "0.1.0") +bazel_dep(name = "rules_license", version = "1.0.0") diff --git a/modules/lanelet2/1.2.2/overlay/BUILD.bazel b/modules/lanelet2/1.2.2/overlay/BUILD.bazel new file mode 100644 index 00000000000..fa74dc3f489 --- /dev/null +++ b/modules/lanelet2/1.2.2/overlay/BUILD.bazel @@ -0,0 +1,242 @@ +"""Bazel build file for lanelet2 libraries""" + +load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") +load("@rules_license//rules:license.bzl", "license") + +package(default_applicable_licenses = [":license"]) + +license( + name = "license", + license_kinds = ["@rules_license//licenses/spdx:BSD-3-Clause"], + license_text = "LICENSE", +) + +cc_library( + name = "lanelet2_core", + srcs = glob(["lanelet2_core/src/**/*.cpp"]), + hdrs = glob(["lanelet2_core/include/**/*.h"]), + copts = select({ + "@platforms//os:windows": [], + "//conditions:default": [ + "-Wno-sign-compare", + "-Wno-unused-function", + "-Wno-unused-local-typedefs", + ], + }), + includes = ["lanelet2_core/include"], + visibility = ["//visibility:public"], + deps = [ + "@boost.config", + "@boost.core", + "@boost.geometry", + "@boost.iterator", + "@boost.lexical_cast", + "@boost.optional", + "@boost.polygon", + "@boost.type_traits", + "@boost.units", + "@boost.variant", + "@eigen", + ], +) + +cc_library( + name = "lanelet2_io", + srcs = glob(["lanelet2_io/src/**/*.cpp"]), + hdrs = glob(["lanelet2_io/include/**/*.h"]), + includes = ["lanelet2_io/include"], + visibility = ["//visibility:public"], + deps = [ + ":lanelet2_core", + "@boost.filesystem", + "@boost.format", + "@boost.geometry", + "@boost.serialization", + "@pugixml", + ], +) + +filegroup( + name = "lanelet2_maps_osm_files", + srcs = glob(["lanelet2_maps/res/*.osm"]), +) + +cc_library( + name = "lanelet2_matching", + srcs = glob(["lanelet2_matching/src/**/*.cpp"]), + hdrs = glob(["lanelet2_matching/include/**/*.h"]), + includes = [ + "lanelet2_matching/include", + # This has to be exposed as a public include because the headers include other headers using + # the local path. + "lanelet2_matching/include/lanelet2_matching", + ], + visibility = ["//visibility:public"], + deps = [ + ":lanelet2_core", + ":lanelet2_traffic_rules", + "@eigen", + ], +) + +cc_library( + name = "lanelet2_projection", + srcs = glob(["lanelet2_projection/src/**/*.cpp"]), + hdrs = glob(["lanelet2_projection/include/**/*.h"]), + includes = ["lanelet2_projection/include"], + visibility = ["//visibility:public"], + deps = [ + ":lanelet2_core", + ":lanelet2_io", + "@geographiclib", + ], +) + +cc_library( + name = "lanelet2_routing", + srcs = glob(["lanelet2_routing/src/**/*.cpp"]), + hdrs = glob(["lanelet2_routing/include/**/*.h"]), + includes = ["lanelet2_routing/include"], + visibility = ["//visibility:public"], + deps = [ + ":lanelet2_core", + ":lanelet2_traffic_rules", + "@boost.geometry", + "@boost.graph", + "@boost.property_map", + ], +) + +cc_library( + name = "lanelet2_traffic_rules", + srcs = glob(["lanelet2_traffic_rules/src/**/*.cpp"]), + hdrs = glob(["lanelet2_traffic_rules/include/**/*.h"]), + includes = ["lanelet2_traffic_rules/include"], + visibility = ["//visibility:public"], + deps = [":lanelet2_core"], +) + +cc_library( + name = "lanelet2_validation", + srcs = glob(["lanelet2_validation/src/**/*.cpp"]), + hdrs = glob(["lanelet2_validation/include/**/*.h"]), + includes = ["lanelet2_validation/include"], + visibility = ["//visibility:public"], + deps = [ + ":lanelet2_core", + ":lanelet2_io", + ":lanelet2_projection", + ":lanelet2_routing", + ":lanelet2_traffic_rules", + "@boost.program_options", + ], +) + +################################################################################# +# Tests +################################################################################# +cc_test( + name = "lanelet2_core_test", + size = "small", + srcs = glob([ + "lanelet2_core/test/*.cpp", + "lanelet2_core/test/*.h", + ]), + copts = select({ + "@platforms//os:windows": [], + "//conditions:default": ["-Wno-sign-compare"], + }), + deps = [ + ":lanelet2_core", + "@boost.geometry", + "@boost.optional", + "@com_google_googletest//:gtest_main", + ], +) + +cc_test( + name = "lanelet2_io_test", + size = "small", + srcs = glob([ + "lanelet2_io/test/*.cpp", + "lanelet2_io/test/*.h", + ]), + data = [":lanelet2_maps_osm_files"], + deps = [ + ":lanelet2_core", + ":lanelet2_io", + "@bazel_tools//tools/cpp/runfiles", + "@boost.filesystem", + "@boost.serialization", + "@com_google_googletest//:gtest_main", + ], +) + +cc_test( + name = "lanelet2_matching_test", + size = "small", + srcs = glob(["lanelet2_matching/test/*.cpp"]), + deps = [ + ":lanelet2_io", + ":lanelet2_matching", + ":lanelet2_projection", + ":lanelet2_traffic_rules", + "@com_google_googletest//:gtest_main", + ], +) + +cc_test( + name = "lanelet2_projection_test", + size = "small", + srcs = glob(["lanelet2_projection/test/*.cpp"]), + deps = [ + ":lanelet2_projection", + "@com_google_googletest//:gtest_main", + ], +) + +cc_test( + name = "lanelet2_routing_test", + size = "small", + srcs = glob([ + "lanelet2_routing/test/*.cpp", + "lanelet2_routing/test/*.h", + ]), + # For some unknown reason, this test fails without optimization enabled. + copts = ["-O3"], + deps = [ + ":lanelet2_core", + ":lanelet2_routing", + ":lanelet2_traffic_rules", + "@boost.filesystem", + "@boost.geometry", + "@boost.optional", + "@com_google_googletest//:gtest_main", + ], +) + +cc_test( + name = "lanelet2_traffic_rules_test", + size = "small", + srcs = glob(["lanelet2_traffic_rules/test/*.cpp"]), + deps = [ + ":lanelet2_core", + ":lanelet2_traffic_rules", + "@com_google_googletest//:gtest_main", + ], +) + +cc_test( + name = "lanelet2_validation_test", + size = "small", + srcs = glob(["lanelet2_validation/test/*.cpp"]), + data = [":lanelet2_maps_osm_files"], + deps = [ + ":lanelet2_core", + ":lanelet2_io", + ":lanelet2_projection", + ":lanelet2_validation", + "@bazel_tools//tools/cpp/runfiles", + "@com_google_googletest//:gtest_main", + ], +) diff --git a/modules/lanelet2/1.2.2/overlay/MODULE.bazel b/modules/lanelet2/1.2.2/overlay/MODULE.bazel new file mode 120000 index 00000000000..9b599e3ad9c --- /dev/null +++ b/modules/lanelet2/1.2.2/overlay/MODULE.bazel @@ -0,0 +1 @@ +../MODULE.bazel \ No newline at end of file diff --git a/modules/lanelet2/1.2.2/patches/bazel_test_data_paths.patch b/modules/lanelet2/1.2.2/patches/bazel_test_data_paths.patch new file mode 100644 index 00000000000..e80276ac824 --- /dev/null +++ b/modules/lanelet2/1.2.2/patches/bazel_test_data_paths.patch @@ -0,0 +1,135 @@ +diff --git a/lanelet2_io/test/TestBinHandler.cpp b/lanelet2_io/test/TestBinHandler.cpp +index c9868ab..2d13a34 100644 +--- a/lanelet2_io/test/TestBinHandler.cpp ++++ b/lanelet2_io/test/TestBinHandler.cpp +@@ -2,11 +2,15 @@ + #include + #include + #include ++#include + + #include "TestSetup.h" + #include "gtest/gtest.h" + #include "lanelet2_io/Io.h" + #include "lanelet2_io/io_handlers/Serialize.h" ++#include "tools/cpp/runfiles/runfiles.h" ++ ++using bazel::tools::cpp::runfiles::Runfiles; + + using namespace lanelet; + +@@ -114,8 +118,9 @@ TEST(BinHandler, explicitIO) { // NOLINT + } + + TEST(BinHandler, fullMap) { ++ std::unique_ptr runfiles = test_setup::CreateRunfilesOrDie(); + Origin origin({49, 8.4, 0}); +- std::string filenameIn = "../../lanelet2_maps/res/mapping_example.osm"; ++ std::string filenameIn = runfiles->Rlocation("lanelet2/lanelet2_maps/res/mapping_example.osm"); + auto map = lanelet::load(filenameIn, origin); + auto llt = map->laneletLayer.find(44968); + writeAndLoad(*llt); +diff --git a/lanelet2_io/test/TestSetup.h b/lanelet2_io/test/TestSetup.h +index 67652af..ad02019 100644 +--- a/lanelet2_io/test/TestSetup.h ++++ b/lanelet2_io/test/TestSetup.h +@@ -6,6 +6,9 @@ + #include + #include + ++#include "gtest/gtest.h" ++#include "tools/cpp/runfiles/runfiles.h" ++ + namespace fs = boost::filesystem; + + namespace lanelet { +@@ -52,8 +55,8 @@ inline bool operator==(const PrimitiveLayer& rhs, const PrimitiveLayer& lh + } + + template <> +-inline bool operator==(const PrimitiveLayer& rhs, +- const PrimitiveLayer& lhs) { ++inline bool operator== (const PrimitiveLayer& rhs, ++ const PrimitiveLayer& lhs) { + return rhs.size() == lhs.size() && std::all_of(rhs.begin(), rhs.end(), [&lhs](auto& v1) { + return *v1->constData() == *(*lhs.find(v1->id()))->constData(); + }); +@@ -121,6 +124,17 @@ inline Area setUpArea(int& num, const std::string& type = AttributeValueString:: + AttributeMap{{AttributeNamesString::Subtype, type}}, {regelem}); + } + ++using bazel::tools::cpp::runfiles::Runfiles; ++ ++inline std::unique_ptr CreateRunfilesOrDie() { ++ std::string error; ++ std::unique_ptr runfiles{Runfiles::Create("TestBinHandler", BAZEL_CURRENT_REPOSITORY, &error)}; ++ if (runfiles == nullptr) { ++ throw std::runtime_error{"Error creating runfiles: " + error}; ++ } ++ return runfiles; ++} ++ + class Tempfile { + public: + explicit Tempfile(std::string name) { +diff --git a/lanelet2_io/test/TestSimpleUsage.cpp b/lanelet2_io/test/TestSimpleUsage.cpp +index 792f69d..54713da 100644 +--- a/lanelet2_io/test/TestSimpleUsage.cpp ++++ b/lanelet2_io/test/TestSimpleUsage.cpp +@@ -1,11 +1,15 @@ + #include "TestSetup.h" + #include "gtest/gtest.h" + #include "lanelet2_io/Io.h" ++#include "tools/cpp/runfiles/runfiles.h" ++ ++using bazel::tools::cpp::runfiles::Runfiles; + + TEST(lanelet2_io, exampleUsage) { // NOLINT + using namespace lanelet; ++ std::unique_ptr runfiles = lanelet::test_setup::CreateRunfilesOrDie(); + Origin origin({49, 8.4, 0}); +- std::string filenameIn = "../../lanelet2_maps/res/mapping_example.osm"; ++ std::string filenameIn = runfiles->Rlocation("lanelet2/lanelet2_maps/res/mapping_example.osm"); + LaneletMapPtr laneletMap = lanelet::load(filenameIn, origin); + + lanelet::test_setup::Tempfile file("file.osm"); +diff --git a/lanelet2_validation/test/lanelet2_validation.cpp b/lanelet2_validation/test/lanelet2_validation.cpp +index 3e30df4..6f66cd4 100644 +--- a/lanelet2_validation/test/lanelet2_validation.cpp ++++ b/lanelet2_validation/test/lanelet2_validation.cpp +@@ -7,9 +7,23 @@ + + #include "lanelet2_validation/Cli.h" + #include "lanelet2_validation/Validation.h" ++#include "tools/cpp/runfiles/runfiles.h" ++ ++using bazel::tools::cpp::runfiles::Runfiles; ++ ++std::unique_ptr CreateRunfilesOrDie() { ++ std::string error; ++ std::unique_ptr runfiles{Runfiles::Create("TestBinHandler", BAZEL_CURRENT_REPOSITORY, &error)}; ++ if (runfiles == nullptr) { ++ throw std::runtime_error{"Error creating runfiles: " + error}; ++ } ++ return runfiles; ++} + + TEST(TestAllValidators, onExampleMap) { // NOLINT +- const char* args[] = {"validator", "../../lanelet2_maps/res/mapping_example.osm", ++ std::unique_ptr runfiles = CreateRunfilesOrDie(); ++ const std::string osm_file = runfiles->Rlocation("lanelet2/lanelet2_maps/res/mapping_example.osm"); ++ const char* args[] = {"validator", osm_file.c_str(), + "--participants", "vehicle", + "--participants", "pedestrian", + "--lat", "49", +@@ -32,8 +46,9 @@ TEST(Validator, pointsTooClose) { // NOLINT + } + + TEST(Validator, curvatureTooBig) { // NOLINT +- std::string exampleMapPath = "../../lanelet2_maps/res/mapping_example.osm"; + using namespace lanelet; ++ std::unique_ptr runfiles = CreateRunfilesOrDie(); ++ std::string exampleMapPath = runfiles->Rlocation("lanelet2/lanelet2_maps/res/mapping_example.osm"); + projection::UtmProjector projector(Origin({49, 8.4})); + LaneletMapPtr map = load(exampleMapPath, projector); + lanelet::validation::ValidationConfig config; diff --git a/modules/lanelet2/1.2.2/patches/bazel_test_include_paths.patch b/modules/lanelet2/1.2.2/patches/bazel_test_include_paths.patch new file mode 100644 index 00000000000..dacbe168446 --- /dev/null +++ b/modules/lanelet2/1.2.2/patches/bazel_test_include_paths.patch @@ -0,0 +1,26 @@ +diff --git a/lanelet2_core/test/test_linestring.cpp b/lanelet2_core/test/test_linestring.cpp +index b8242ee..e002787 100644 +--- a/lanelet2_core/test/test_linestring.cpp ++++ b/lanelet2_core/test/test_linestring.cpp +@@ -5,7 +5,7 @@ + + #include "lanelet2_core/geometry/LineString.h" + #include "lanelet2_core/primitives/LineString.h" +-#include "primitives/Traits.h" ++#include "lanelet2_core/primitives/Traits.h" + using namespace lanelet; + + class LineStringPoints : public ::testing::Test { +diff --git a/lanelet2_matching/test/lanelet2_matching.cpp b/lanelet2_matching/test/lanelet2_matching.cpp +index c47194e..5b84b54 100644 +--- a/lanelet2_matching/test/lanelet2_matching.cpp ++++ b/lanelet2_matching/test/lanelet2_matching.cpp +@@ -33,7 +33,7 @@ + #include + #include + +-#include "LaneletMatching.h" ++#include "lanelet2_matching/LaneletMatching.h" + #include "gtest/gtest.h" + + using namespace lanelet; diff --git a/modules/lanelet2/1.2.2/presubmit.yml b/modules/lanelet2/1.2.2/presubmit.yml new file mode 100644 index 00000000000..7a8ecae88af --- /dev/null +++ b/modules/lanelet2/1.2.2/presubmit.yml @@ -0,0 +1,32 @@ +matrix: + platform: + - debian10 + - debian11 + # MacOS is not supported by lanelet2. + # - macos + # - macos_arm64 + - ubuntu2004 + - ubuntu2204 + - ubuntu2404 + # Windows is not supported by lanelet2. + # - windows + bazel: + - 7.x + - 8.x +tasks: + unix_test: + platform: ${{ platform }} + bazel: ${{ bazel }} + build_flags: + - '--cxxopt=-std=c++17' + - '--host_cxxopt=-std=c++17' + build_targets: + - '@lanelet2//:lanelet2_core' + - '@lanelet2//:lanelet2_io' + - '@lanelet2//:lanelet2_matching' + - '@lanelet2//:lanelet2_projection' + - '@lanelet2//:lanelet2_routing' + - '@lanelet2//:lanelet2_traffic_rules' + - '@lanelet2//:lanelet2_validation' + test_targets: + - '@lanelet2//...' diff --git a/modules/lanelet2/1.2.2/source.json b/modules/lanelet2/1.2.2/source.json new file mode 100644 index 00000000000..e7c4f18856a --- /dev/null +++ b/modules/lanelet2/1.2.2/source.json @@ -0,0 +1,14 @@ +{ + "url": "https://github.com/fzi-forschungszentrum-informatik/Lanelet2/archive/refs/tags/1.2.2.tar.gz", + "integrity": "sha256-jSM48W6PEydBJTwrKYxKJbu6Gpqi+/zpPqr11aj+U5Y=", + "strip_prefix": "Lanelet2-1.2.2", + "patches": { + "bazel_test_data_paths.patch": "sha256-lRfoCSWA3FfEMYD8MWWOln4Hs6hep0h/l7lMrExFlzQ=", + "bazel_test_include_paths.patch": "sha256-iaAuQFKvVknHYUzSmFpsnXx5auhE1RqpXIKS9qK+C2E=" + }, + "overlay": { + "BUILD.bazel": "sha256-XP8SspStSOBTBt/Wz1FSL67NXaxGqu0H+3l3E5wvFmg=", + "MODULE.bazel": "sha256-zPCZnuediXqru+a8IRQ1TYsLRw0km2QZ69714zSJqvA=" + }, + "patch_strip": 1 +} diff --git a/modules/lanelet2/metadata.json b/modules/lanelet2/metadata.json new file mode 100644 index 00000000000..ff1efd9931d --- /dev/null +++ b/modules/lanelet2/metadata.json @@ -0,0 +1,17 @@ +{ + "homepage": "https://github.com/fzi-forschungszentrum-informatik/Lanelet2", + "maintainers": [ + { + "email": "kgreenek@gmail.com", + "github": "kgreenek", + "name": "Kevin Greene" + } + ], + "repository": [ + "github:fzi-forschungszentrum-informatik/Lanelet2" + ], + "versions": [ + "1.2.2" + ], + "yanked_versions": {} +}