Skip to content

Commit 6e52a1a

Browse files
Enable OSS Bazel builds by fixing dependencies and proto paths (#50)
- Add py_proto_library macro for OSS compatibility - Replace gunit_main with googletest gtest_main - Comment out Google-internal dependencies and missing test files - Fix proto import to use workspace-relative path - Remove invalid third_party load statements Fixes build errors when running `bazel build //...` in OSS environment. Co-authored-by: Madhur Karampudi <142544288+vkarampudi@users.noreply.github.com>
1 parent 3ed424e commit 6e52a1a

5 files changed

Lines changed: 81 additions & 68 deletions

File tree

struct2tensor/benchmarks/BUILD

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,7 @@
1313
# limitations under the License.
1414

1515
load("@rules_cc//cc:cc_test.bzl", "cc_test")
16-
17-
# Placeholder: load py_proto_library
18-
# Placeholder: load py_binary
19-
# Placeholder: load py_library
20-
# Placeholder: load py_test
21-
load("//third_party/protobuf/bazel:proto_library.bzl", "proto_library")
22-
load("//tools/build_defs/proto/cpp:cc_proto_library.bzl", "cc_proto_library")
16+
load("//struct2tensor:struct2tensor.bzl", "py_proto_library")
2317

2418
licenses(["notice"])
2519

@@ -35,26 +29,28 @@ py_proto_library(
3529
deps = [":benchmark_proto"],
3630
)
3731

32+
# Use native cc_proto_library instead of custom macro since we already have proto_library defined
3833
cc_proto_library(
3934
name = "benchmark_cc_proto",
4035
deps = [":benchmark_proto"],
4136
)
4237

43-
cc_test(
44-
name = "serialization_benchmark",
45-
srcs = ["serialization_benchmark.cc"],
46-
deps = [
47-
":benchmark_cc_proto",
48-
"//testing/base/public:gunit",
49-
"@com_google_absl//absl/flags:flag",
50-
"@com_google_absl//absl/flags:parse",
51-
"@com_google_absl//absl/random",
52-
"@com_google_absl//absl/random:distributions",
53-
"@com_google_protobuf//:protobuf",
54-
"@org_tensorflow//tensorflow/core:feature_util",
55-
"@org_tensorflow//tensorflow/core:protos_all_cc",
56-
],
57-
)
38+
# Google-internal benchmark - commented out for OSS
39+
# cc_test(
40+
# name = "serialization_benchmark",
41+
# srcs = ["serialization_benchmark.cc"],
42+
# deps = [
43+
# ":benchmark_cc_proto",
44+
# "//testing/base/public:gunit",
45+
# "@com_google_absl//absl/flags:flag",
46+
# "@com_google_absl//absl/flags:parse",
47+
# "@com_google_absl//absl/random",
48+
# "@com_google_absl//absl/random:distributions",
49+
# "@com_google_protobuf//:protobuf",
50+
# "@org_tensorflow//tensorflow/core:feature_util",
51+
# "@org_tensorflow//tensorflow/core:protos_all_cc",
52+
# ],
53+
# )
5854

5955
py_library(
6056
name = "struct2tensor_benchmark_lib",
@@ -63,10 +59,11 @@ py_library(
6359
":benchmark_proto_py_pb2",
6460
":struct2tensor_benchmark_util",
6561
"//struct2tensor",
66-
"//testing/pybase",
67-
"//testing/pybase:parameterized",
68-
"//third_party/py/cpuinfo",
69-
"//third_party/py/psutil",
62+
# Google-internal dependencies - not available in OSS
63+
# "//testing/pybase",
64+
# "//testing/pybase:parameterized",
65+
# "//third_party/py/cpuinfo",
66+
# "//third_party/py/psutil",
7067
],
7168
)
7269

@@ -112,9 +109,10 @@ py_library(
112109
name = "struct2tensor_benchmark_util",
113110
srcs = ["struct2tensor_benchmark_util.py"],
114111
deps = [
115-
"//file/colossus/public:cns",
116-
"//third_party/py/cpuinfo",
117-
"//third_party/py/psutil",
112+
# Google-internal dependencies - not available in OSS
113+
# "//file/colossus/public:cns",
114+
# "//third_party/py/cpuinfo",
115+
# "//third_party/py/psutil",
118116
"@absl_py//absl/flags",
119117
"@absl_py//absl/testing:parameterized",
120118
],

struct2tensor/kernels/parquet/BUILD

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -99,38 +99,40 @@ cc_library(
9999
],
100100
)
101101

102-
cc_test(
103-
name = "parent_indices_builder_test",
104-
srcs = ["parent_indices_builder_test.cc"],
105-
deps = [
106-
":parent_indices_builder_lib",
107-
"//testing/base/public:gunit_main",
108-
"@org_tensorflow//tensorflow/core:lib",
109-
"@org_tensorflow//tensorflow/core:test",
110-
],
111-
)
102+
# Test file parent_indices_builder_test.cc does not exist, commenting out
103+
# cc_test(
104+
# name = "parent_indices_builder_test",
105+
# srcs = ["parent_indices_builder_test.cc"],
106+
# deps = [
107+
# ":parent_indices_builder_lib",
108+
# "@com_google_googletest//:gtest_main", # Replaces Google-internal //testing/base/public:gunit_main
109+
# "@org_tensorflow//tensorflow/core:lib",
110+
# "@org_tensorflow//tensorflow/core:test",
111+
# ],
112+
# )
112113

113-
cc_test(
114-
name = "parquet_reader_test",
115-
srcs = ["parquet_reader_test.cc"],
116-
data = [
117-
"//struct2tensor/testdata/parquet_testdata",
118-
],
119-
deps = [
120-
":parquet_reader_lib",
121-
"//testing/base/public:gunit_main",
122-
"@org_tensorflow//tensorflow/core:framework",
123-
],
124-
)
125-
126-
cc_test(
127-
name = "parquet_reader_util_test",
128-
srcs = ["parquet_reader_util_test.cc"],
129-
data = [
130-
"//struct2tensor/testdata/parquet_testdata",
131-
],
132-
deps = [
133-
":parquet_reader_util_lib",
134-
"//testing/base/public:gunit_main",
135-
],
136-
)
114+
# Test file parquet_reader_test.cc does not exist, commenting out
115+
# cc_test(
116+
# name = "parquet_reader_test",
117+
# srcs = ["parquet_reader_test.cc"],
118+
# data = [
119+
# "//struct2tensor/testdata/parquet_testdata",
120+
# ],
121+
# deps = [
122+
# ":parquet_reader_lib",
123+
# "@com_google_googletest//:gtest_main", # Replaces Google-internal //testing/base/public:gunit_main
124+
# "@org_tensorflow//tensorflow/core:framework",
125+
# ],
126+
# )
127+
# Test file parquet_reader_util_test.cc does not exist, commenting out
128+
# cc_test(
129+
# name = "parquet_reader_util_test",
130+
# srcs = ["parquet_reader_util_test.cc"],
131+
# data = [
132+
# "//struct2tensor/testdata/parquet_testdata",
133+
# ],
134+
# deps = [
135+
# ":parquet_reader_util_lib",
136+
# "@com_google_googletest//:gtest_main", # Replaces Google-internal //testing/base/public:gunit_main
137+
# ],
138+
# )

struct2tensor/struct2tensor.bzl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,3 +181,15 @@ def s2t_proto_library_py(name, proto_library, srcs = [], deps = [], oss_deps = [
181181
visibility = visibility,
182182
testonly = testonly,
183183
)
184+
185+
def py_proto_library(name, deps, visibility = None, **kwargs):
186+
"""Simple wrapper for py_proto_library using custom rule.
187+
188+
This macro provides OSS compatibility for py_proto_library targets.
189+
"""
190+
_py_proto_library_rule(
191+
name = name,
192+
deps = deps,
193+
visibility = visibility,
194+
**kwargs
195+
)

struct2tensor/test/test_any.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ syntax = "proto3";
1616

1717
package struct2tensor.test;
1818

19-
import "google/protobuf/any.proto";
19+
import "struct2tensor/test/any.proto";
2020

2121
message MessageWithAny {
2222
google.protobuf.Any my_any = 1;

struct2tensor/tools/BUILD

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ py_library(
2727
deps = [
2828
"//struct2tensor",
2929
"//struct2tensor:struct2tensor_expression_impl",
30-
"//third_party/py/absl:app",
31-
"//third_party/py/tensorflow_docs/api_generator:generate_lib",
32-
"//third_party/py/tensorflow_docs/api_generator:public_api",
33-
"//third_party/py/yaml",
30+
# Google-internal dependencies - not available in OSS
31+
# "//third_party/py/absl:app",
32+
# "//third_party/py/tensorflow_docs/api_generator:generate_lib",
33+
# "//third_party/py/tensorflow_docs/api_generator:public_api",
34+
# "//third_party/py/yaml",
3435
"@absl_py//absl/flags",
3536
],
3637
)

0 commit comments

Comments
 (0)