# Copyright 2016 The Chromium Authors # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. import("//testing/test.gni") import("//third_party/flatbuffers/flatbuffer.gni") config("flatbuffers_config") { include_dirs = [ "src/include" ] # Required to prevent static initialization of locale # in util.cpp defines = [ "FLATBUFFERS_LOCALE_INDEPENDENT=0" ] } # The part of FlatBuffers that Chrome is interested in. source_set("flatbuffers") { public = [ "src/include/flatbuffers/base.h", "src/include/flatbuffers/flatbuffers.h", "src/include/flatbuffers/stl_emulation.h", # Required for tflite. "src/include/flatbuffers/flexbuffers.h", "src/include/flatbuffers/util.h", ] if (is_win) { data_deps = [ "//build/win:runtime_libs" ] } configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code" ] public_configs = [ ":flatbuffers_config" ] } # The complete FlatBuffers library, as required to build the flatc compiler and # some of the tests. source_set("compiler_files") { include_dirs = [ "src/grpc" ] sources = [ "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/java_generator.cc", "src/grpc/src/compiler/java_generator.h", "src/grpc/src/compiler/python_generator.cc", "src/grpc/src/compiler/python_generator.h", "src/grpc/src/compiler/schema_interface.h", "src/grpc/src/compiler/swift_generator.cc", "src/grpc/src/compiler/swift_generator.h", "src/grpc/src/compiler/ts_generator.cc", "src/grpc/src/compiler/ts_generator.h", "src/include/flatbuffers/code_generators.h", "src/include/flatbuffers/flatc.h", "src/include/flatbuffers/grpc.h", "src/include/flatbuffers/hash.h", "src/include/flatbuffers/idl.h", "src/include/flatbuffers/minireflect.h", "src/include/flatbuffers/reflection.h", "src/include/flatbuffers/reflection_generated.h", "src/include/flatbuffers/registry.h", "src/src/annotated_binary_text_gen.cpp", "src/src/annotated_binary_text_gen.h", "src/src/bfbs_gen.h", "src/src/bfbs_gen_lua.cpp", "src/src/bfbs_gen_lua.h", "src/src/bfbs_gen_nim.cpp", "src/src/bfbs_gen_nim.h", "src/src/bfbs_namer.h", "src/src/binary_annotator.cpp", "src/src/binary_annotator.h", "src/src/code_generators.cpp", "src/src/flatc.cpp", "src/src/idl_gen_binary.cpp", "src/src/idl_gen_binary.h", "src/src/idl_gen_cpp.cpp", "src/src/idl_gen_cpp.h", "src/src/idl_gen_csharp.cpp", "src/src/idl_gen_csharp.h", "src/src/idl_gen_dart.cpp", "src/src/idl_gen_dart.h", "src/src/idl_gen_fbs.cpp", "src/src/idl_gen_go.cpp", "src/src/idl_gen_go.h", "src/src/idl_gen_grpc.cpp", "src/src/idl_gen_java.cpp", "src/src/idl_gen_java.h", "src/src/idl_gen_json_schema.cpp", "src/src/idl_gen_json_schema.h", "src/src/idl_gen_kotlin.cpp", "src/src/idl_gen_kotlin.h", "src/src/idl_gen_lobster.cpp", "src/src/idl_gen_lobster.h", "src/src/idl_gen_lua.cpp", "src/src/idl_gen_lua.h", "src/src/idl_gen_php.cpp", "src/src/idl_gen_php.h", "src/src/idl_gen_python.cpp", "src/src/idl_gen_python.h", "src/src/idl_gen_rust.cpp", "src/src/idl_gen_rust.h", "src/src/idl_gen_swift.cpp", "src/src/idl_gen_swift.h", "src/src/idl_gen_text.cpp", "src/src/idl_gen_text.h", "src/src/idl_gen_ts.cpp", "src/src/idl_gen_ts.h", "src/src/idl_namer.h", "src/src/idl_parser.cpp", "src/src/namer.h", "src/src/reflection.cpp", "src/src/util.cpp", ] configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code" ] visibility = [ ":*" ] deps = [ ":flatbuffers" ] } executable("flatc") { sources = [ "src/src/flatc_main.cpp" ] deps = [ ":compiler_files", ":flatbuffers", ] } # The following is just for testing. flatbuffer("flatbuffers_samplebuffer") { testonly = true sources = [ "src/tests/alignment_test.fbs", "src/tests/arrays_test.fbs", "src/tests/include_test/include_test1.fbs", "src/tests/include_test/sub/include_test2.fbs", "src/tests/monster_extra.fbs", "src/tests/monster_test.fbs", "src/tests/namespace_test/namespace_test1.fbs", "src/tests/namespace_test/namespace_test2.fbs", "src/tests/native_inline_table_test.fbs", "src/tests/native_type_test.fbs", "src/tests/optional_scalars.fbs", ] flatc_include_dirs = [ "src/tests/include_test" ] } # This combines sources, "flatbuffers" and "flatbuffers_test", specified in the # public github repo required to build the unittests. This must be separate # from ":compiler_files". source_set("flatbuffers_test_files") { include_dirs = [ "src/grpc" ] sources = [ "src/include/flatbuffers/base.h", "src/include/flatbuffers/code_generators.h", "src/include/flatbuffers/flatbuffers.h", "src/include/flatbuffers/flexbuffers.h", "src/include/flatbuffers/grpc.h", "src/include/flatbuffers/hash.h", "src/include/flatbuffers/idl.h", "src/include/flatbuffers/minireflect.h", "src/include/flatbuffers/reflection.h", "src/include/flatbuffers/reflection_generated.h", "src/include/flatbuffers/registry.h", "src/include/flatbuffers/stl_emulation.h", "src/include/flatbuffers/util.h", "src/src/code_generators.cpp", "src/src/idl_gen_fbs.cpp", "src/src/idl_gen_text.cpp", "src/src/idl_gen_text.h", "src/src/idl_parser.cpp", "src/src/reflection.cpp", "src/src/util.cpp", ] configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code" ] deps = [ ":flatbuffers" ] } test("flatbuffers_unittests") { sources = [ "src/tests/alignment_test.cpp", "src/tests/alignment_test.h", "src/tests/evolution_test.cpp", "src/tests/evolution_test.h", "src/tests/flexbuffers_test.cpp", "src/tests/flexbuffers_test.h", "src/tests/fuzz_test.cpp", "src/tests/fuzz_test.h", "src/tests/is_quiet_nan.h", "src/tests/json_test.cpp", "src/tests/json_test.h", "src/tests/key_field_test.cpp", "src/tests/key_field_test.h", "src/tests/monster_test.cpp", "src/tests/monster_test.h", "src/tests/native_type_test_impl.cpp", "src/tests/native_type_test_impl.h", "src/tests/optional_scalars_test.cpp", "src/tests/optional_scalars_test.h", "src/tests/parser_test.cpp", "src/tests/parser_test.h", "src/tests/proto_test.cpp", "src/tests/proto_test.h", "src/tests/reflection_test.cpp", "src/tests/reflection_test.h", "src/tests/test.cpp", "src/tests/test_assert.cpp", "src/tests/test_assert.h", "src/tests/test_builder.cpp", "src/tests/test_builder.h", "src/tests/util_test.cpp", "src/tests/util_test.h", ] deps = [ ":flatbuffers", ":flatbuffers_samplebuffer", ":flatbuffers_test_files", ] data = [ "src/tests/", "//testing/scripts/run_flatbuffers_unittests.py", ] data_deps = [ "//testing:test_scripts_shared" ] defines = [ "FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE", # Careful, this test suite needs to be run in the actual out/ # directory. "FLATBUFFERS_TEST_PATH_PREFIX=" + rebase_path("//third_party/flatbuffers/src/", root_build_dir), ] configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code" ] libs = [ "log" ] } if (is_android) { import("//build/config/android/rules.gni") android_library("flatbuffers_java") { chromium_code = false sources = [ "src/java/src/main/java/com/google/flatbuffers/ArrayReadWriteBuf.java", "src/java/src/main/java/com/google/flatbuffers/BaseVector.java", "src/java/src/main/java/com/google/flatbuffers/BooleanVector.java", "src/java/src/main/java/com/google/flatbuffers/ByteBufferReadWriteBuf.java", "src/java/src/main/java/com/google/flatbuffers/ByteBufferUtil.java", "src/java/src/main/java/com/google/flatbuffers/ByteVector.java", "src/java/src/main/java/com/google/flatbuffers/Constants.java", "src/java/src/main/java/com/google/flatbuffers/DoubleVector.java", "src/java/src/main/java/com/google/flatbuffers/FlatBufferBuilder.java", "src/java/src/main/java/com/google/flatbuffers/FlexBuffers.java", "src/java/src/main/java/com/google/flatbuffers/FlexBuffersBuilder.java", "src/java/src/main/java/com/google/flatbuffers/FloatVector.java", "src/java/src/main/java/com/google/flatbuffers/IntVector.java", "src/java/src/main/java/com/google/flatbuffers/LongVector.java", "src/java/src/main/java/com/google/flatbuffers/ReadBuf.java", "src/java/src/main/java/com/google/flatbuffers/ReadWriteBuf.java", "src/java/src/main/java/com/google/flatbuffers/ShortVector.java", "src/java/src/main/java/com/google/flatbuffers/StringVector.java", "src/java/src/main/java/com/google/flatbuffers/Struct.java", "src/java/src/main/java/com/google/flatbuffers/Table.java", "src/java/src/main/java/com/google/flatbuffers/UnionVector.java", "src/java/src/main/java/com/google/flatbuffers/Utf8.java", "src/java/src/main/java/com/google/flatbuffers/Utf8Old.java", "src/java/src/main/java/com/google/flatbuffers/Utf8Safe.java", ] } }