Adding fuchsia build files.
Change-Id: I77a9ca293e0cafd8949b33730e27fcb7c8a215e7
diff --git a/BUILD.gn b/BUILD.gn
new file mode 100644
index 0000000..081fbd2
--- /dev/null
+++ b/BUILD.gn
@@ -0,0 +1,67 @@
+# Copyright 2017 The Fuchsia Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//third_party/flatbuffers/flatbuffer.gni")
+
+config("flatbuffers_fuchsia_warnings") {
+ cflags = []
+}
+
+config("flatbuffers_config") {
+ include_dirs = [ "include" ]
+}
+
+source_set("flatbuffers") {
+ sources = [
+ "include/flatbuffers/flatbuffers.h",
+ "include/flatbuffers/hash.h",
+ ]
+
+ configs += [ ":flatbuffers_fuchsia_warnings" ]
+ public_configs = [ ":flatbuffers_config" ]
+}
+
+source_set("compiler_files") {
+ sources = [
+ "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/schema_interface.h",
+ "include/flatbuffers/code_generators.h",
+ "include/flatbuffers/idl.h",
+ "include/flatbuffers/util.h",
+ "src/idl_gen_cpp.cpp",
+ "src/idl_gen_fbs.cpp",
+ "src/idl_gen_general.cpp",
+ "src/idl_gen_go.cpp",
+ "src/idl_gen_grpc.cpp",
+ "src/idl_gen_js.cpp",
+ "src/idl_gen_php.cpp",
+ "src/idl_gen_python.cpp",
+ "src/idl_gen_text.cpp",
+ "src/idl_parser.cpp",
+ "src/reflection.cpp",
+ "src/util.cpp",
+ ]
+ include_dirs = [ "grpc" ]
+ visibility = [ ":*" ]
+ deps = [
+ ":flatbuffers",
+ ]
+}
+
+executable("flatc") {
+ sources = [
+ "src/flatc.cpp",
+ ]
+ deps = [
+ ":compiler_files",
+ ":flatbuffers",
+ ]
+
+ if (is_linux) {
+ libs = [ "pthread" ]
+ }
+}
diff --git a/flatbuffer.gni b/flatbuffer.gni
new file mode 100644
index 0000000..ebd2017
--- /dev/null
+++ b/flatbuffer.gni
@@ -0,0 +1,121 @@
+# Copyright 2017 The Fuchsia Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Compile a flatbuffer.
+#
+# sources
+# Specifies the sources to compile.
+#
+# flatc_out_dir (optional)
+# Specifies the path suffix that output files are generated under. This
+# path will be appended to root_gen_dir.
+#
+# Targets that depend on the proto target will be able to include the
+# resulting flatbuffers header with an include like:
+# #include "dir/for/my_flatbuffer/buffer_generated.h"
+# If undefined, this defaults to matching the input directory for each
+# .fbs file (you should almost always use the default mode).
+#
+# deps (optional)
+# Additional dependencies.
+#
+# Parameters for compiling the generated code:
+#
+# defines (optional)
+# Defines to supply to the source set that compiles the generated source
+# code.
+#
+# extra_configs (optional)
+# A list of config labels that will be appended to the configs applying
+# to the source set.
+#
+# testonly (optional)
+# Boolean to indicate whether the generated source sets should be labeled
+# as testonly.
+#
+# Example:
+# flatbuffer("mylib") {
+# sources = [
+# "foo.fbs",
+# ]
+# }
+
+import("//build/compiled_action.gni")
+
+template("flatbuffer") {
+ assert(defined(invoker.sources), "Need sources for flatbuffers_library")
+
+ # Don't apply OS-specific sources filtering to the assignments later on.
+ # Platform files should have gotten filtered out in the sources assignment
+ # when this template was invoked. If they weren't, it was on purpose and
+ # this template shouldn't re-apply the filter.
+ set_sources_assignment_filter([])
+
+ action_name = "${target_name}_gen"
+ source_set_name = target_name
+ compiled_action_foreach(action_name) {
+ visibility = [ ":$source_set_name" ]
+
+ tool = "//third_party/flatbuffers:flatc"
+
+ sources = invoker.sources
+
+ if (defined(invoker.flatc_out_dir)) {
+ out_dir = "$root_gen_dir/" + invoker.flatc_out_dir
+ } else {
+ out_dir = "{{source_gen_dir}}"
+ }
+
+ outputs = [
+ "$out_dir/{{source_name_part}}_generated.h",
+ ]
+
+ args = [
+ "-c",
+ "-o",
+ "$out_dir",
+ "{{source}}",
+ ]
+
+ # The deps may have steps that have to run before running flatc.
+ if (defined(invoker.deps)) {
+ deps += invoker.deps
+ }
+ }
+
+ source_set(target_name) {
+ forward_variables_from(invoker,
+ [
+ "visibility",
+ "defines",
+ ])
+
+ sources = get_target_outputs(":$action_name")
+
+ if (defined(invoker.extra_configs)) {
+ configs += invoker.extra_configs
+ }
+
+ if (defined(invoker.testonly)) {
+ testonly = invoker.testonly
+ }
+
+ public_configs = [ "//third_party/flatbuffers:flatbuffers_config" ]
+
+ public_deps = [
+ # The generated headers reference headers within flatbuffers, so
+ # dependencies must be able to find those headers too.
+ "//third_party/flatbuffers",
+ ]
+ deps = [
+ ":$action_name",
+ ]
+
+ # This will link any libraries in the deps (the use of invoker.deps in the
+ # action won't link it).
+ if (defined(invoker.deps)) {
+ deps += invoker.deps
+ }
+ }
+}