summaryrefslogtreecommitdiff
path: root/build_extra/flatbuffers/BUILD.gn
blob: b56731935e28dfcf8cf963446aee1415d4851079 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# Copyright 2016 The Chromium 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("flatbuffer.gni")

fb_src = flatbuffers_source_location

config("flatbuffers_config") {
  include_dirs = [ "$fb_src/include" ]

  if (is_clang) {
    cflags = [
      "-Wno-exit-time-destructors",
      "-Wno-header-hygiene",

      # TODO: rust branch of flatbuffers has this warning.
      # This should be removed when the branch fixed.
      "-Wno-return-type",

      "-fcolor-diagnostics",
      "-fansi-escape-codes",
    ]
  }
}

# The part of FlatBuffers that Chrome is interested in.
source_set("flatbuffers") {
  sources = [
    "$fb_src/include/flatbuffers/flatbuffers.h",
  ]

  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 = [ "$fb_src/grpc" ]
  sources = [
    "$fb_src/grpc/src/compiler/config.h",
    "$fb_src/grpc/src/compiler/config.h",
    "$fb_src/grpc/src/compiler/cpp_generator.cc",
    "$fb_src/grpc/src/compiler/cpp_generator.h",
    "$fb_src/grpc/src/compiler/go_generator.cc",
    "$fb_src/grpc/src/compiler/go_generator.h",
    "$fb_src/grpc/src/compiler/java_generator.cc",
    "$fb_src/grpc/src/compiler/java_generator.h",
    "$fb_src/grpc/src/compiler/schema_interface.h",
    "$fb_src/include/flatbuffers/code_generators.h",
    "$fb_src/include/flatbuffers/flatc.h",
    "$fb_src/include/flatbuffers/flexbuffers.h",
    "$fb_src/include/flatbuffers/grpc.h",
    "$fb_src/include/flatbuffers/hash.h",
    "$fb_src/include/flatbuffers/idl.h",
    "$fb_src/include/flatbuffers/reflection.h",
    "$fb_src/include/flatbuffers/reflection_generated.h",
    "$fb_src/include/flatbuffers/util.h",
    "$fb_src/src/code_generators.cpp",
    "$fb_src/src/flatc.cpp",
    "$fb_src/src/idl_gen_cpp.cpp",
    "$fb_src/src/idl_gen_dart.cpp",
    "$fb_src/src/idl_gen_fbs.cpp",
    "$fb_src/src/idl_gen_general.cpp",
    "$fb_src/src/idl_gen_go.cpp",
    "$fb_src/src/idl_gen_grpc.cpp",
    "$fb_src/src/idl_gen_js.cpp",
    "$fb_src/src/idl_gen_json_schema.cpp",
    "$fb_src/src/idl_gen_lobster.cpp",
    "$fb_src/src/idl_gen_lua.cpp",
    "$fb_src/src/idl_gen_php.cpp",
    "$fb_src/src/idl_gen_python.cpp",
    "$fb_src/src/idl_gen_rust.cpp",
    "$fb_src/src/idl_gen_text.cpp",
    "$fb_src/src/idl_parser.cpp",
    "$fb_src/src/reflection.cpp",
    "$fb_src/src/util.cpp",
  ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
  visibility = [ ":*" ]
  deps = [
    ":flatbuffers",
  ]
}

executable("flatc") {
  sources = [
    "$fb_src/src/flatc_main.cpp",
  ]
  deps = [
    ":compiler_files",
    ":flatbuffers",
  ]
}

# The following is just for testing.

flatbuffer("flatbuffers_samplebuffer") {
  testonly = true
  sources = [
    "$fb_src/tests/include_test/include_test1.fbs",
    "$fb_src/tests/include_test/sub/include_test2.fbs",
    "$fb_src/tests/monster_test.fbs",
    "$fb_src/tests/namespace_test/namespace_test1.fbs",
    "$fb_src/tests/namespace_test/namespace_test2.fbs",
  ]
  flatc_include_dirs = [ "$fb_src/tests/include_test" ]
}
# test("flatbuffers_unittest") {
#   sources = [
#     "src/tests/test.cpp",
#   ]
#   deps = [
#     ":compiler_files",
#     ":flatbuffers",
#     ":flatbuffers_samplebuffer",
#   ]
#   data = [
#     "src/tests/",
#   ]
#
#   if (is_win) {
#     # Suppress "object allocated on the heap may not be aligned 16".
#     cflags = [ "/wd4316" ]
#   }
#   defines = [ "FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE" ]
# }