Commit 488ae524 authored by pkalinnikov's avatar pkalinnikov Committed by Commit Bot

Reland: Update FlatBuffers to include multiple improvements.

This CL updates FlatBuffers to the latest version 1.6.x. This is necessary to
include the following changes to the library:
 - d7ac378: Offset<T>::IsNull method.
 - 93c0960: --keep-prefix compiler option.
 - c559eb4: Generate files for empty schemas.
 - aaf5598: Fix path comparison on Windows.
 - fb87c0d: Improve allocator handling (fixes test).
 - 22743ca: Fix --keep-prefix bugs.
 - 642254b: Fix one more --keep-prefix issue.
 - dd05f32: Add tests for nested FlatBuffers.
 - 01c50d5: Get rid of move semantics in VectorIterator.

This is a reland of https://codereview.chromium.org/2883063002/ with a
compile flag added to Windows build suppressing the alignment warning.

BUG=611351,713774
TBR=palmer@chromium.org

Review-Url: https://codereview.chromium.org/2923203002
Cr-Commit-Position: refs/heads/master@{#477947}
parent e65976a4
...@@ -226,7 +226,7 @@ deps = { ...@@ -226,7 +226,7 @@ deps = {
Var('chromium_git') + '/chromium/deps/flac.git' + '@' + '7d0f5b3a173ffe98db08057d1f52b7787569e0a6', Var('chromium_git') + '/chromium/deps/flac.git' + '@' + '7d0f5b3a173ffe98db08057d1f52b7787569e0a6',
'src/third_party/flatbuffers/src': 'src/third_party/flatbuffers/src':
Var('chromium_git') + '/external/github.com/google/flatbuffers.git' + '@' + 'e92ae5199d52fd59540a800bec7eef46cd778257', Var('chromium_git') + '/external/github.com/google/flatbuffers.git' + '@' + '01c50d57a67a52ee3cddd81b54d4647e9123a290',
'src/third_party/pyftpdlib/src': 'src/third_party/pyftpdlib/src':
Var('chromium_git') + '/external/pyftpdlib.git' + '@' + '2be6d65e31c7ee6320d059f581f05ae8d89d7e45', Var('chromium_git') + '/external/pyftpdlib.git' + '@' + '2be6d65e31c7ee6320d059f581f05ae8d89d7e45',
......
...@@ -9,26 +9,45 @@ config("flatbuffers_config") { ...@@ -9,26 +9,45 @@ config("flatbuffers_config") {
include_dirs = [ "src/include" ] include_dirs = [ "src/include" ]
} }
# The part of FlatBuffers that Chrome is interested in.
source_set("flatbuffers") { source_set("flatbuffers") {
sources = [ sources = [
"src/include/flatbuffers/flatbuffers.h", "src/include/flatbuffers/flatbuffers.h",
"src/include/flatbuffers/hash.h",
] ]
configs -= [ "//build/config/compiler:chromium_code" ] configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code" ]
public_configs = [ ":flatbuffers_config" ] public_configs = [ ":flatbuffers_config" ]
} }
# The complete FlatBuffers library, as required to build the flatc compiler and
# some of the tests.
source_set("compiler_files") { source_set("compiler_files") {
include_dirs = [ "src/grpc" ]
sources = [ sources = [
"src/grpc/src/compiler/config.h",
"src/grpc/src/compiler/cpp_generator.cc",
"src/grpc/src/compiler/cpp_generator.h",
"src/grpc/src/compiler/go_generator.cc",
"src/grpc/src/compiler/go_generator.h",
"src/grpc/src/compiler/schema_interface.h",
"src/include/flatbuffers/code_generators.h", "src/include/flatbuffers/code_generators.h",
"src/include/flatbuffers/flatc.h",
"src/include/flatbuffers/flexbuffers.h",
"src/include/flatbuffers/grpc.h",
"src/include/flatbuffers/hash.h",
"src/include/flatbuffers/idl.h", "src/include/flatbuffers/idl.h",
"src/include/flatbuffers/reflection.h",
"src/include/flatbuffers/reflection_generated.h",
"src/include/flatbuffers/util.h", "src/include/flatbuffers/util.h",
"src/src/code_generators.cpp",
"src/src/flatc.cpp",
"src/src/idl_gen_cpp.cpp", "src/src/idl_gen_cpp.cpp",
"src/src/idl_gen_fbs.cpp", "src/src/idl_gen_fbs.cpp",
"src/src/idl_gen_general.cpp", "src/src/idl_gen_general.cpp",
"src/src/idl_gen_go.cpp", "src/src/idl_gen_go.cpp",
"src/src/idl_gen_grpc.cpp",
"src/src/idl_gen_js.cpp", "src/src/idl_gen_js.cpp",
"src/src/idl_gen_php.cpp", "src/src/idl_gen_php.cpp",
"src/src/idl_gen_python.cpp", "src/src/idl_gen_python.cpp",
...@@ -45,7 +64,7 @@ source_set("compiler_files") { ...@@ -45,7 +64,7 @@ source_set("compiler_files") {
executable("flatc") { executable("flatc") {
sources = [ sources = [
"src/src/flatc.cpp", "src/src/flatc_main.cpp",
] ]
deps = [ deps = [
":compiler_files", ":compiler_files",
...@@ -60,25 +79,18 @@ flatbuffer("flatbuffers_samplebuffer") { ...@@ -60,25 +79,18 @@ flatbuffer("flatbuffers_samplebuffer") {
testonly = true testonly = true
sources = [ sources = [
# Disabled as workaround for crbug.com/611351 # Disabled as workaround for crbug.com/611351
# "src/tests/include_test1.fbs", # "src/tests/include_test/include_test1.fbs",
# "src/tests/include_test2.fbs", # "src/tests/include_test/sub/include_test2.fbs",
"src/tests/monster_test.fbs", "src/tests/monster_test.fbs",
"src/tests/namespace_test/namespace_test1.fbs", "src/tests/namespace_test/namespace_test1.fbs",
"src/tests/namespace_test/namespace_test2.fbs", "src/tests/namespace_test/namespace_test2.fbs",
] ]
flatc_include_dirs = [ "src/tests/include_test" ]
} }
test("flatbuffers_unittest") { test("flatbuffers_unittest") {
sources = [ sources = [
# The following files are not included in :flatbuffers
# but are listed here because test.cpp tests more than what will
# get included into Chrome (reflection and generation).
"src/include/reflection.h",
"src/include/reflection_generated.h",
# This is the actual test.
"src/tests/test.cpp", "src/tests/test.cpp",
"src/tests/test.h",
] ]
deps = [ deps = [
":compiler_files", ":compiler_files",
...@@ -88,4 +100,10 @@ test("flatbuffers_unittest") { ...@@ -88,4 +100,10 @@ test("flatbuffers_unittest") {
data = [ data = [
"src/tests/", "src/tests/",
] ]
if (is_win) {
# Suppress "object allocated on the heap may not be aligned 16".
cflags = [ "/wd4316" ]
}
defines = [ "FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE" ]
} }
Name: FlatBuffers Name: FlatBuffers
Short Name: flatbuffers Short Name: flatbuffers
URL: https://github.com/google/flatbuffers URL: https://github.com/google/flatbuffers
Version: e92ae5199d52fd59540a800bec7eef46cd778257 Version: 01c50d57a67a52ee3cddd81b54d4647e9123a290
Date: 2016-06-03 Date: 2017-06-05
License: Apache 2.0 License: Apache 2.0
License File: LICENSE License File: LICENSE
Security Critical: yes Security Critical: yes
......
...@@ -8,12 +8,23 @@ ...@@ -8,12 +8,23 @@
# Specifies the path suffix that output files are generated under. This # Specifies the path suffix that output files are generated under. This
# path will be appended to root_gen_dir. # path will be appended to root_gen_dir.
# #
# Targets that depend on the proto target will be able to include the # Targets that depend on the flatbuffer target will be able to include
# resulting flatbuffers header with an include like: # the resulting FlatBuffers header with an include like:
# #include "dir/for/my_flatbuffer/buffer_generated.h" # #include "dir/for/my_flatbuffer/buffer_generated.h"
# If undefined, this defaults to matchign the input directory for each # If undefined, this defaults to matchign the input directory for each
# .fbs file (you should almost always use the default mode). # .fbs file (you should almost always use the default mode).
# #
# flatc_include_dirs (optional)
# Specifies the directories which FlatBuffers compiler uses to find
# included .fbs files in.
#
# The directories will be tried in the order given, and if all fail (or,
# as by default, none are specified) it will try to load relative to the
# directory of the schema file being parsed.
#
# TODO(pkalinnikov): Add repository root to this list, to allow including
# by absolute path.
#
# deps (optional) # deps (optional)
# Additional dependencies. # Additional dependencies.
# #
...@@ -68,8 +79,18 @@ template("flatbuffer") { ...@@ -68,8 +79,18 @@ template("flatbuffer") {
"$out_dir/{{source_name_part}}_generated.h", "$out_dir/{{source_name_part}}_generated.h",
] ]
args = [ args = [ "-c" ]
"-c",
if (defined(invoker.flatc_include_dirs)) {
foreach(include_dir, invoker.flatc_include_dirs) {
args += [
"-I",
rebase_path(include_dir, "$root_build_dir"),
]
}
}
args += [
"-o", "-o",
"$out_dir", "$out_dir",
"{{source}}", "{{source}}",
...@@ -101,7 +122,7 @@ template("flatbuffer") { ...@@ -101,7 +122,7 @@ template("flatbuffer") {
public_configs = [ "//third_party/flatbuffers:flatbuffers_config" ] public_configs = [ "//third_party/flatbuffers:flatbuffers_config" ]
public_deps = [ public_deps = [
# The generated headers reference headers within flatbuffers, so # The generated headers reference headers within FlatBuffers, so
# dependencies must be able to find those headers too. # dependencies must be able to find those headers too.
"//third_party/flatbuffers", "//third_party/flatbuffers",
] ]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment