From 6e54b200e06ffac2f1995e0643195a1f0ae86f9e Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Mon, 16 Sep 2024 21:08:44 +0000 Subject: [PATCH] @wip Signed-off-by: Michael Carroll --- BUILD.bazel | 112 +++++++++++++++++++++++++++++++++++++++++++++ MODULE.bazel | 1 + src/parser_urdf.cc | 2 +- 3 files changed, 114 insertions(+), 1 deletion(-) diff --git a/BUILD.bazel b/BUILD.bazel index 203449052..2cfcdcb18 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,3 +1,4 @@ +load("@rules_gz//gz:headers.bzl", "gz_configure_header", "gz_export_header") load("@buildifier_prebuilt//:rules.bzl", "buildifier", "buildifier_test") load("@rules_license//rules:license.bzl", "license") @@ -17,6 +18,117 @@ exports_files([ "MODULE.bazel", ]) +gz_configure_header( + name = "config", + src = "include/sdf/config.hh.in", + cmakelists = ["CMakeLists.txt"], + defines = { + "CMAKE_INSTALL_FULL_DATAROOTDIR": "unused", + "PROJECT_NAME": "sdformat", + "PROJECT_VERSION": "15.0.0", + "PROJECT_VERSION_FULL": "15.0.0", + "PROJECT_VERSION_MAJOR": "15", + "PROJECT_VERSION_MINOR": "0", + "PROJECT_VERSION_PATCH": "0", + "SDF_PROTOCOL_VERSION": "1.12", + }, + package = "sdformat", +) + +gz_export_header( + name = "include/sdf/Export.hh", + export_base = "GZ_SDFORMAT", + lib_name = "sdformat", + visibility = ["//visibility:private"], +) + +public_headers_no_gen = glob([ + "include/sdf/*.h", + "include/sdf/*.hh", +]) + +private_headers = glob(["src/*.hh"]) + +sources = glob( + ["src/*.cc"], + exclude = [ + "src/*_TEST.cc", + "src/InstallationDirectories.cc", + ], +) + +public_headers = public_headers_no_gen + [ + "include/sdf/config.hh", + "include/sdf/Export.hh", +] + +cc_library( + name = "installation_directories", + srcs = ["src/InstallationDirectories.cc"], + hdrs = [ + "include/sdf/Export.hh", + "include/sdf/InstallationDirectories.hh", + "include/sdf/config.hh", + "include/sdf/sdf_config.h", + "include/sdf/system_util.hh", + ], + defines = [ + 'CMAKE_INSTALL_RELATIVE_DATAROOTDIR=\\"unused\\"', + ], + includes = ["include"], + visibility = ["//visibility:private"], +) + +cc_library( + name = "urdf_parser", + srcs = [ + "src/urdf/urdf_parser/joint.cpp", + "src/urdf/urdf_parser/link.cpp", + "src/urdf/urdf_parser/model.cpp", + "src/urdf/urdf_parser/pose.cpp", + "src/urdf/urdf_parser/twist.cpp", + "src/urdf/urdf_parser/urdf_model_state.cpp", + "src/urdf/urdf_parser/urdf_sensor.cpp", + "src/urdf/urdf_parser/world.cpp", + ], + hdrs = glob( + ["src/urdf/**/*.h"], + ), + copts = ["-Wno-unknown-pragmas"], + includes = ["src/urdf"], + deps = [ + "@tinyxml2", + ], +) + +cc_library( + name = "sdformat", + srcs = sources + private_headers, + hdrs = public_headers, + includes = ["include"], + visibility = ["//visibility:public"], + deps = [ + ":installation_directories", + ":urdf_parser", + "@gz-math", + "@gz-utils", + ], +) + +[cc_test( + name = src.replace("/", "_").replace(".cc", "").replace("src_", ""), + srcs = [src], + env = { + "GZ_BAZEL": "1", + "GZ_BAZEL_PATH": "sdformat", + }, + deps = [ + ":sdformat", + "@gtest", + "@gtest//:gtest_main", + ], +) for src in test_sources] + # Bazel linting buildifier( name = "buildifier.fix", diff --git a/MODULE.bazel b/MODULE.bazel index c980da9f5..3355702b3 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -7,6 +7,7 @@ module( bazel_dep(name = "buildifier_prebuilt", version = "6.1.2") bazel_dep(name = "googletest", version = "1.14.0") bazel_dep(name = "rules_license", version = "0.0.8") +bazel_dep(name = "tinyxml2", version = "10.0.0") # Gazebo Dependencies bazel_dep(name = "rules_gz") diff --git a/src/parser_urdf.cc b/src/parser_urdf.cc index d8d2b2352..fac4ea5bd 100644 --- a/src/parser_urdf.cc +++ b/src/parser_urdf.cc @@ -35,8 +35,8 @@ #include #include "sdf/Error.hh" -#include "sdf/sdf.hh" #include "sdf/Types.hh" +#include "sdf/Frame.hh" #include "XmlUtils.hh" #include "SDFExtension.hh"