Skip to content

Commit

Permalink
Split the JSON rules out of the main BUILD file and removed obsolete …
Browse files Browse the repository at this point in the history
…forwarding headers

PiperOrigin-RevId: 541016462
  • Loading branch information
haberman authored and copybara-github committed Jun 16, 2023
1 parent ee24ef2 commit ba50073
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 146 deletions.
76 changes: 3 additions & 73 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -743,29 +743,10 @@ cc_library(
],
)

# TODO(b/232091617): Once we can delete the deprecated forwarding headers
# (= everything in upb/) we can move this build target down into json/
cc_library(
alias(
name = "json",
srcs = [
"upb/json/decode.c",
"upb/json/encode.c",
],
hdrs = [
"upb/json/decode.h",
"upb/json/encode.h",
"upb/json_decode.h",
"upb/json_encode.h",
],
copts = UPB_DEFAULT_COPTS,
actual = "//upb/json",
visibility = ["//visibility:public"],
deps = [
":collections",
":lex",
":port",
":reflection",
":upb",
],
)

# Tests ########################################################################
Expand All @@ -790,53 +771,6 @@ cc_test(
],
)

proto_library(
name = "json_test_proto",
testonly = 1,
srcs = ["upb/json/test.proto"],
deps = ["@com_google_protobuf//:struct_proto"],
)

upb_proto_library(
name = "json_test_upb_proto",
testonly = 1,
deps = [":json_test_proto"],
)

upb_proto_reflection_library(
name = "json_test_upb_proto_reflection",
testonly = 1,
deps = [":json_test_proto"],
)

cc_test(
name = "json_decode_test",
srcs = ["upb/json/decode_test.cc"],
deps = [
":json",
":json_test_upb_proto",
":json_test_upb_proto_reflection",
":reflection",
":struct_upb_proto",
":upb",
"@com_google_googletest//:gtest_main",
],
)

cc_test(
name = "json_encode_test",
srcs = ["upb/json/encode_test.cc"],
deps = [
":json",
":json_test_upb_proto",
":json_test_upb_proto_reflection",
":reflection",
":struct_upb_proto",
":upb",
"@com_google_googletest//:gtest_main",
],
)

cc_test(
name = "collections_test",
srcs = ["upb/collections/test.cc"],
Expand All @@ -856,6 +790,7 @@ cc_test(
":message_test_upb_proto_reflection",
":reflection",
":upb",
"//upb/json",
"//upb/test:fuzz_util",
"//upb/test:test_messages_proto3_upb_proto",
"@com_google_googletest//:gtest_main",
Expand All @@ -881,11 +816,6 @@ upb_proto_reflection_library(
deps = [":message_test_proto"],
)

upb_proto_library(
name = "struct_upb_proto",
deps = ["@com_google_protobuf//:struct_proto"],
)

cc_test(
name = "atoi_test",
srcs = ["upb/lex/atoi_test.cc"],
Expand Down
3 changes: 3 additions & 0 deletions cmake/make_cmakelists.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ def bootstrap_upb_proto_library(self, **kwargs):
def bootstrap_cc_library(self, **kwargs):
pass

def alias(self, **kwargs):
pass


class WorkspaceFileFunctions(object):
def __init__(self, converter):
Expand Down
2 changes: 2 additions & 0 deletions upb/conformance/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ cc_binary(
"//:reflection",
"//:textformat",
"//:wire",
"//upb/json",
],
)

Expand Down Expand Up @@ -141,6 +142,7 @@ cc_binary(
"//:reflection",
"//:textformat",
"//:wire",
"//upb/json",
],
)

Expand Down
84 changes: 84 additions & 0 deletions upb/json/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# TODO(haberman): describe this package.

load(
"//bazel:build_defs.bzl",
"UPB_DEFAULT_COPTS",
)
load(
"//bazel:upb_proto_library.bzl",
"upb_proto_library",
"upb_proto_reflection_library",
)

cc_library(
name = "json",
srcs = [
"decode.c",
"encode.c",
],
hdrs = [
"decode.h",
"encode.h",
],
copts = UPB_DEFAULT_COPTS,
visibility = ["//visibility:public"],
deps = [
"//:collections",
"//:lex",
"//:port",
"//:reflection",
"//:upb",
],
)

cc_test(
name = "encode_test",
srcs = ["encode_test.cc"],
deps = [
":json",
":json_test_upb_proto",
":json_test_upb_proto_reflection",
":struct_upb_proto",
"//:reflection",
"//:upb",
"@com_google_googletest//:gtest_main",
],
)

proto_library(
name = "json_test_proto",
testonly = 1,
srcs = ["test.proto"],
deps = ["@com_google_protobuf//:struct_proto"],
)

upb_proto_library(
name = "json_test_upb_proto",
testonly = 1,
deps = [":json_test_proto"],
)

upb_proto_reflection_library(
name = "json_test_upb_proto_reflection",
testonly = 1,
deps = [":json_test_proto"],
)

cc_test(
name = "json_decode_test",
srcs = ["decode_test.cc"],
deps = [
":json",
":json_test_upb_proto",
":json_test_upb_proto_reflection",
":struct_upb_proto",
"//:reflection",
"//:upb",
"@com_google_googletest//:gtest_main",
],
)

upb_proto_library(
name = "struct_upb_proto",
deps = ["@com_google_protobuf//:struct_proto"],
)
36 changes: 0 additions & 36 deletions upb/json_decode.h

This file was deleted.

36 changes: 0 additions & 36 deletions upb/json_encode.h

This file was deleted.

1 change: 1 addition & 0 deletions upb/test/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ cc_test(
"//:json",
"//:port",
"//:reflection",
"//upb/json",
"@com_google_googletest//:gtest_main",
],
)
Expand Down
2 changes: 1 addition & 1 deletion upb/util/required_fields_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "absl/strings/string_view.h"
#include "upb/json_decode.h"
#include "upb/json/decode.h"
#include "upb/reflection/def.hpp"
#include "upb/upb.hpp"
#include "upb/util/required_fields_test.upb.h"
Expand Down
1 change: 1 addition & 0 deletions upbc/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ cc_library(
"//:mini_table",
"//:port",
"//:reflection",
"//upb/json",
],
)

Expand Down

0 comments on commit ba50073

Please sign in to comment.