From 833e8803da346413676fff088ac97c4c26481a85 Mon Sep 17 00:00:00 2001 From: Austin Anderson Date: Mon, 20 Aug 2018 10:36:54 -0700 Subject: [PATCH] Automated rollback of commit f35866577cb8d27a51b31f49f472e926c4359e1f PiperOrigin-RevId: 209443205 --- .../contrib/lite/delegates/eager/kernel.cc | 2 +- .../contrib/lite/delegates/eager/test_util.cc | 2 +- .../kernels/ctc_beam_search_decoder.cc | 2 +- .../kernels/ctc_beam_search_decoder_test.cc | 2 +- .../contrib/lite/kernels/audio_spectrogram.cc | 2 +- .../lite/kernels/audio_spectrogram_test.cc | 2 +- .../lite/kernels/detection_postprocess.cc | 2 +- .../kernels/detection_postprocess_test.cc | 2 +- tensorflow/contrib/lite/kernels/mfcc.cc | 2 +- tensorflow/contrib/lite/kernels/mfcc_test.cc | 2 +- tensorflow/contrib/lite/schema/BUILD | 2 +- .../schema/flatbuffer_compatibility_test.cc | 2 +- tensorflow/workspace.bzl | 16 +- third_party/flatbuffers/BUILD | 16 +- third_party/flatbuffers/build_defs.bzl | 363 +++++++++--------- .../{BUILD.bazel => flatbuffers.BUILD} | 5 +- third_party/flatbuffers/workspace.bzl | 19 - .../flatbuffers.BUILD} | 0 18 files changed, 214 insertions(+), 229 deletions(-) rename third_party/flatbuffers/{BUILD.bazel => flatbuffers.BUILD} (97%) delete mode 100644 third_party/flatbuffers/workspace.bzl rename third_party/{flatbuffers/BUILD.system => systemlibs/flatbuffers.BUILD} (100%) diff --git a/tensorflow/contrib/lite/delegates/eager/kernel.cc b/tensorflow/contrib/lite/delegates/eager/kernel.cc index b8e329275bb..1082b787259 100644 --- a/tensorflow/contrib/lite/delegates/eager/kernel.cc +++ b/tensorflow/contrib/lite/delegates/eager/kernel.cc @@ -14,7 +14,7 @@ limitations under the License. ==============================================================================*/ #include "tensorflow/contrib/lite/delegates/eager/kernel.h" -#include "include/flatbuffers/flexbuffers.h" // flatbuffers +#include "flatbuffers/flexbuffers.h" #include "tensorflow/contrib/lite/builtin_ops.h" #include "tensorflow/contrib/lite/context.h" #include "tensorflow/contrib/lite/context_util.h" diff --git a/tensorflow/contrib/lite/delegates/eager/test_util.cc b/tensorflow/contrib/lite/delegates/eager/test_util.cc index 203afa6abd9..26d96acc820 100644 --- a/tensorflow/contrib/lite/delegates/eager/test_util.cc +++ b/tensorflow/contrib/lite/delegates/eager/test_util.cc @@ -16,7 +16,7 @@ limitations under the License. #include "tensorflow/contrib/lite/delegates/eager/test_util.h" #include "absl/memory/memory.h" -#include "include/flatbuffers/flexbuffers.h" // flatbuffers +#include "flatbuffers/flexbuffers.h" #include "tensorflow/contrib/lite/string.h" namespace tflite { diff --git a/tensorflow/contrib/lite/experimental/kernels/ctc_beam_search_decoder.cc b/tensorflow/contrib/lite/experimental/kernels/ctc_beam_search_decoder.cc index b6c9a28be69..834d1ebd666 100644 --- a/tensorflow/contrib/lite/experimental/kernels/ctc_beam_search_decoder.cc +++ b/tensorflow/contrib/lite/experimental/kernels/ctc_beam_search_decoder.cc @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ #include -#include "include/flatbuffers/flexbuffers.h" // flatbuffers +#include "flatbuffers/flexbuffers.h" #include "tensorflow/contrib/lite/context.h" #include "tensorflow/contrib/lite/experimental/kernels/ctc_beam_search.h" #include "tensorflow/contrib/lite/kernels/internal/optimized/optimized_ops.h" diff --git a/tensorflow/contrib/lite/experimental/kernels/ctc_beam_search_decoder_test.cc b/tensorflow/contrib/lite/experimental/kernels/ctc_beam_search_decoder_test.cc index 0da5532e663..9d1e6a562f0 100644 --- a/tensorflow/contrib/lite/experimental/kernels/ctc_beam_search_decoder_test.cc +++ b/tensorflow/contrib/lite/experimental/kernels/ctc_beam_search_decoder_test.cc @@ -18,7 +18,7 @@ limitations under the License. #include #include -#include "include/flatbuffers/flexbuffers.h" // flatbuffers +#include "flatbuffers/flexbuffers.h" #include "tensorflow/contrib/lite/interpreter.h" #include "tensorflow/contrib/lite/kernels/register.h" #include "tensorflow/contrib/lite/kernels/test_util.h" diff --git a/tensorflow/contrib/lite/kernels/audio_spectrogram.cc b/tensorflow/contrib/lite/kernels/audio_spectrogram.cc index fbbe172193d..91d8dd3fa71 100644 --- a/tensorflow/contrib/lite/kernels/audio_spectrogram.cc +++ b/tensorflow/contrib/lite/kernels/audio_spectrogram.cc @@ -22,7 +22,7 @@ limitations under the License. #include "tensorflow/contrib/lite/kernels/kernel_util.h" #include "tensorflow/contrib/lite/kernels/op_macros.h" -#include "include/flatbuffers/flexbuffers.h" // flatbuffers +#include "flatbuffers/flexbuffers.h" namespace tflite { namespace ops { diff --git a/tensorflow/contrib/lite/kernels/audio_spectrogram_test.cc b/tensorflow/contrib/lite/kernels/audio_spectrogram_test.cc index b1e5f4f0216..8d460fdfc61 100644 --- a/tensorflow/contrib/lite/kernels/audio_spectrogram_test.cc +++ b/tensorflow/contrib/lite/kernels/audio_spectrogram_test.cc @@ -18,7 +18,7 @@ limitations under the License. #include #include -#include "include/flatbuffers/flexbuffers.h" // flatbuffers +#include "flatbuffers/flexbuffers.h" #include "tensorflow/contrib/lite/interpreter.h" #include "tensorflow/contrib/lite/kernels/register.h" #include "tensorflow/contrib/lite/kernels/test_util.h" diff --git a/tensorflow/contrib/lite/kernels/detection_postprocess.cc b/tensorflow/contrib/lite/kernels/detection_postprocess.cc index 211d43a47a0..d7bde0ff79b 100644 --- a/tensorflow/contrib/lite/kernels/detection_postprocess.cc +++ b/tensorflow/contrib/lite/kernels/detection_postprocess.cc @@ -15,7 +15,7 @@ limitations under the License. #include #include #include -#include "include/flatbuffers/flexbuffers.h" // flatbuffers +#include "flatbuffers/flexbuffers.h" #include "tensorflow/contrib/lite/builtin_op_data.h" #include "tensorflow/contrib/lite/context.h" #include "tensorflow/contrib/lite/kernels/internal/optimized/optimized_ops.h" diff --git a/tensorflow/contrib/lite/kernels/detection_postprocess_test.cc b/tensorflow/contrib/lite/kernels/detection_postprocess_test.cc index fe90e5d8948..4e0f8484a32 100644 --- a/tensorflow/contrib/lite/kernels/detection_postprocess_test.cc +++ b/tensorflow/contrib/lite/kernels/detection_postprocess_test.cc @@ -17,7 +17,7 @@ limitations under the License. #include #include -#include "include/flatbuffers/flexbuffers.h" // flatbuffers +#include "flatbuffers/flexbuffers.h" #include "tensorflow/contrib/lite/interpreter.h" #include "tensorflow/contrib/lite/kernels/register.h" #include "tensorflow/contrib/lite/kernels/test_util.h" diff --git a/tensorflow/contrib/lite/kernels/mfcc.cc b/tensorflow/contrib/lite/kernels/mfcc.cc index dd388df6300..3f5bc4d68a5 100644 --- a/tensorflow/contrib/lite/kernels/mfcc.cc +++ b/tensorflow/contrib/lite/kernels/mfcc.cc @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ #include "tensorflow/contrib/lite/kernels/internal/mfcc.h" -#include "include/flatbuffers/flexbuffers.h" // flatbuffers +#include "flatbuffers/flexbuffers.h" #include "tensorflow/contrib/lite/builtin_op_data.h" #include "tensorflow/contrib/lite/context.h" #include "tensorflow/contrib/lite/kernels/internal/mfcc_dct.h" diff --git a/tensorflow/contrib/lite/kernels/mfcc_test.cc b/tensorflow/contrib/lite/kernels/mfcc_test.cc index 69aa19623b3..0291ca8c1c5 100644 --- a/tensorflow/contrib/lite/kernels/mfcc_test.cc +++ b/tensorflow/contrib/lite/kernels/mfcc_test.cc @@ -18,7 +18,7 @@ limitations under the License. #include #include -#include "include/flatbuffers/flexbuffers.h" // flatbuffers +#include "flatbuffers/flexbuffers.h" #include "tensorflow/contrib/lite/interpreter.h" #include "tensorflow/contrib/lite/kernels/register.h" #include "tensorflow/contrib/lite/kernels/test_util.h" diff --git a/tensorflow/contrib/lite/schema/BUILD b/tensorflow/contrib/lite/schema/BUILD index 28a7e500034..b616e449e6d 100644 --- a/tensorflow/contrib/lite/schema/BUILD +++ b/tensorflow/contrib/lite/schema/BUILD @@ -48,7 +48,7 @@ exports_files([ "schema_v3.fbs", ]) -load("@flatbuffers//:build_defs.bzl", "flatbuffer_cc_library") +load("//third_party/flatbuffers:build_defs.bzl", "flatbuffer_cc_library") # Generic schema for inference on device. flatbuffer_cc_library( diff --git a/tensorflow/contrib/lite/schema/flatbuffer_compatibility_test.cc b/tensorflow/contrib/lite/schema/flatbuffer_compatibility_test.cc index 4af69257095..cd46a06f7d1 100644 --- a/tensorflow/contrib/lite/schema/flatbuffer_compatibility_test.cc +++ b/tensorflow/contrib/lite/schema/flatbuffer_compatibility_test.cc @@ -15,7 +15,7 @@ limitations under the License. #include #include -#include "include/flatbuffers/flatc.h" // flatbuffers +#include "flatbuffers/flatc.h" #include "tensorflow/core/platform/platform.h" #ifdef PLATFORM_GOOGLE diff --git a/tensorflow/workspace.bzl b/tensorflow/workspace.bzl index b79370a6c6b..68c78c21cb0 100644 --- a/tensorflow/workspace.bzl +++ b/tensorflow/workspace.bzl @@ -19,10 +19,10 @@ load( "//tensorflow/tools/def_file_filter:def_file_filter_configure.bzl", "def_file_filter_configure", ) -load("//third_party/flatbuffers:workspace.bzl", flatbuffers = "repo") def initialize_third_party(): - flatbuffers() + # Fill in later + pass # Sanitize a dependency so that it works correctly from code that includes # TensorFlow as a submodule. @@ -740,6 +740,18 @@ def tf_workspace(path_prefix = "", tf_repo_name = ""): build_file = clean_dep("//third_party:arm_neon_2_x86_sse.BUILD"), ) + tf_http_archive( + name = "flatbuffers", + strip_prefix = "flatbuffers-1.9.0", + sha256 = "5ca5491e4260cacae30f1a5786d109230db3f3a6e5a0eb45d0d0608293d247e3", + urls = [ + "https://mirror.bazel.build/github.com/google/flatbuffers/archive/v1.9.0.tar.gz", + "https://github.com/google/flatbuffers/archive/v1.9.0.tar.gz", + ], + build_file = clean_dep("//third_party/flatbuffers:flatbuffers.BUILD"), + system_build_file = clean_dep("//third_party/systemlibs:flatbuffers.BUILD"), + ) + native.new_http_archive( name = "double_conversion", urls = [ diff --git a/third_party/flatbuffers/BUILD b/third_party/flatbuffers/BUILD index 82bab3ffd96..fbdf19f2054 100644 --- a/third_party/flatbuffers/BUILD +++ b/third_party/flatbuffers/BUILD @@ -1 +1,15 @@ -# This empty BUILD file is required to make Bazel treat this directory as a package. +package(default_visibility = ["//visibility:public"]) + +licenses(["notice"]) # Apache 2.0 + +filegroup( + name = "all_files", + srcs = glob( + ["**/*"], + exclude = [ + "**/METADATA", + "**/OWNERS", + ], + ), + visibility = ["//tensorflow:__subpackages__"], +) diff --git a/third_party/flatbuffers/build_defs.bzl b/third_party/flatbuffers/build_defs.bzl index ba763f3360f..ae8d7feebe7 100644 --- a/third_party/flatbuffers/build_defs.bzl +++ b/third_party/flatbuffers/build_defs.bzl @@ -8,50 +8,66 @@ DEFAULT_FLATC_ARGS = [ "--gen-object-api", ] -def flatbuffer_library_public( - name, - srcs, - outs, - language_flag, - out_prefix = "", - includes = [], - include_paths = [], - flatc_args = DEFAULT_FLATC_ARGS, - reflection_name = "", - reflection_visiblity = None, - output_to_bindir = False): - """Generates code files for reading/writing the given flatbuffers in the requested language using the public compiler. +def flatbuffer_library_public(name, + srcs, + outs, + language_flag, + out_prefix="", + includes=[], + include_paths=[], + flatc_args=DEFAULT_FLATC_ARGS, + reflection_name="", + reflection_visiblity=None, + output_to_bindir=False): + '''Generates code files for reading/writing the given flatbuffers in the requested language using the public compiler. - Outs: - filegroup(name): all generated source files. - Fileset([reflection_name]): (Optional) all generated reflection binaries. - - Args: - name: Rule name. - srcs: Source .fbs files. Sent in order to the compiler. - outs: Output files from flatc. - language_flag: Target language flag. One of [-c, -j, -js]. - out_prefix: Prepend this path to the front of all generated files except on - single source targets. Usually is a directory name. - includes: Optional, list of filegroups of schemas that the srcs depend on. - include_paths: Optional, list of paths the includes files can be found in. - flatc_args: Optional, list of additional arguments to pass to flatc. - reflection_name: Optional, if set this will generate the flatbuffer - reflection binaries for the schemas. - reflection_visiblity: The visibility of the generated reflection Fileset. - output_to_bindir: Passed to genrule for output to bin directory. - """ - include_paths_cmd = ["-I %s" % (s) for s in include_paths] - - # '$(@D)' when given a single source target will give the appropriate - # directory. Appending 'out_prefix' is only necessary when given a build - # target with multiple sources. - output_directory = ( - ("-o $(@D)/%s" % (out_prefix)) if len(srcs) > 1 else ("-o $(@D)") - ) - genrule_cmd = " ".join([ + Args: + name: Rule name. + srcs: Source .fbs files. Sent in order to the compiler. + outs: Output files from flatc. + language_flag: Target language flag. One of [-c, -j, -js]. + out_prefix: Prepend this path to the front of all generated files except on + single source targets. Usually is a directory name. + includes: Optional, list of filegroups of schemas that the srcs depend on. + include_paths: Optional, list of paths the includes files can be found in. + flatc_args: Optional, list of additional arguments to pass to flatc. + reflection_name: Optional, if set this will generate the flatbuffer + reflection binaries for the schemas. + reflection_visiblity: The visibility of the generated reflection Fileset. + output_to_bindir: Passed to genrule for output to bin directory. + Outs: + filegroup(name): all generated source files. + Fileset([reflection_name]): (Optional) all generated reflection binaries. + ''' + include_paths_cmd = ["-I %s" % (s) for s in include_paths] + # '$(@D)' when given a single source target will give the appropriate + # directory. Appending 'out_prefix' is only necessary when given a build + # target with multiple sources. + output_directory = ( + ("-o $(@D)/%s" % (out_prefix)) if len(srcs) > 1 else ("-o $(@D)")) + genrule_cmd = " ".join([ + "for f in $(SRCS); do", + "$(location %s)" % (flatc_path), + " ".join(flatc_args), + " ".join(include_paths_cmd), + language_flag, + output_directory, + "$$f;", + "done", + ]) + native.genrule( + name=name, + srcs=srcs, + outs=outs, + output_to_bindir=output_to_bindir, + tools=includes + [flatc_path,], + cmd=genrule_cmd, + message="Generating flatbuffer files for %s:" % (name),) + if reflection_name: + reflection_genrule_cmd = " ".join([ "for f in $(SRCS); do", "$(location %s)" % (flatc_path), + "-b --schema", " ".join(flatc_args), " ".join(include_paths_cmd), language_flag, @@ -59,157 +75,122 @@ def flatbuffer_library_public( "$$f;", "done", ]) - native.genrule( - name = name, - srcs = srcs, - outs = outs, - output_to_bindir = output_to_bindir, - tools = includes + [flatc_path], - cmd = genrule_cmd, - message = "Generating flatbuffer files for %s:" % (name), - ) - if reflection_name: - reflection_genrule_cmd = " ".join([ - "for f in $(SRCS); do", - "$(location %s)" % (flatc_path), - "-b --schema", - " ".join(flatc_args), - " ".join(include_paths_cmd), - language_flag, - output_directory, - "$$f;", - "done", - ]) - reflection_outs = [ - (out_prefix + "%s.bfbs") % (s.replace(".fbs", "").split("/")[-1]) - for s in srcs - ] - native.genrule( - name = "%s_srcs" % reflection_name, - srcs = srcs, - outs = reflection_outs, - output_to_bindir = output_to_bindir, - tools = includes + [flatc_path], - cmd = reflection_genrule_cmd, - message = "Generating flatbuffer reflection binary for %s:" % (name), - ) - native.Fileset( - name = reflection_name, - out = "%s_out" % reflection_name, - entries = [ - native.FilesetEntry(files = reflection_outs), - ], - visibility = reflection_visiblity, - ) - -def flatbuffer_cc_library( - name, - srcs, - srcs_filegroup_name = "", - out_prefix = "", - includes = [], - include_paths = [], - flatc_args = DEFAULT_FLATC_ARGS, - visibility = None, - srcs_filegroup_visibility = None, - gen_reflections = False): - '''A cc_library with the generated reader/writers for the given flatbuffer definitions. - - Outs: - filegroup([name]_srcs): all generated .h files. - filegroup(srcs_filegroup_name if specified, or [name]_includes if not): - Other flatbuffer_cc_library's can pass this in for their `includes` - parameter, if they depend on the schemas in this library. - Fileset([name]_reflection): (Optional) all generated reflection binaries. - cc_library([name]): library with sources and flatbuffers deps. - - Remarks: - ** Because the genrule used to call flatc does not have any trivial way of - computing the output list of files transitively generated by includes and - --gen-includes (the default) being defined for flatc, the --gen-includes - flag will not work as expected. The way around this is to add a dependency - to the flatbuffer_cc_library defined alongside the flatc included Fileset. - For example you might define: - - flatbuffer_cc_library( - name = "my_fbs", - srcs = [ "schemas/foo.fbs" ], - includes = [ "//third_party/bazz:bazz_fbs_includes" ], - ) - - In which foo.fbs includes a few files from the Fileset defined at - //third_party/bazz:bazz_fbs_includes. When compiling the library that - includes foo_generated.h, and therefore has my_fbs as a dependency, it - will fail to find any of the bazz *_generated.h files unless you also - add bazz's flatbuffer_cc_library to your own dependency list, e.g.: - - cc_library( - name = "my_lib", - deps = [ - ":my_fbs", - "//third_party/bazz:bazz_fbs" - ], - ) - - Happy dependent Flatbuffering! - - Args: - name: Rule name. - srcs: Source .fbs files. Sent in order to the compiler. - srcs_filegroup_name: Name of the output filegroup that holds srcs. Pass this - filegroup into the `includes` parameter of any other - flatbuffer_cc_library that depends on this one's schemas. - out_prefix: Prepend this path to the front of all generated files. Usually - is a directory name. - includes: Optional, list of filegroups of schemas that the srcs depend on. - ** SEE REMARKS BELOW ** - include_paths: Optional, list of paths the includes files can be found in. - flatc_args: Optional list of additional arguments to pass to flatc - (e.g. --gen-mutable). - visibility: The visibility of the generated cc_library. By default, use the - default visibility of the project. - srcs_filegroup_visibility: The visibility of the generated srcs filegroup. - By default, use the value of the visibility parameter above. - gen_reflections: Optional, if true this will generate the flatbuffer - reflection binaries for the schemas. - ''' - output_headers = [ - (out_prefix + "%s_generated.h") % (s.replace(".fbs", "").split("/")[-1]) - for s in srcs + reflection_outs = [ + (out_prefix + "%s.bfbs") % (s.replace(".fbs", "").split("/")[-1]) for s in srcs ] - reflection_name = "%s_reflection" % name if gen_reflections else "" - - flatbuffer_library_public( - name = "%s_srcs" % (name), - srcs = srcs, - outs = output_headers, - language_flag = "-c", - out_prefix = out_prefix, - includes = includes, - include_paths = include_paths, - flatc_args = flatc_args, - reflection_name = reflection_name, - reflection_visiblity = visibility, - ) - native.cc_library( - name = name, - hdrs = output_headers, - srcs = output_headers, - features = [ - "-parse_headers", + native.genrule( + name= "%s_srcs" % reflection_name, + srcs=srcs, + outs=reflection_outs, + output_to_bindir=output_to_bindir, + tools=includes + [flatc_path,], + cmd=reflection_genrule_cmd, + message="Generating flatbuffer reflection binary for %s:" % (name),) + native.Fileset( + name=reflection_name, + out="%s_out" % reflection_name, + entries=[ + native.FilesetEntry(files=reflection_outs), ], - deps = [ - "@flatbuffers//:runtime_cc", - ], - includes = ["."], - linkstatic = 1, - visibility = visibility, + visibility=reflection_visiblity ) - # A filegroup for the `srcs`. That is, all the schema files for this - # Flatbuffer set. - native.filegroup( - name = srcs_filegroup_name if srcs_filegroup_name else "%s_includes" % (name), - srcs = srcs, - visibility = srcs_filegroup_visibility if srcs_filegroup_visibility != None else visibility, - ) + +def flatbuffer_cc_library(name, srcs, srcs_filegroup_name="", + out_prefix="", includes=[], include_paths=[], + flatc_args=DEFAULT_FLATC_ARGS, + visibility=None, srcs_filegroup_visibility=None, + gen_reflections=False): + '''A cc_library with the generated reader/writers for the given flatbuffer definitions. + + Args: + name: Rule name. + srcs: Source .fbs files. Sent in order to the compiler. + srcs_filegroup_name: Name of the output filegroup that holds srcs. Pass this + filegroup into the `includes` parameter of any other + flatbuffer_cc_library that depends on this one's schemas. + out_prefix: Prepend this path to the front of all generated files. Usually + is a directory name. + includes: Optional, list of filegroups of schemas that the srcs depend on. + ** SEE REMARKS BELOW ** + include_paths: Optional, list of paths the includes files can be found in. + flatc_args: Optional list of additional arguments to pass to flatc + (e.g. --gen-mutable). + visibility: The visibility of the generated cc_library. By default, use the + default visibility of the project. + srcs_filegroup_visibility: The visibility of the generated srcs filegroup. + By default, use the value of the visibility parameter above. + gen_reflections: Optional, if true this will generate the flatbuffer + reflection binaries for the schemas. + Outs: + filegroup([name]_srcs): all generated .h files. + filegroup(srcs_filegroup_name if specified, or [name]_includes if not): + Other flatbuffer_cc_library's can pass this in for their `includes` + parameter, if they depend on the schemas in this library. + Fileset([name]_reflection): (Optional) all generated reflection binaries. + cc_library([name]): library with sources and flatbuffers deps. + + Remarks: + ** Because the genrule used to call flatc does not have any trivial way of + computing the output list of files transitively generated by includes and + --gen-includes (the default) being defined for flatc, the --gen-includes + flag will not work as expected. The way around this is to add a dependency + to the flatbuffer_cc_library defined alongside the flatc included Fileset. + For example you might define: + + flatbuffer_cc_library( + name = "my_fbs", + srcs = [ "schemas/foo.fbs" ], + includes = [ "//third_party/bazz:bazz_fbs_includes" ], + ) + + In which foo.fbs includes a few files from the Fileset defined at + //third_party/bazz:bazz_fbs_includes. When compiling the library that + includes foo_generated.h, and therefore has my_fbs as a dependency, it + will fail to find any of the bazz *_generated.h files unless you also + add bazz's flatbuffer_cc_library to your own dependency list, e.g.: + + cc_library( + name = "my_lib", + deps = [ + ":my_fbs", + "//third_party/bazz:bazz_fbs" + ], + ) + + Happy dependent Flatbuffering! + ''' + output_headers = [ + (out_prefix + "%s_generated.h") % (s.replace(".fbs", "").split("/")[-1]) for s in srcs + ] + reflection_name = "%s_reflection" % name if gen_reflections else "" + + flatbuffer_library_public(name="%s_srcs" % (name), + srcs=srcs, + outs=output_headers, + language_flag="-c", + out_prefix=out_prefix, + includes=includes, + include_paths=include_paths, + flatc_args=flatc_args, + reflection_name=reflection_name, + reflection_visiblity=visibility,) + native.cc_library(name=name, + hdrs=output_headers, + srcs=output_headers, + features=[ + "-parse_headers", + ], + deps=[ + "@flatbuffers//:runtime_cc", + ], + includes=["."], + linkstatic=1, + visibility=visibility) + + # A filegroup for the `srcs`. That is, all the schema files for this + # Flatbuffer set. + native.filegroup( + name = srcs_filegroup_name if srcs_filegroup_name else "%s_includes" % (name), + srcs = srcs, + visibility=srcs_filegroup_visibility if srcs_filegroup_visibility != None else visibility) diff --git a/third_party/flatbuffers/BUILD.bazel b/third_party/flatbuffers/flatbuffers.BUILD similarity index 97% rename from third_party/flatbuffers/BUILD.bazel rename to third_party/flatbuffers/flatbuffers.BUILD index 9d233a30d6c..4a3701e8936 100644 --- a/third_party/flatbuffers/BUILD.bazel +++ b/third_party/flatbuffers/flatbuffers.BUILD @@ -19,10 +19,7 @@ config_setting( FLATBUFFERS_COPTS = select({ ":windows": [], - "//conditions:default": [ - "-Wno-implicit-fallthrough", - "-fexceptions", - ], + "//conditions:default": ["-Wno-implicit-fallthrough", "-fexceptions"], }) # Public flatc library to compile flatbuffer files at runtime. diff --git a/third_party/flatbuffers/workspace.bzl b/third_party/flatbuffers/workspace.bzl deleted file mode 100644 index 3aeef96a723..00000000000 --- a/third_party/flatbuffers/workspace.bzl +++ /dev/null @@ -1,19 +0,0 @@ -"""Loads the Flatbuffers library, used by TF Lite.""" - -load("//third_party:repo.bzl", "third_party_http_archive") - -def repo(): - third_party_http_archive( - name = "flatbuffers", - strip_prefix = "flatbuffers-1.9.0", - sha256 = "5ca5491e4260cacae30f1a5786d109230db3f3a6e5a0eb45d0d0608293d247e3", - urls = [ - "https://mirror.bazel.build/github.com/google/flatbuffers/archive/v1.9.0.tar.gz", - "https://github.com/google/flatbuffers/archive/v1.9.0.tar.gz", - ], - build_file = "//third_party/flatbuffers:BUILD.bazel", - system_build_file = "//third_party/flatbuffers:BUILD.system", - link_files = { - "//third_party/flatbuffers:build_defs.bzl": "build_defs.bzl", - }, - ) diff --git a/third_party/flatbuffers/BUILD.system b/third_party/systemlibs/flatbuffers.BUILD similarity index 100% rename from third_party/flatbuffers/BUILD.system rename to third_party/systemlibs/flatbuffers.BUILD