[Bazel/C++] Factor out stubs, io, and testing libraries. (#9980)
This change creates packages under src/google/protobuf/{io,stubs,testing} and moves build definitions there. Future changes will handle .../util and .../compiler, and finally src/google/protobuf.pull/9985/head
parent
e235147407
commit
c2c770e7ea
8 changed files with 404 additions and 71 deletions
@ -0,0 +1,146 @@ |
||||
# Protobuf IO library. |
||||
|
||||
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") |
||||
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix") |
||||
load("//build_defs:cpp_opts.bzl", "COPTS", "LINK_OPTS") |
||||
|
||||
package( |
||||
default_visibility = ["//visibility:public"], |
||||
) |
||||
|
||||
cc_library( |
||||
name = "io", |
||||
srcs = [ |
||||
"coded_stream.cc", |
||||
"zero_copy_stream.cc", |
||||
"zero_copy_stream_impl.cc", |
||||
"zero_copy_stream_impl_lite.cc", |
||||
], |
||||
hdrs = [ |
||||
"coded_stream.h", |
||||
"zero_copy_stream.h", |
||||
"zero_copy_stream_impl.h", |
||||
"zero_copy_stream_impl_lite.h", |
||||
], |
||||
copts = COPTS, |
||||
include_prefix = "google/protobuf/io", |
||||
deps = [ |
||||
":io_win32", |
||||
"//:arena", |
||||
"//src/google/protobuf/stubs:lite", |
||||
], |
||||
) |
||||
|
||||
cc_library( |
||||
name = "printer", |
||||
srcs = ["printer.cc"], |
||||
hdrs = ["printer.h"], |
||||
copts = COPTS + select({ |
||||
"//build_defs:config_msvc": [], |
||||
"//conditions:default": ["-Wno-maybe-uninitialized"], |
||||
}), |
||||
include_prefix = "google/protobuf/io", |
||||
deps = [ |
||||
":io", |
||||
"//src/google/protobuf/stubs", |
||||
], |
||||
) |
||||
|
||||
cc_library( |
||||
name = "tokenizer", |
||||
srcs = [ |
||||
"strtod.cc", |
||||
"tokenizer.cc", |
||||
], |
||||
hdrs = [ |
||||
"strtod.h", |
||||
"tokenizer.h", |
||||
], |
||||
copts = COPTS, |
||||
include_prefix = "google/protobuf/io", |
||||
deps = [ |
||||
":io", |
||||
"//src/google/protobuf/stubs", |
||||
], |
||||
) |
||||
|
||||
cc_library( |
||||
name = "gzip_stream", |
||||
srcs = ["gzip_stream.cc"], |
||||
hdrs = ["gzip_stream.h"], |
||||
copts = COPTS + select({ |
||||
"//build_defs:config_msvc": [], |
||||
"//conditions:default": ["-Wno-maybe-uninitialized"], |
||||
}), |
||||
include_prefix = "google/protobuf/io", |
||||
deps = [ |
||||
":io", |
||||
"//src/google/protobuf/stubs", |
||||
] + select({ |
||||
"//build_defs:config_msvc": [], |
||||
"//conditions:default": ["@zlib//:zlib"], |
||||
}), |
||||
) |
||||
|
||||
cc_library( |
||||
name = "io_win32", |
||||
srcs = ["io_win32.cc"], |
||||
hdrs = ["io_win32.h"], |
||||
copts = COPTS, |
||||
include_prefix = "google/protobuf/io", |
||||
visibility = ["//pkg:__pkg__"], |
||||
deps = [ |
||||
"//:arena", |
||||
"//src/google/protobuf/stubs:lite", |
||||
], |
||||
) |
||||
|
||||
cc_test( |
||||
name = "io_test", |
||||
srcs = [ |
||||
"coded_stream_unittest.cc", |
||||
"printer_unittest.cc", |
||||
"tokenizer_unittest.cc", |
||||
"zero_copy_stream_unittest.cc", |
||||
], |
||||
copts = COPTS + select({ |
||||
"//build_defs:config_msvc": [], |
||||
"//conditions:default": ["-Wno-maybe-uninitialized"], |
||||
}), |
||||
data = [ |
||||
"//:testdata", |
||||
], |
||||
deps = [ |
||||
":gzip_stream", |
||||
":io", |
||||
"//:protobuf", |
||||
"//src/google/protobuf/testing", |
||||
"@com_google_googletest//:gtest", |
||||
"@com_google_googletest//:gtest_main", |
||||
], |
||||
) |
||||
|
||||
cc_test( |
||||
name = "win32_test", |
||||
srcs = ["io_win32_unittest.cc"], |
||||
tags = [ |
||||
"manual", |
||||
"windows", |
||||
], |
||||
deps = [ |
||||
"//:protobuf_lite", |
||||
"@com_google_googletest//:gtest", |
||||
"@com_google_googletest//:gtest_main", |
||||
], |
||||
) |
||||
|
||||
################################################################################ |
||||
# Distribution packaging |
||||
################################################################################ |
||||
|
||||
pkg_files( |
||||
name = "dist_files", |
||||
srcs = glob(["**/*"]), |
||||
strip_prefix = strip_prefix.from_root(""), |
||||
visibility = ["//pkg:__pkg__"], |
||||
) |
@ -0,0 +1,138 @@ |
||||
# Protobuf stubs library. |
||||
# These are utilities that mirror the behavior of internal Google code. |
||||
|
||||
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") |
||||
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix") |
||||
load("//build_defs:cpp_opts.bzl", "COPTS", "LINK_OPTS") |
||||
|
||||
package( |
||||
default_visibility = ["//:__subpackages__"], |
||||
) |
||||
|
||||
cc_library( |
||||
name = "lite", |
||||
srcs = [ |
||||
"bytestream.cc", |
||||
"common.cc", |
||||
"int128.cc", |
||||
"status.cc", |
||||
"statusor.cc", |
||||
"stringpiece.cc", |
||||
"stringprintf.cc", |
||||
"structurally_valid.cc", |
||||
"strutil.cc", |
||||
"time.cc", |
||||
], |
||||
hdrs = [ |
||||
"bytestream.h", |
||||
"callback.h", |
||||
"casts.h", |
||||
"common.h", |
||||
"hash.h", |
||||
"int128.h", |
||||
"logging.h", |
||||
"macros.h", |
||||
"map_util.h", |
||||
"mathutil.h", |
||||
"mutex.h", |
||||
"once.h", |
||||
"platform_macros.h", |
||||
"port.h", |
||||
"status.h", |
||||
"status_macros.h", |
||||
"statusor.h", |
||||
"stl_util.h", |
||||
"stringpiece.h", |
||||
"stringprintf.h", |
||||
"strutil.h", |
||||
"template_util.h", |
||||
"time.h", |
||||
], |
||||
copts = COPTS, |
||||
include_prefix = "google/protobuf/stubs", |
||||
linkopts = LINK_OPTS, |
||||
deps = ["//:port_def"], |
||||
) |
||||
|
||||
cc_library( |
||||
name = "stubs", |
||||
srcs = [ |
||||
"substitute.cc", |
||||
], |
||||
hdrs = [ |
||||
"substitute.h", |
||||
], |
||||
copts = COPTS, |
||||
include_prefix = "google/protobuf/stubs", |
||||
textual_hdrs = [ |
||||
"bytestream.h", |
||||
"callback.h", |
||||
"casts.h", |
||||
"common.h", |
||||
"hash.h", |
||||
"int128.h", |
||||
"logging.h", |
||||
"macros.h", |
||||
"map_util.h", |
||||
"mathutil.h", |
||||
"mutex.h", |
||||
"once.h", |
||||
"platform_macros.h", |
||||
"port.h", |
||||
"status.h", |
||||
"status_macros.h", |
||||
"statusor.h", |
||||
"stl_util.h", |
||||
"stringpiece.h", |
||||
"stringprintf.h", |
||||
"strutil.h", |
||||
"template_util.h", |
||||
"time.h", |
||||
], |
||||
deps = [ |
||||
":lite", |
||||
"//:port_def", |
||||
], |
||||
) |
||||
|
||||
cc_test( |
||||
name = "stubs_test", |
||||
srcs = [ |
||||
"bytestream_unittest.cc", |
||||
"common_unittest.cc", |
||||
"int128_unittest.cc", |
||||
"status_test.cc", |
||||
"statusor_test.cc", |
||||
"stringpiece_unittest.cc", |
||||
"stringprintf_unittest.cc", |
||||
"structurally_valid_unittest.cc", |
||||
"strutil_unittest.cc", |
||||
"template_util_unittest.cc", |
||||
"time_test.cc", |
||||
], |
||||
copts = COPTS + select({ |
||||
"//build_defs:config_msvc": [], |
||||
"//conditions:default": [ |
||||
"-Wno-deprecated-declarations", |
||||
], |
||||
}), |
||||
linkopts = LINK_OPTS, |
||||
deps = [ |
||||
":lite", |
||||
":stubs", |
||||
"//src/google/protobuf/testing", |
||||
"@com_google_googletest//:gtest", |
||||
"@com_google_googletest//:gtest_main", |
||||
], |
||||
) |
||||
|
||||
################################################################################ |
||||
# Distribution packaging |
||||
################################################################################ |
||||
|
||||
pkg_files( |
||||
name = "dist_files", |
||||
srcs = glob(["**/*"]), |
||||
strip_prefix = strip_prefix.from_root(""), |
||||
visibility = ["//pkg:__pkg__"], |
||||
) |
@ -0,0 +1,41 @@ |
||||
# Protobuf testing support. |
||||
# This package contains testonly utilities used in C++ unit tests. |
||||
|
||||
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") |
||||
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix") |
||||
load("//build_defs:cpp_opts.bzl", "COPTS", "LINK_OPTS") |
||||
|
||||
package(default_visibility = ["//:__subpackages__"]) |
||||
|
||||
cc_library( |
||||
name = "testing", |
||||
testonly = 1, |
||||
srcs = [ |
||||
"file.cc", |
||||
"googletest.cc", |
||||
], |
||||
hdrs = [ |
||||
"file.h", |
||||
"googletest.h", |
||||
], |
||||
copts = COPTS, |
||||
include_prefix = "google/protobuf/testing", |
||||
linkopts = LINK_OPTS, |
||||
deps = [ |
||||
"//:protobuf_lite", # for ShutdownProtobufLibrary |
||||
"//src/google/protobuf/io", |
||||
"//src/google/protobuf/stubs:lite", |
||||
"@com_google_googletest//:gtest", |
||||
], |
||||
) |
||||
|
||||
################################################################################ |
||||
# Distribution packaging |
||||
################################################################################ |
||||
|
||||
pkg_files( |
||||
name = "dist_files", |
||||
srcs = glob(["**/*"]), |
||||
strip_prefix = strip_prefix.from_root(""), |
||||
visibility = ["//pkg:__pkg__"], |
||||
) |
Loading…
Reference in new issue