From ca5f951137a121e55ca21ee162afd1be596775ba Mon Sep 17 00:00:00 2001 From: Josh Haberman Date: Thu, 24 Jan 2019 12:19:08 -0800 Subject: [PATCH] More fixes for google3 import. --- BUILD | 17 +++++++++++++---- build_defs.bzl | 19 +++++++++++++++++-- tools/make_cmakelists.py | 7 +++++-- 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/BUILD b/BUILD index 95939364a0..1c6cdef230 100644 --- a/BUILD +++ b/BUILD @@ -7,6 +7,7 @@ load( "lua_library", "lua_test", "make_shell_script", + "map_dep", "upb_amalgamation", "upb_proto_library", "upb_proto_reflection_library", @@ -122,9 +123,9 @@ cc_library( ], hdrs = ["upbc/generator.h"], deps = [ - "@absl//absl/strings", - "@com_google_protobuf//:protobuf", - "@com_google_protobuf//:protoc_lib", + map_dep("@absl//absl/strings"), + map_dep("@com_google_protobuf//:protobuf"), + map_dep("@com_google_protobuf//:protoc_lib"), ], ) @@ -133,10 +134,16 @@ cc_binary( srcs = ["upbc/main.cc"], deps = [ ":upbc_generator", - "@com_google_protobuf//:protoc_lib", + map_dep("@com_google_protobuf//:protoc_lib"), ], ) + +# We strip the tests and remaining rules from google3 until the upb_proto_library() +# and upb_proto_reflection_library() rules are fixed. + +# copybara:strip_for_google3_begin + # C/C++ tests ################################################################## cc_library( @@ -487,3 +494,5 @@ generated_file_staleness_test( ], generated_pattern = "generated/%s", ) + +# copybara:strip_end diff --git a/build_defs.bzl b/build_defs.bzl index bb4d6f878a..1c26a00074 100644 --- a/build_defs.bzl +++ b/build_defs.bzl @@ -207,6 +207,21 @@ upb_amalgamation = rule( }, ) +is_bazel = not hasattr(native, "genmpm") + +google3_dep_map = { + "@absl//absl/strings": "//third_party/absl/strings", + "@com_google_protobuf//:protoc": "//third_party/protobuf:protoc", + "@com_google_protobuf//:protobuf": "//third_party/protobuf:protobuf", + "@com_google_protobuf//:protoc_lib": "//third_party/protobuf:libprotoc", +} + +def map_dep(dep): + if is_bazel: + return dep + else: + return google3_dep_map[dep] + # upb_proto_library() rule def _remove_up(string): @@ -261,7 +276,7 @@ _upb_proto_library_srcs = rule( "protoc": attr.label( executable = True, cfg = "host", - default = "@com_google_protobuf//:protoc", + default = map_dep("@com_google_protobuf//:protoc"), ), "deps": attr.label_list(), }, @@ -291,7 +306,7 @@ _upb_proto_reflection_library_srcs = rule( "protoc": attr.label( executable = True, cfg = "host", - default = "@com_google_protobuf//:protoc", + default = map_dep("@com_google_protobuf//:protoc"), ), "deps": attr.label_list(), }, diff --git a/tools/make_cmakelists.py b/tools/make_cmakelists.py index 1e1c1ee049..86544cbe8e 100755 --- a/tools/make_cmakelists.py +++ b/tools/make_cmakelists.py @@ -134,12 +134,15 @@ class BuildFileFunctions(object): def select(self, arg_dict): return [] - def glob(*args): + def glob(self, *args): return [] - def licenses(*args): + def licenses(self, *args): pass + def map_dep(self, arg): + return arg + class WorkspaceFileFunctions(object): def __init__(self, converter):