Skip to content

Commit

Permalink
bazel_to_cmake: Identify bazel proto constructs which are not well ha…
Browse files Browse the repository at this point in the history
…ndled.

This changes the bazel_to_cmake test to include a BAZEL configuration variant which is not well handled by bazel_to_cmake without yet fixing the translation.

Related to: #197

PiperOrigin-RevId: 674930925
Change-Id: I3498b8d81c8b8634169cd0db7e16076769634812
  • Loading branch information
laramiel authored and copybara-github committed Sep 15, 2024
1 parent d59b0a1 commit 4629236
Show file tree
Hide file tree
Showing 18 changed files with 412 additions and 363 deletions.
46 changes: 44 additions & 2 deletions tools/cmake/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ TESTDATA = [
"bazel_to_cmake/testdata/rules_proto/golden/build_rules.cmake",
"bazel_to_cmake/testdata/rules_proto/WORKSPACE.bazel",
"bazel_to_cmake/testdata/rules_proto/x.proto",
"bazel_to_cmake/testdata/rules_proto/src/subdir/y.proto",
"bazel_to_cmake/testdata/third_party_http_archive/a.cc",
"bazel_to_cmake/testdata/third_party_http_archive/BUILD.bazel",
"bazel_to_cmake/testdata/third_party_http_archive/config.json",
Expand All @@ -142,11 +143,12 @@ TESTDATA = [
"bazel_to_cmake/testdata/third_party_http_archive/golden/build_rules.cmake",
"bazel_to_cmake/testdata/third_party_http_archive/half.BUILD.bazel",
"bazel_to_cmake/testdata/third_party_http_archive/WORKSPACE.bazel",
"bazel_to_cmake/testdata/upb_proto_library/a.cc",
"bazel_to_cmake/testdata/upb_proto_library/x.cc",
"bazel_to_cmake/testdata/upb_proto_library/BUILD.bazel",
"bazel_to_cmake/testdata/upb_proto_library/a.proto",
"bazel_to_cmake/testdata/upb_proto_library/b.proto",
"bazel_to_cmake/testdata/upb_proto_library/c.proto",
"bazel_to_cmake/testdata/upb_proto_library/config.json",
"bazel_to_cmake/testdata/upb_proto_library/d.proto",
"bazel_to_cmake/testdata/upb_proto_library/golden/build_rules.cmake",
"bazel_to_cmake/testdata/upb_proto_library/WORKSPACE.bazel",
]
Expand All @@ -161,3 +163,43 @@ tensorstore_pytest_test(
"skip-windows", # path canonicalization isn't correct when testing on windows.
],
)

cc_library(
name = "bazel_to_cmake/testdata/upb_proto_library/x",
srcs = ["bazel_to_cmake/testdata/upb_proto_library/x.cc"],
)

proto_library(
name = "bazel_to_cmake/testdata/rules_proto/a_proto",
srcs = ["bazel_to_cmake/testdata/rules_proto/a.proto"],
)

proto_library(
name = "bazel_to_cmake/testdata/rules_proto/c_proto",
srcs = ["bazel_to_cmake/testdata/rules_proto/c.proto"],
)

proto_library(
name = "bazel_to_cmake/testdata/rules_proto/b_proto",
srcs = ["bazel_to_cmake/testdata/rules_proto/b.proto"],
)

proto_library(
name = "bazel_to_cmake/testdata/upb_proto_library/a_proto",
srcs = ["bazel_to_cmake/testdata/upb_proto_library/a.proto"],
)

proto_library(
name = "bazel_to_cmake/testdata/rules_proto/x_proto",
srcs = ["bazel_to_cmake/testdata/rules_proto/x.proto"],
)

proto_library(
name = "bazel_to_cmake/testdata/rules_proto/src/subdir/y_proto",
srcs = ["bazel_to_cmake/testdata/rules_proto/src/subdir/y.proto"],
)

proto_library(
name = "bazel_to_cmake/testdata/upb_proto_library/b_proto",
srcs = ["bazel_to_cmake/testdata/upb_proto_library/b.proto"],
)
1 change: 1 addition & 0 deletions tools/cmake/bazel_to_cmake/bzl_library/grpc_generate_cc.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from ..starlark.provider import TargetInfo
from ..starlark.select import Configurable

from .upb_proto_library import UPB_REPO # pylint: disable=unused-import

GRPC_REPO = RepositoryId("com_github_grpc_grpc")

Expand Down
14 changes: 10 additions & 4 deletions tools/cmake/bazel_to_cmake/testdata/rules_proto/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ proto_library(

proto_library(
name = "ab_proto",
deps = [
"a_proto",
":b_proto",
srcs = [
"a.proto",
"b.proto",
],
)

proto_library(
name = "abc_proto",
srcs = ["c.proto"],
deps = [
"ab_proto",
":ab_proto",
],
)

Expand All @@ -48,3 +48,9 @@ cc_proto_library(
name = "x_proto_cc",
deps = [":x_proto"],
)

proto_library(
name = "y_proto",
srcs = ["src/subdir/y.proto"],
strip_import_prefix = "src",
)
3 changes: 2 additions & 1 deletion tools/cmake/bazel_to_cmake/testdata/rules_proto/a.proto
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
// a.proto
// a.proto
syntax = "proto2";
3 changes: 2 additions & 1 deletion tools/cmake/bazel_to_cmake/testdata/rules_proto/b.proto
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
// b.proto
// b.proto
syntax = "proto2";
3 changes: 2 additions & 1 deletion tools/cmake/bazel_to_cmake/testdata/rules_proto/c.proto
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
// c.proto
// c.proto
syntax = "proto2";
10 changes: 3 additions & 7 deletions tools/cmake/bazel_to_cmake/testdata/rules_proto/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,22 @@
"//:a_proto__upbdefs_library",
"//:ab_proto",
"//:ab_proto__cpp_library",
"//:ab_proto__minitable_library",
"//:ab_proto__upb_library",
"//:ab_proto__upbdefs_library",
"//:ab_protos_cc",
"//:abc_proto",
"//:abc_proto__cpp_library",
"//:abc_proto__minitable_library",
"//:abc_proto__upb_library",
"//:abc_proto__upbdefs_library",
"//:abc_protos_cc",
"//:b_proto",
"//:b_proto__cpp_library",
"//:b_proto__minitable_library",
"//:b_proto__upb_library",
"//:b_proto__upbdefs_library",
"//:x_proto",
"//:x_proto__cpp_library",
"//:x_proto__minitable_library",
"//:x_proto__upb_library",
"//:x_proto__upbdefs_library",
"//:x_proto_cc"
"//:x_proto_cc",
"//:y_proto__cpp_library",
"//:y_proto__upb_library"
]
}
Loading

0 comments on commit 4629236

Please sign in to comment.