Skip to content

Commit

Permalink
Format with buildifier
Browse files Browse the repository at this point in the history
  • Loading branch information
cushon authored and acozzette committed Jul 1, 2019
1 parent bedef1e commit 2b857d0
Showing 1 changed file with 93 additions and 51 deletions.
144 changes: 93 additions & 51 deletions BUILD
Expand Up @@ -27,25 +27,25 @@ ZLIB_DEPS = ["@zlib//:zlib"]

MSVC_COPTS = [
"/DHAVE_PTHREAD",
"/wd4018", # -Wno-sign-compare
"/wd4065", # switch statement contains 'default' but no 'case' labels
"/wd4146", # unary minus operator applied to unsigned type, result still unsigned
"/wd4244", # 'conversion' conversion from 'type1' to 'type2', possible loss of data
"/wd4251", # 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'
"/wd4267", # 'var' : conversion from 'size_t' to 'type', possible loss of data
"/wd4305", # 'identifier' : truncation from 'type1' to 'type2'
"/wd4307", # 'operator' : integral constant overflow
"/wd4309", # 'conversion' : truncation of constant value
"/wd4334", # 'operator' : result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
"/wd4355", # 'this' : used in base member initializer list
"/wd4506", # no definition for inline function 'function'
"/wd4514", # -Wno-unused-function
"/wd4800", # 'type' : forcing value to bool 'true' or 'false' (performance warning)
"/wd4996", # The compiler encountered a deprecated declaration.
"/wd4018", # -Wno-sign-compare
"/wd4065", # switch statement contains 'default' but no 'case' labels
"/wd4146", # unary minus operator applied to unsigned type, result still unsigned
"/wd4244", # 'conversion' conversion from 'type1' to 'type2', possible loss of data
"/wd4251", # 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'
"/wd4267", # 'var' : conversion from 'size_t' to 'type', possible loss of data
"/wd4305", # 'identifier' : truncation from 'type1' to 'type2'
"/wd4307", # 'operator' : integral constant overflow
"/wd4309", # 'conversion' : truncation of constant value
"/wd4334", # 'operator' : result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
"/wd4355", # 'this' : used in base member initializer list
"/wd4506", # no definition for inline function 'function'
"/wd4514", # -Wno-unused-function
"/wd4800", # 'type' : forcing value to bool 'true' or 'false' (performance warning)
"/wd4996", # The compiler encountered a deprecated declaration.
]

COPTS = select({
":msvc" : MSVC_COPTS,
":msvc": MSVC_COPTS,
"//conditions:default": [
"-DHAVE_PTHREAD",
"-DHAVE_ZLIB",
Expand All @@ -59,7 +59,10 @@ COPTS = select({

load(":compiler_config_setting.bzl", "create_compiler_config_setting")

create_compiler_config_setting(name = "msvc", value = "msvc-cl")
create_compiler_config_setting(
name = "msvc",
value = "msvc-cl",
)

config_setting(
name = "android",
Expand Down Expand Up @@ -91,7 +94,10 @@ LINK_OPTS = select({
# Suppress linker warnings about files with no symbols defined.
"-ignore:4221",
],
"//conditions:default": ["-lpthread", "-lm"],
"//conditions:default": [
"-lpthread",
"-lm",
],
})

load(
Expand Down Expand Up @@ -135,7 +141,10 @@ cc_library(
"src/google/protobuf/stubs/time.cc",
"src/google/protobuf/wire_format_lite.cc",
],
hdrs = glob(["src/google/protobuf/**/*.h", "src/google/protobuf/**/*.inc"]),
hdrs = glob([
"src/google/protobuf/**/*.h",
"src/google/protobuf/**/*.inc",
]),
copts = COPTS,
includes = ["src/"],
linkopts = LINK_OPTS,
Expand Down Expand Up @@ -205,7 +214,10 @@ cc_library(
"src/google/protobuf/wire_format.cc",
"src/google/protobuf/wrappers.pb.cc",
],
hdrs = glob(["src/**/*.h", "src/**/*.inc"]),
hdrs = glob([
"src/**/*.h",
"src/**/*.inc",
]),
copts = COPTS,
includes = ["src/"],
linkopts = LINK_OPTS,
Expand All @@ -219,26 +231,44 @@ cc_library(
# TODO(keveman): Remove this target once the support gets added to Bazel.
cc_library(
name = "protobuf_headers",
hdrs = glob(["src/**/*.h", "src/**/*.inc"]),
hdrs = glob([
"src/**/*.h",
"src/**/*.inc",
]),
includes = ["src/"],
visibility = ["//visibility:public"],
)

# Map of all well known protos.
# name => (include path, imports)
WELL_KNOWN_PROTO_MAP = {
"any" : ("google/protobuf/any.proto", []),
"api" : ("google/protobuf/api.proto", ["source_context", "type"]),
"compiler_plugin" : ("google/protobuf/compiler/plugin.proto", ["descriptor"]),
"descriptor" : ("google/protobuf/descriptor.proto", []),
"duration" : ("google/protobuf/duration.proto", []),
"empty" : ("google/protobuf/empty.proto", []),
"field_mask" : ("google/protobuf/field_mask.proto", []),
"source_context" : ("google/protobuf/source_context.proto", []),
"struct" : ("google/protobuf/struct.proto", []),
"timestamp" : ("google/protobuf/timestamp.proto", []),
"type" : ("google/protobuf/type.proto", ["any", "source_context"]),
"wrappers" : ("google/protobuf/wrappers.proto", []),
"any": ("google/protobuf/any.proto", []),
"api": (
"google/protobuf/api.proto",
[
"source_context",
"type",
],
),
"compiler_plugin": (
"google/protobuf/compiler/plugin.proto",
["descriptor"],
),
"descriptor": ("google/protobuf/descriptor.proto", []),
"duration": ("google/protobuf/duration.proto", []),
"empty": ("google/protobuf/empty.proto", []),
"field_mask": ("google/protobuf/field_mask.proto", []),
"source_context": ("google/protobuf/source_context.proto", []),
"struct": ("google/protobuf/struct.proto", []),
"timestamp": ("google/protobuf/timestamp.proto", []),
"type": (
"google/protobuf/type.proto",
[
"any",
"source_context",
],
),
"wrappers": ("google/protobuf/wrappers.proto", []),
}

RELATIVE_WELL_KNOWN_PROTOS = [proto[1][0] for proto in WELL_KNOWN_PROTO_MAP.items()]
Expand Down Expand Up @@ -284,9 +314,9 @@ internal_copied_filegroup(
[proto_library(
name = proto[0] + "_proto",
srcs = [proto[1][0]],
deps = [dep + "_proto" for dep in proto[1][1]],
visibility = ["//visibility:public"],
) for proto in WELL_KNOWN_PROTO_MAP.items()]
deps = [dep + "_proto" for dep in proto[1][1]],
) for proto in WELL_KNOWN_PROTO_MAP.items()]

################################################################################
# Protocol Buffers Compiler
Expand Down Expand Up @@ -514,11 +544,14 @@ cc_binary(
cc_test(
name = "win32_test",
srcs = ["src/google/protobuf/io/io_win32_unittest.cc"],
tags = [
"manual",
"windows",
],
deps = [
":protobuf_lite",
"//external:gtest_main",
],
tags = ["manual", "windows"],
)

cc_test(
Expand Down Expand Up @@ -598,11 +631,11 @@ cc_test(
"src/google/protobuf/well_known_types_unittest.cc",
"src/google/protobuf/wire_format_unittest.cc",
] + select({
"//conditions:default" : [
"//conditions:default": [
# Doesn't pass on Windows with MSVC
"src/google/protobuf/compiler/command_line_interface_unittest.cc",
],
":msvc": []
":msvc": [],
}),
copts = COPTS,
data = [
Expand Down Expand Up @@ -640,8 +673,11 @@ java_library(
":gen_well_known_protos_java",
],
javacopts = select({
"//:jdk9": ["--add-modules=jdk.unsupported"],
"//conditions:default": ["-source 7", "-target 7"],
"//:jdk9": ["--add-modules=jdk.unsupported"],
"//conditions:default": [
"-source 7",
"-target 7",
],
}),
visibility = ["//visibility:public"],
)
Expand Down Expand Up @@ -752,7 +788,10 @@ java_library(
srcs = glob([
"java/util/src/main/java/com/google/protobuf/util/*.java",
]),
javacopts = ["-source 7", "-target 7"],
javacopts = [
"-source 7",
"-target 7",
],
visibility = ["//visibility:public"],
deps = [
"protobuf_java",
Expand Down Expand Up @@ -869,11 +908,11 @@ py_proto_library(
}),
default_runtime = "",
protoc = ":protoc",
py_extra_srcs = glob(["python/**/__init__.py"]),
py_libs = [
":python_srcs",
"//external:six",
],
py_extra_srcs = glob(["python/**/__init__.py"]),
srcs_version = "PY2AND3",
visibility = ["//visibility:public"],
)
Expand Down Expand Up @@ -965,18 +1004,18 @@ internal_protobuf_py_tests(
cc_library(
name = "proto_api",
hdrs = ["python/google/protobuf/proto_api.h"],
visibility = ["//visibility:public"],
deps = [
"//external:python_headers",
],
visibility = ["//visibility:public"],
)

proto_lang_toolchain(
name = "cc_toolchain",
blacklisted_protos = [":_internal_wkt_protos_genrule"],
command_line = "--cpp_out=$(OUT)",
runtime = ":protobuf",
visibility = ["//visibility:public"],
blacklisted_protos = [":_internal_wkt_protos_genrule"],
)

proto_lang_toolchain(
Expand Down Expand Up @@ -1079,22 +1118,22 @@ genrule(
name = "generated_protos",
srcs = ["src/google/protobuf/unittest_import.proto"],
outs = ["unittest_gen.proto"],
cmd = "cat $(SRCS) | sed 's|google/|src/google/|' > $(OUTS)"
cmd = "cat $(SRCS) | sed 's|google/|src/google/|' > $(OUTS)",
)

proto_library(
name = "generated_protos_proto",
srcs = [
"unittest_gen.proto",
"src/google/protobuf/unittest_import_public.proto",
"unittest_gen.proto",
],
)

py_proto_library(
name = "generated_protos_py",
srcs = [
"unittest_gen.proto",
"src/google/protobuf/unittest_import_public.proto",
"unittest_gen.proto",
],
default_runtime = "",
protoc = ":protoc",
Expand All @@ -1113,6 +1152,7 @@ proto_library(
proto_library(
name = "test_messages_proto3_proto",
srcs = ["src/google/protobuf/test_messages_proto3.proto"],
visibility = ["//visibility:public"],
deps = [
":any_proto",
":duration_proto",
Expand All @@ -1121,7 +1161,6 @@ proto_library(
":timestamp_proto",
":wrappers_proto",
],
visibility = ["//visibility:public"],
)

cc_proto_library(
Expand Down Expand Up @@ -1150,8 +1189,8 @@ cc_proto_library(

cc_library(
name = "jsoncpp",
hdrs = ["conformance/third_party/jsoncpp/json.h"],
srcs = ["conformance/third_party/jsoncpp/jsoncpp.cpp"],
hdrs = ["conformance/third_party/jsoncpp/json.h"],
includes = ["conformance"],
)

Expand All @@ -1164,8 +1203,11 @@ cc_library(
hdrs = [
"conformance/conformance_test.h",
],
includes = [
"conformance",
"src",
],
deps = [":conformance_proto_cc"],
includes = ["conformance", "src"],
)

cc_library(
Expand Down Expand Up @@ -1194,10 +1236,10 @@ cc_library(
cc_binary(
name = "conformance_test_runner",
srcs = ["conformance/conformance_test_main.cc"],
visibility = ["//visibility:public"],
deps = [
":binary_json_conformance_suite",
":conformance_test",
":text_format_conformance_suite",
],
visibility = ["//visibility:public"],
)

0 comments on commit 2b857d0

Please sign in to comment.