Skip to content

Commit

Permalink
[lcm] Remove build-time transitive dependency on LCM headers (RobotLo…
Browse files Browse the repository at this point in the history
  • Loading branch information
jwnimmer-tri authored Jun 27, 2022
1 parent 61cf576 commit 1ab3b7e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
10 changes: 8 additions & 2 deletions lcm/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,12 @@ drake_cc_library(
name = "drake_lcm",
srcs = ["drake_lcm.cc"],
hdrs = ["drake_lcm.h"],
deps = [
interface_deps = [
":drake_lcm_params",
":interface",
"//common:essential",
],
deps = [
"//common:scope_exit",
"@glib",
"@lcm",
Expand All @@ -76,9 +78,11 @@ drake_cc_library(
name = "lcm_log",
srcs = ["drake_lcm_log.cc"],
hdrs = ["drake_lcm_log.h"],
deps = [
interface_deps = [
":interface",
"//common:essential",
],
deps = [
"@lcm",
],
)
Expand Down Expand Up @@ -122,6 +126,7 @@ drake_cc_googletest(
":drake_lcm",
":lcmt_drake_signal_utils",
"//common/test_utilities:expect_throws_message",
"@lcm",
],
)

Expand All @@ -131,6 +136,7 @@ drake_cc_googletest(
deps = [
":drake_lcm",
":lcmt_drake_signal_utils",
"@lcm",
],
)

Expand Down
1 change: 1 addition & 0 deletions lcm/drake_lcm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <vector>

#include <glib.h>
#include <lcm/lcm-cpp.hpp>

#include "drake/common/drake_assert.h"
#include "drake/common/drake_copyable.h"
Expand Down
11 changes: 9 additions & 2 deletions lcm/drake_lcm.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,20 @@
#include <optional>
#include <string>

#include "lcm/lcm-cpp.hpp"

#include "drake/common/drake_copyable.h"
#include "drake/common/drake_deprecated.h"
#include "drake/lcm/drake_lcm_interface.h"
#include "drake/lcm/drake_lcm_params.h"

#ifndef DRAKE_DOXYGEN_CXX
namespace lcm {
// We don't want to pollute our Drake headers with the include paths for either
// @lcm or @glib, so we forward-declare the `class ::lcm::LCM` for use only by
// DrakeLcm::get_lcm_instance() -- an advanced function that is rarely used.
class LCM;
} // namespace lcm
#endif

namespace drake {
namespace lcm {

Expand Down
1 change: 0 additions & 1 deletion tools/install/libdrake/header_lint.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ _ALLOWED_EXTERNALS = [
"spdlog",

# The entries that follow are defects; we should work to remove them.
"glib",
"zlib",
]

Expand Down
1 change: 0 additions & 1 deletion tools/install/libdrake/test/header_dependency_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ def setUp(self):
re_thirds = [
re.compile(r'^(Eigen|unsupported/Eigen)/.*$'),
re.compile(r'^(fmt|spdlog)/.*$'),
re.compile(r'^lcm/.*$'),
re.compile(r'^optitrack/.*$'),
]

Expand Down

0 comments on commit 1ab3b7e

Please sign in to comment.