From e38ef5d044984c858b7e1d21867347e1bb0d28a8 Mon Sep 17 00:00:00 2001 From: Rodrigo Queiro Date: Mon, 4 Mar 2019 20:55:14 +0100 Subject: [PATCH] Remove direct reference to genfiles For historical reasons, Bazel has two directories for generated files, although a future version of Bazel will remove the genfiles directory: https://github.com/bazelbuild/bazel/issues/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 --- bazel/build_rules/rosmsg.bzl | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bazel/build_rules/rosmsg.bzl b/bazel/build_rules/rosmsg.bzl index b16c49e5f..c60904355 100644 --- a/bazel/build_rules/rosmsg.bzl +++ b/bazel/build_rules/rosmsg.bzl @@ -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) ) @@ -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