summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbttk <bttk@google.com>2019-12-02 14:14:48 -0800
committerWouter van Oortmerssen <aardappel@gmail.com>2019-12-02 14:14:48 -0800
commit99d11e279f290c0ad0e835b7c257dbc84a2161c9 (patch)
tree8bd3a34318fdf31b30d26133c6e9aaf72a32fa68
parent4fd8eb214b93d9d60a5753d2db9cbbba4a9ec937 (diff)
downloadflatbuffers-99d11e279f290c0ad0e835b7c257dbc84a2161c9.tar.gz
flatbuffers-99d11e279f290c0ad0e835b7c257dbc84a2161c9.tar.bz2
flatbuffers-99d11e279f290c0ad0e835b7c257dbc84a2161c9.zip
Split Bazel targets into multiple packages (#5640)
* Split Bazel targets into multiple packages * Merge /include/BUILD back into /BUILD
-rw-r--r--BUILD196
-rw-r--r--grpc/src/compiler/BUILD89
-rw-r--r--grpc/src/compiler/java_generator.cc2
-rw-r--r--src/BUILD73
-rw-r--r--tests/BUILD105
5 files changed, 287 insertions, 178 deletions
diff --git a/BUILD b/BUILD
index 5042553c..4f8107b2 100644
--- a/BUILD
+++ b/BUILD
@@ -1,35 +1,22 @@
licenses(["notice"])
-load("@rules_cc//cc:defs.bzl", "cc_library")
+load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
package(
default_visibility = ["//visibility:public"],
- features = [
- "-layering_check",
- "-parse_headers",
- ],
)
exports_files([
"LICENSE",
])
-load(":build_defs.bzl", "flatbuffer_cc_library")
-
# Public flatc library to compile flatbuffer files at runtime.
cc_library(
name = "flatbuffers",
- srcs = [
- "src/code_generators.cpp",
- "src/idl_gen_fbs.cpp",
- "src/idl_gen_text.cpp",
- "src/idl_parser.cpp",
- "src/reflection.cpp",
- "src/util.cpp",
- ],
- hdrs = [":public_headers"],
- includes = ["include/"],
+ hdrs = ["//:public_headers"],
linkstatic = 1,
+ strip_include_prefix = "/include",
+ deps = ["//src:flatbuffers"],
)
# Public C++ headers for the Flatbuffers library.
@@ -45,6 +32,7 @@ filegroup(
"include/flatbuffers/minireflect.h",
"include/flatbuffers/reflection.h",
"include/flatbuffers/reflection_generated.h",
+ "include/flatbuffers/registry.h",
"include/flatbuffers/stl_emulation.h",
"include/flatbuffers/util.h",
],
@@ -53,66 +41,29 @@ filegroup(
# Public flatc compiler library.
cc_library(
name = "flatc_library",
- srcs = [
- "src/code_generators.cpp",
- "src/flatc.cpp",
- "src/idl_gen_fbs.cpp",
- "src/idl_parser.cpp",
- "src/reflection.cpp",
- "src/util.cpp",
- ],
- hdrs = [
- "include/flatbuffers/flatc.h",
- ":public_headers",
- ],
- includes = [
- "grpc/",
- "include/",
+ linkstatic = 1,
+ deps = [
+ "//src:flatc_library",
],
)
# Public flatc compiler.
cc_binary(
name = "flatc",
- srcs = [
- "grpc/src/compiler/config.h",
- "grpc/src/compiler/cpp_generator.cc",
- "grpc/src/compiler/cpp_generator.h",
- "grpc/src/compiler/go_generator.cc",
- "grpc/src/compiler/go_generator.h",
- "grpc/src/compiler/python_generator.cc",
- "grpc/src/compiler/python_generator.h",
- "grpc/src/compiler/python_private_generator.h",
- "grpc/src/compiler/java_generator.cc",
- "grpc/src/compiler/java_generator.h",
- "grpc/src/compiler/schema_interface.h",
- "src/flatc_main.cpp",
- "src/idl_gen_cpp.cpp",
- "src/idl_gen_csharp.cpp",
- "src/idl_gen_dart.cpp",
- "src/idl_gen_go.cpp",
- "src/idl_gen_grpc.cpp",
- "src/idl_gen_java.cpp",
- "src/idl_gen_js_ts.cpp",
- "src/idl_gen_json_schema.cpp",
- "src/idl_gen_kotlin.cpp",
- "src/idl_gen_lobster.cpp",
- "src/idl_gen_lua.cpp",
- "src/idl_gen_php.cpp",
- "src/idl_gen_python.cpp",
- "src/idl_gen_rust.cpp",
- "src/idl_gen_text.cpp",
- "src/util.cpp",
- ],
- includes = [
- "grpc/",
- "include/",
- ],
deps = [
- ":flatc_library",
+ "//src:flatc",
],
)
+filegroup(
+ name = "flatc_headers",
+ srcs = [
+ "include/flatbuffers/flatc.h",
+ ],
+ visibility = ["//:__subpackages__"],
+)
+
+# Library used by flatbuffer_cc_library rules.
cc_library(
name = "runtime_cc",
hdrs = [
@@ -122,115 +73,6 @@ cc_library(
"include/flatbuffers/stl_emulation.h",
"include/flatbuffers/util.h",
],
- includes = ["include/"],
linkstatic = 1,
-)
-
-# Test binary.
-cc_test(
- name = "flatbuffers_test",
- testonly = 1,
- srcs = [
- "include/flatbuffers/minireflect.h",
- "include/flatbuffers/registry.h",
- "src/code_generators.cpp",
- "src/idl_gen_fbs.cpp",
- "src/idl_gen_text.cpp",
- "src/idl_parser.cpp",
- "src/reflection.cpp",
- "src/util.cpp",
- "tests/evolution_test/evolution_v1_generated.h",
- "tests/evolution_test/evolution_v2_generated.h",
- "tests/namespace_test/namespace_test1_generated.h",
- "tests/namespace_test/namespace_test2_generated.h",
- "tests/native_type_test_impl.cpp",
- "tests/native_type_test_impl.h",
- "tests/test.cpp",
- "tests/test_assert.cpp",
- "tests/test_assert.h",
- "tests/test_builder.cpp",
- "tests/test_builder.h",
- "tests/union_vector/union_vector_generated.h",
- ":public_headers",
- ],
- copts = [
- "-DFLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE",
- "-DBAZEL_TEST_DATA_PATH",
- ],
- data = [
- ":tests/arrays_test.bfbs",
- ":tests/arrays_test.fbs",
- ":tests/arrays_test.golden",
- ":tests/evolution_test/evolution_v1.fbs",
- ":tests/evolution_test/evolution_v1.json",
- ":tests/evolution_test/evolution_v2.fbs",
- ":tests/evolution_test/evolution_v2.json",
- ":tests/include_test/include_test1.fbs",
- ":tests/include_test/sub/include_test2.fbs",
- ":tests/monster_extra.fbs",
- ":tests/monster_test.bfbs",
- ":tests/monster_test.fbs",
- ":tests/monsterdata_extra.json",
- ":tests/monsterdata_test.golden",
- ":tests/monsterdata_test.json",
- ":tests/native_type_test.fbs",
- ":tests/prototest/imported.proto",
- ":tests/prototest/test.golden",
- ":tests/prototest/test.proto",
- ":tests/prototest/test_union.golden",
- ":tests/unicode_test.json",
- ":tests/union_vector/union_vector.fbs",
- ":tests/union_vector/union_vector.json",
- ],
- includes = [
- "include/",
- "tests/",
- ],
- deps = [
- ":arrays_test_cc_fbs",
- ":monster_extra_cc_fbs",
- ":monster_test_cc_fbs",
- ":native_type_test_cc_fbs",
- ],
-)
-
-# Test bzl rules
-
-flatbuffer_cc_library(
- name = "monster_test_cc_fbs",
- srcs = ["tests/monster_test.fbs"],
- include_paths = ["tests/include_test"],
- includes = [
- "tests/include_test/include_test1.fbs",
- "tests/include_test/sub/include_test2.fbs",
- ],
-)
-
-flatbuffer_cc_library(
- name = "monster_extra_cc_fbs",
- srcs = ["tests/monster_extra.fbs"],
-)
-
-flatbuffer_cc_library(
- name = "arrays_test_cc_fbs",
- srcs = ["tests/arrays_test.fbs"],
- flatc_args = [
- "--gen-object-api",
- "--gen-compare",
- "--no-includes",
- "--gen-mutable",
- "--reflect-names",
- "--cpp-ptr-type flatbuffers::unique_ptr",
- "--scoped-enums",
- ],
-)
-
-flatbuffer_cc_library(
- name = "native_type_test_cc_fbs",
- srcs = ["tests/native_type_test.fbs"],
- flatc_args = [
- "--gen-object-api",
- "--gen-mutable",
- "--cpp-ptr-type flatbuffers::unique_ptr",
- ],
+ strip_include_prefix = "/include",
)
diff --git a/grpc/src/compiler/BUILD b/grpc/src/compiler/BUILD
new file mode 100644
index 00000000..9aa394b5
--- /dev/null
+++ b/grpc/src/compiler/BUILD
@@ -0,0 +1,89 @@
+package(
+ default_visibility = ["//visibility:public"],
+)
+
+filegroup(
+ name = "common_headers",
+ srcs = [
+ "config.h",
+ "schema_interface.h",
+ ],
+)
+
+cc_library(
+ name = "cpp_generator",
+ srcs = [
+ "cpp_generator.cc",
+ ],
+ hdrs = [
+ "cpp_generator.h",
+ ":common_headers",
+ ],
+ include_prefix = "src/compiler",
+ strip_include_prefix = "/grpc/src/compiler",
+ deps = [
+ "//:flatbuffers",
+ ],
+)
+
+cc_library(
+ name = "go_generator",
+ srcs = [
+ "go_generator.cc",
+ ],
+ hdrs = [
+ "go_generator.h",
+ ":common_headers",
+ ],
+ include_prefix = "src/compiler",
+ strip_include_prefix = "/grpc/src/compiler",
+ deps = [
+ "//:flatbuffers",
+ ],
+)
+
+cc_library(
+ name = "java_generator",
+ srcs = [
+ "java_generator.cc",
+ ],
+ hdrs = [
+ "java_generator.h",
+ ":common_headers",
+ ],
+ include_prefix = "src/compiler",
+ strip_include_prefix = "/grpc/src/compiler",
+ deps = [
+ "//:flatbuffers",
+ ],
+)
+
+cc_library(
+ name = "python_generator",
+ hdrs = [
+ "python_generator.h",
+ ],
+ include_prefix = "src/compiler",
+ strip_include_prefix = "/grpc/src/compiler",
+ deps = [
+ ":python_generator_private",
+ ],
+)
+
+cc_library(
+ name = "python_generator_private",
+ srcs = [
+ "python_generator.cc",
+ ],
+ hdrs = [
+ "python_generator.h",
+ "python_private_generator.h",
+ ":common_headers",
+ ],
+ include_prefix = "src/compiler",
+ strip_include_prefix = "/grpc/src/compiler",
+ visibility = ["//visibility:private"],
+ deps = [
+ "//:flatbuffers",
+ ],
+)
diff --git a/grpc/src/compiler/java_generator.cc b/grpc/src/compiler/java_generator.cc
index 661c9ee6..d2cf5ccc 100644
--- a/grpc/src/compiler/java_generator.cc
+++ b/grpc/src/compiler/java_generator.cc
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include "java_generator.h"
+#include "src/compiler/java_generator.h"
#include <algorithm>
#include <iostream>
diff --git a/src/BUILD b/src/BUILD
new file mode 100644
index 00000000..3532a7ac
--- /dev/null
+++ b/src/BUILD
@@ -0,0 +1,73 @@
+package(
+ default_visibility = ["//visibility:private"],
+)
+
+load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
+
+# Public flatc library to compile flatbuffer files at runtime.
+cc_library(
+ name = "flatbuffers",
+ srcs = [
+ "code_generators.cpp",
+ "idl_gen_fbs.cpp",
+ "idl_gen_text.cpp",
+ "idl_parser.cpp",
+ "reflection.cpp",
+ "util.cpp",
+ ],
+ hdrs = ["//:public_headers"],
+ strip_include_prefix = "/include",
+ visibility = ["//:__pkg__"],
+)
+
+# Public flatc compiler library.
+cc_library(
+ name = "flatc_library",
+ srcs = [
+ "flatc.cpp",
+ ],
+ hdrs = [
+ "//:flatc_headers",
+ ],
+ strip_include_prefix = "/include",
+ visibility = ["//:__pkg__"],
+ deps = [
+ ":flatbuffers",
+ ],
+)
+
+# Public flatc compiler.
+cc_library(
+ name = "flatc",
+ srcs = [
+ "flatc_main.cpp",
+ "idl_gen_cpp.cpp",
+ "idl_gen_csharp.cpp",
+ "idl_gen_dart.cpp",
+ "idl_gen_go.cpp",
+ "idl_gen_grpc.cpp",
+ "idl_gen_java.cpp",
+ "idl_gen_js_ts.cpp",
+ "idl_gen_json_schema.cpp",
+ "idl_gen_kotlin.cpp",
+ "idl_gen_lobster.cpp",
+ "idl_gen_lua.cpp",
+ "idl_gen_php.cpp",
+ "idl_gen_python.cpp",
+ "idl_gen_rust.cpp",
+ "idl_gen_text.cpp",
+ "util.cpp",
+ ],
+ hdrs = [
+ "//:flatc_headers",
+ ],
+ strip_include_prefix = "/include",
+ visibility = ["//:__pkg__"],
+ deps = [
+ ":flatc_library",
+ "//grpc/src/compiler:cpp_generator",
+ "//grpc/src/compiler:go_generator",
+ "//grpc/src/compiler:java_generator",
+ "//grpc/src/compiler:python_generator",
+ ],
+)
diff --git a/tests/BUILD b/tests/BUILD
new file mode 100644
index 00000000..8ebd8b66
--- /dev/null
+++ b/tests/BUILD
@@ -0,0 +1,105 @@
+package(
+ default_visibility = ["//visibility:private"],
+)
+
+# Test binary.
+cc_test(
+ name = "flatbuffers_test",
+ testonly = 1,
+ srcs = [
+ "evolution_test/evolution_v1_generated.h",
+ "evolution_test/evolution_v2_generated.h",
+ "namespace_test/namespace_test1_generated.h",
+ "namespace_test/namespace_test2_generated.h",
+ "native_type_test_impl.cpp",
+ "native_type_test_impl.h",
+ "test.cpp",
+ "test_assert.cpp",
+ "test_assert.h",
+ "test_builder.cpp",
+ "test_builder.h",
+ "union_vector/union_vector_generated.h",
+ ],
+ copts = [
+ "-DFLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE",
+ "-DBAZEL_TEST_DATA_PATH",
+ ],
+ data = [
+ ":arrays_test.bfbs",
+ ":arrays_test.fbs",
+ ":arrays_test.golden",
+ ":evolution_test/evolution_v1.fbs",
+ ":evolution_test/evolution_v1.json",
+ ":evolution_test/evolution_v2.fbs",
+ ":evolution_test/evolution_v2.json",
+ ":include_test/include_test1.fbs",
+ ":include_test/sub/include_test2.fbs",
+ ":monster_extra.fbs",
+ ":monster_test.bfbs",
+ ":monster_test.fbs",
+ ":monsterdata_extra.json",
+ ":monsterdata_test.golden",
+ ":monsterdata_test.json",
+ ":native_type_test.fbs",
+ ":prototest/imported.proto",
+ ":prototest/test.golden",
+ ":prototest/test.proto",
+ ":prototest/test_union.golden",
+ ":unicode_test.json",
+ ":union_vector/union_vector.fbs",
+ ":union_vector/union_vector.json",
+ ],
+ includes = [
+ "",
+ "include/",
+ ],
+ deps = [
+ ":arrays_test_cc_fbs",
+ ":monster_extra_cc_fbs",
+ ":monster_test_cc_fbs",
+ ":native_type_test_cc_fbs",
+ "//:flatbuffers",
+ ],
+)
+
+# Test bzl rules
+load("//:build_defs.bzl", "flatbuffer_cc_library")
+
+flatbuffer_cc_library(
+ name = "monster_test_cc_fbs",
+ srcs = ["monster_test.fbs"],
+ include_paths = ["tests/include_test"],
+ includes = [
+ "include_test/include_test1.fbs",
+ "include_test/sub/include_test2.fbs",
+ ],
+)
+
+flatbuffer_cc_library(
+ name = "monster_extra_cc_fbs",
+ srcs = ["monster_extra.fbs"],
+)
+
+flatbuffer_cc_library(
+ name = "arrays_test_cc_fbs",
+ srcs = ["arrays_test.fbs"],
+ flatc_args = [
+ "--gen-object-api",
+ "--gen-compare",
+ "--no-includes",
+ "--gen-mutable",
+ "--reflect-names",
+ "--cpp-ptr-type flatbuffers::unique_ptr",
+ "--scoped-enums",
+ ],
+)
+
+flatbuffer_cc_library(
+ name = "native_type_test_cc_fbs",
+ srcs = ["native_type_test.fbs"],
+ flatc_args = [
+ "--gen-object-api",
+ "--gen-mutable",
+ "--cpp-ptr-type flatbuffers::unique_ptr",
+ ],
+)