Reputation:
I use bazel to manage my project and I want to generate protobuf files by bazel build. Here is my file path tree:
There are two problems:
How to make geometry.proto import matrix.proto (in the same folder)?
syntax = "proto2"; import "matrix.proto"; package sample.proto;
This Is the BUILD file:
load("@rules_cc//cc:defs.bzl", "cc_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
proto_library(
name = "lam_common",
srcs = [
"lam_common/geometry.proto",
"lam_common/matrix.proto",
"lam_common/projection.proto",
],
import_prefix = "proto",
)
proto_library(
name = "external_proto",
srcs = [
"external_proto/config_camera.proto",
"external_proto/config_filter.proto",
"external_proto/config_multi_sensors_fusion.proto",
"external_proto/config_navigation_device.proto",
"external_proto/config_region.proto",
"external_proto/config_static_detector.proto",
"external_proto/debug_internal_ekf_state.proto",
"external_proto/debug_states.proto",
"external_proto/keyframe_states.proto",
"external_proto/layer_pose.proto",
"external_proto/lidar_icp_poses.proto",
"external_proto/loop_detection_poses.proto",
"external_proto/novatel_raw_data.proto",
"external_proto/perception_object.proto",
"external_proto/prediction.proto",
"external_proto/static_detection_segments.proto",
"external_proto/stream.proto",
"external_proto/tile_points_storage.proto",
],
deps =
[":lam_common"],
)
cc_proto_library(
name = "external_proto_cc",
deps = [":external_proto"],
)
Upvotes: 0
Views: 1033
Reputation: 11
Instead of chaning all of the import statements in the proto files, you can pass in the strip_import_prefix = "lam_common"
to proto_library
.
Upvotes: 0
Reputation:
I use import "proto/lam_common/xxx.proto", then the problem is resolved.
Upvotes: 0