Skip to content

Commit

Permalink
Remove direct reference to genfiles
Browse files Browse the repository at this point in the history
For historical reasons, Bazel has two directories for generated files,
although a future version of Bazel will remove the genfiles directory:
bazelbuild/bazel#6761

Currently, rosmsg() copies all the source files (*.msg, *.srv) to the
output directory, so that the directory structure matches the needs of
ROS's codegen tools. It uses a hacky way of finding the paths to the
transitive dependencies within the output directory, which includes a
direct reference to genfiles. By using output_to_bindir=True, we can
avoid the direct reference.

Fixing the hack would involve rewriting the rosmsg() macro to use a
rule, which wouldn't be too hard but might break compatibility.

See #2.

Change-Id: Ibae3451e1329e397329089aa6796c5477789c788
  • Loading branch information
drigz committed Mar 5, 2019
1 parent 89269a1 commit e38ef5d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions bazel/build_rules/rosmsg.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ OUTPUT_PREFIX = "__rosmsg__"
_COMMON_CMD_CODE = """
# Find all directories with *.msg *.srv files. The names of these directories
# are assumed to be the package names for the inclusion search paths.
# _CopyMsgSrvFiles ensures all such files are within genfiles, although
# _CopyMsgSrvFiles ensures all such files are within bindir, although
# depending on the execution settings they may be found in the host or target
# genfiles.
# TODO(rodrigoq): use aspects for the include directories instead of find(1).
ROS_INCLUDE_DIRS=( $$(find $(GENDIR) bazel-out/host/genfiles \\
# bindir.
# TODO(rodrigoq): use providers for the include directories instead of find(1).
ROS_INCLUDE_DIRS=( $$(find $(GENDIR) bazel-out/host/bin \\
\( -name "*.msg" -or -name "*.srv" \) \\
-exec dirname {{}} \; | sort -u) )
Expand Down Expand Up @@ -131,6 +131,7 @@ def _CopyMsgSrvFiles(name, srcs, output_dir):
srcs = [src],
outs = [new_path],
cmd = "cp $< $@",
output_to_bindir = True,
)
results.append(new_path)
return results
Expand Down

0 comments on commit e38ef5d

Please sign in to comment.