Open sloretz opened 2 years ago
Possible fixes
Maybe we should filter out any underlay workspaces from environment variables?
I think this makes the most sense.
Ideally, our Bazel rules should be as explicit as possible in source code, and not change behavior based on envrionment variables, esp. if the goal is to explicitly list the chain of workspaces / overlays.
If a user wants to use a workspace, they should explicitly list in their WORKSPACE
. If they really want to be at the behest of their environment variables, they can use tricks like Anzu's os.bzl
to load in env vars.
What do you think?
Currently when an existing local ROS 2 workspace is sourced,
bazel_ros2_rules
will generate a BUILD.bazel file with absolute paths in places where Bazel labels are expected, thus making the whole build file invalid.Examples in BUILD.bazel
```Python share_filegroup( name = "rti_connext_dds_cmake_module_share", share_directories = ["/home/sloretz/ws/drake-ros/ros2/install/share/rti_connext_dds_cmake_module", "/home/sloretz/ws/drake-ros/ros2/install/share/ament_index"], ) ``` ```Python cc_library( name = "rmw_fastrtps_dynamic_cpp_cc", srcs = ["/home/sloretz/ws/drake-ros/ros2/install/lib/librmw_fastrtps_dynamic_cpp.so", "/home/sloretz/ws/drake-ros/ros2/install/lib/libfastrtps.so.2.6"], hdrs = glob(["{}/**/*.h*".format(x) for x in ["archive/rmw_fastrtps_dynamic_cpp"]]), includes = ["archive"], copts = ["-isystem /home/sloretz/ws/drake-ros/ros2/install/include/rmw_fastrtps_dynamic_cpp"], defines = [], linkopts = ["-Wl,-rpath,/home/sloretz/.cache/bazel/_bazel_sloretz/effac4167a518523c467e34b5d8c3dd7/external/ros2/archive/rosidl_typesupport_cpp/lib:/home/sloretz/.cache/bazel/_bazel_sloretz/effac4167a518523c467e34b5d8c3dd7/external/ros2/archive/rosidl_typesupport_c/lib:/home/sloretz/.cache/bazel/_bazel_sloretz/effac4167a518523c467e34b5d8c3dd7/external/ros2/archive/rcpputils/lib:/home/sloretz/.cache/bazel/_bazel_sloretz/effac4167a518523c467e34b5d8c3dd7/external/ros2/archive/rcutils/lib:/home/sloretz/.cache/bazel/_bazel_sloretz/effac4167a518523c467e34b5d8c3dd7/external/ros2/archive/rmw/lib:/home/sloretz/.cache/bazel/_bazel_sloretz/effac4167a518523c467e34b5d8c3dd7/external/ros2/archive/rmw_dds_common/lib:/home/sloretz/.cache/bazel/_bazel_sloretz/effac4167a518523c467e34b5d8c3dd7/external/ros2/archive/rmw_fastrtps_shared_cpp/lib:/home/sloretz/.cache/bazel/_bazel_sloretz/effac4167a518523c467e34b5d8c3dd7/external/ros2/archive/rosidl_runtime_c/lib:/home/sloretz/.cache/bazel/_bazel_sloretz/effac4167a518523c467e34b5d8c3dd7/external/ros2/archive/rosidl_typesupport_fastrtps_c/lib:/home/sloretz/.cache/bazel/_bazel_sloretz/effac4167a518523c467e34b5d8c3dd7/external/ros2/archive/rosidl_typesupport_fastrtps_cpp/lib:/home/sloretz/.cache/bazel/_bazel_sloretz/effac4167a518523c467e34b5d8c3dd7/external/ros2/archive/rosidl_typesupport_introspection_c/lib:/home/sloretz/.cache/bazel/_bazel_sloretz/effac4167a518523c467e34b5d8c3dd7/external/ros2/archive/rosidl_typesupport_introspection_cpp/lib:/home/sloretz/.cache/bazel/_bazel_sloretz/effac4167a518523c467e34b5d8c3dd7/external/ros2/archive/fastcdr/lib:/home/sloretz/ws/drake-ros/ros2/install/lib:/home/sloretz/.cache/bazel/_bazel_sloretz/effac4167a518523c467e34b5d8c3dd7/external/ros2/archive/fastrtps/lib"], data = [":rmw_fastrtps_dynamic_cpp_share", "/home/sloretz/ws/drake-ros/ros2/install/lib/librmw_fastrtps_dynamic_cpp.so", "/home/sloretz/ws/drake-ros/ros2/install/lib/libfastrtps.so.2.6"], deps = [":rmw_dds_common_cc", ":rcutils_cc", ":rmw_fastrtps_shared_cpp_cc", ":rcpputils_cc", ":rosidl_runtime_c_cc", ":rosidl_typesupport_fastrtps_cpp_cc", ":rosidl_typesupport_introspection_c_cc", ":rosidl_typesupport_introspection_cpp_cc", ":rosidl_typesupport_fastrtps_c_cc", ":fastcdr_cc", ":fastrtps_cc", ":rmw_cc", ":fastrtps_cmake_module_cc"], ) ``` ```Python ros_import_binary( name = "ament_clang_format", executable = "/home/sloretz/ws/drake-ros/ros2/install/bin/ament_clang_format", data = [":action_msgs_cc", ":rclpy_cc", ":rcl_lifecycle_cc", ":rcl_lifecycle_transitive_py", ":builtin_interfaces_cc", ":tracetools_cc", ":rosidl_runtime_c_cc", ":rosidl_runtime_c_transitive_py", ":rclcpp_action_cc", ":rclcpp_action_transitive_py", ":rcl_interfaces_cc", ":unique_identifier_msgs_cc", ":rmw_cc", ":rmw_transitive_py", ":rcl_yaml_param_parser_cc", ":rosgraph_msgs_cc", ":rcutils_cc", ":rcl_cc", ":rcl_transitive_py", ":rosidl_default_generators_cc", ":rosidl_default_runtime_cc", ":rosidl_default_runtime_transitive_py", ":rmw_implementation_cc", ":rmw_implementation_transitive_py", ":rcpputils_cc", ":rcpputils_transitive_py", ":yaml_cc", ":rosidl_runtime_cpp_cc", ":rcl_logging_interface_cc", ":rcl_logging_interface_transitive_py", ":rosidl_typesupport_fastrtps_cpp_cc", ":rosidl_typesupport_introspection_cpp_cc", ":rmw_connextddsmicro_cc", ":ament_index_cpp_cc", ":rosidl_generator_c_cc", ":rosidl_typesupport_introspection_c_cc", ":rcl_action_cc", ":rcl_action_transitive_py", ":rosidl_typesupport_interface_cc", ":rosidl_generator_cpp_cc", ":rosidl_parser_cc", ":rcl_logging_noop_cc", ":rcl_logging_noop_transitive_py", ":rosidl_typesupport_fastrtps_c_cc", ":rmw_fastrtps_dynamic_cpp_cc", ":rmw_fastrtps_dynamic_cpp_transitive_py", ":rosidl_typesupport_c_cc", ":rosidl_typesupport_cpp_cc", ":rmw_cyclonedds_cpp_cc", ":rmw_cyclonedds_cpp_transitive_py", ":fastcdr_cc", ":rosidl_generator_py_cc", ":rclcpp_cc", ":rclcpp_transitive_py", ":lifecycle_msgs_cc", ":rmw_fastrtps_cpp_cc", ":rmw_fastrtps_cpp_transitive_py", ":libyaml_vendor_cc", ":rmw_connextdds_cc", ":ament_cmake_cc", ":ament_cmake_transitive_py", ":rmw_implementation_cmake_cc", ":ament_cmake_core_cc", ":ament_cmake_export_targets_cc", ":rmw_connextdds_common_cc", ":rmw_connextdds_common_transitive_py", ":rcl_logging_spdlog_cc", ":rcl_logging_spdlog_transitive_py", ":rosidl_cmake_cc", ":ament_cmake_version_cc", ":libstatistics_collector_cc", ":libstatistics_collector_transitive_py", ":rti_connext_dds_cmake_module_cc", ":ament_cmake_export_interfaces_cc", ":ament_cmake_test_cc", ":rmw_fastrtps_shared_cpp_cc", ":rmw_fastrtps_shared_cpp_transitive_py", ":fastrtps_cmake_module_cc", ":std_msgs_cc", ":ament_cmake_export_link_flags_cc", ":statistics_msgs_cc", ":rmw_dds_common_cc", ":ament_cmake_export_libraries_cc", ":ament_cmake_python_cc", ":ament_cmake_export_dependencies_cc", ":ament_cmake_export_include_directories_cc", ":rosidl_adapter_cc", ":ament_cmake_libraries_cc", ":ament_cmake_export_definitions_cc", ":ament_cmake_gen_version_h_cc", ":spdlog_vendor_cc", ":fastrtps_cc", ":ament_cmake_target_dependencies_cc"], deps = [":action_msgs_py", ":rclpy_py", ":builtin_interfaces_py", ":rcl_interfaces_py", ":unique_identifier_msgs_py", ":rpyutils_py", ":rosgraph_msgs_py", ":rcutils_py", ":rosidl_typesupport_fastrtps_cpp_py", ":rosidl_typesupport_introspection_cpp_py", ":ament_index_python_py", ":rosidl_generator_c_py", ":rosidl_typesupport_introspection_c_py", ":rosidl_generator_cpp_py", ":rosidl_parser_py", ":rosidl_typesupport_fastrtps_c_py", ":rosidl_typesupport_c_py", ":rosidl_typesupport_cpp_py", ":rosidl_generator_py_py", ":lifecycle_msgs_py", ":rosidl_cmake_py", ":rosidl_cli_py", ":ament_cmake_test_py", ":std_msgs_py", ":statistics_msgs_py", ":rmw_dds_common_py", ":rosidl_adapter_py"], ) ```