Skip to content

Commit cf62123

Browse files
dmitriplotnikovcopybara-github
authored andcommitted
Remove CelRuntime dependency on CelLiteRuntime.
This provides a clean dependency separation: downstream build targets depend either on the full or lite protobuf library, but not both. PiperOrigin-RevId: 787255311
1 parent 55662ab commit cf62123

File tree

3 files changed

+56
-7
lines changed

3 files changed

+56
-7
lines changed

runtime/src/main/java/dev/cel/runtime/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,6 @@ java_library(
793793
":function_resolver",
794794
":interpretable",
795795
":interpreter",
796-
":lite_runtime",
797796
":proto_message_activation_factory",
798797
":proto_message_runtime_equality",
799798
":runtime_equality",

runtime/src/main/java/dev/cel/runtime/CelRuntime.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,20 @@ public interface CelRuntime {
3737

3838
/** Creates an evaluable {@code Program} instance which is thread-safe and immutable. */
3939
@Immutable
40-
interface Program extends CelLiteRuntime.Program {
40+
interface Program {
41+
42+
/** Evaluate the expression without any variables. */
43+
Object eval() throws CelEvaluationException;
44+
45+
/** Evaluate the expression using a {@code mapValue} as the source of input variables. */
46+
Object eval(Map<String, ?> mapValue) throws CelEvaluationException;
47+
48+
/**
49+
* Evaluate a compiled program with {@code mapValue} and late-bound functions {@code
50+
* lateBoundFunctionResolver}.
51+
*/
52+
Object eval(Map<String, ?> mapValue, CelFunctionResolver lateBoundFunctionResolver)
53+
throws CelEvaluationException;
4154

4255
/** Evaluate the expression using {@code message} fields as the source of input variables. */
4356
Object eval(Message message) throws CelEvaluationException;

runtime/src/test/java/dev/cel/runtime/BUILD.bazel

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ java_library(
1919
# keep sorted
2020
exclude = [
2121
"CelLiteInterpreterTest.java",
22+
"CelLiteRuntimeTest.java",
2223
"CelValueInterpreterTest.java",
2324
"InterpreterTest.java",
2425
] + ANDROID_TESTS,
@@ -48,7 +49,6 @@ java_library(
4849
"//common/types:cel_v1alpha1_types",
4950
"//common/types:message_type_provider",
5051
"//common/values:cel_value_provider",
51-
"//common/values:proto_message_lite_value_provider",
5252
"//compiler",
5353
"//compiler:compiler_builder",
5454
"//extensions:optional_library",
@@ -65,8 +65,6 @@ java_library(
6565
"//runtime:interpreter",
6666
"//runtime:interpreter_util",
6767
"//runtime:late_function_binding",
68-
"//runtime:lite_runtime",
69-
"//runtime:lite_runtime_factory",
7068
"//runtime:proto_message_activation_factory",
7169
"//runtime:proto_message_runtime_equality",
7270
"//runtime:proto_message_runtime_helpers",
@@ -89,12 +87,10 @@ java_library(
8987
"@com_google_googleapis//google/rpc/context:attribute_context_java_proto",
9088
"@maven//:com_google_guava_guava",
9189
"@maven//:com_google_protobuf_protobuf_java",
92-
"@maven//:com_google_protobuf_protobuf_java_util",
9390
"@maven//:com_google_testparameterinjector_test_parameter_injector",
9491
"@maven//:com_google_truth_extensions_truth_proto_extension",
9592
"@maven//:junit_junit",
9693
"@maven//:org_jspecify_jspecify",
97-
"@maven_android//:com_google_protobuf_protobuf_javalite",
9894
],
9995
)
10096

@@ -161,6 +157,46 @@ cel_android_local_test(
161157
],
162158
)
163159

160+
java_library(
161+
name = "cel_lite_runtime_test",
162+
testonly = 1,
163+
srcs = [
164+
"CelLiteRuntimeTest.java",
165+
],
166+
deps = [
167+
"//:java_truth",
168+
"//common:cel_ast",
169+
"//common:compiler_common",
170+
"//common/internal:proto_time_utils",
171+
"//common/types",
172+
"//common/values:proto_message_lite_value_provider",
173+
"//compiler",
174+
"//compiler:compiler_builder",
175+
"//parser:macro",
176+
"//runtime",
177+
"//runtime:function_binding",
178+
"//runtime:lite_runtime",
179+
"//runtime:lite_runtime_factory",
180+
"//runtime:standard_functions",
181+
"//testing/protos:message_with_enum_cel_java_proto",
182+
"//testing/protos:message_with_enum_java_proto",
183+
"//testing/protos:multi_file_cel_java_proto",
184+
"//testing/protos:multi_file_java_proto",
185+
"//testing/protos:single_file_java_proto",
186+
"//testing/protos:test_all_types_cel_java_proto2",
187+
"//testing/protos:test_all_types_cel_java_proto3",
188+
"@cel_spec//proto/cel/expr/conformance/proto2:test_all_types_java_proto",
189+
"@cel_spec//proto/cel/expr/conformance/proto3:test_all_types_java_proto",
190+
"@maven//:com_google_guava_guava",
191+
"@maven//:com_google_protobuf_protobuf_java",
192+
"@maven//:com_google_protobuf_protobuf_java_util",
193+
"@maven//:com_google_testparameterinjector_test_parameter_injector",
194+
"@maven//:com_google_truth_extensions_truth_proto_extension",
195+
"@maven//:junit_junit",
196+
"@maven_android//:com_google_protobuf_protobuf_javalite",
197+
],
198+
)
199+
164200
java_library(
165201
name = "cel_lite_interpreter_test",
166202
testonly = 1,
@@ -188,6 +224,7 @@ junit4_test_suites(
188224
src_dir = "src/test/java",
189225
deps = [
190226
":cel_lite_interpreter_test",
227+
":cel_lite_runtime_test",
191228
":cel_value_interpreter_test",
192229
":interpreter_test",
193230
":tests",

0 commit comments

Comments
 (0)