Skip to content

Commit

Permalink
Move flatbuffers gn files to //build_extra/flatbuffers
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Jul 7, 2018
1 parent d4c5ff8 commit 740b47d
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 347 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ node_modules
/third_party/cpplint/
/third_party/zlib/
/third_party/rust_crates/libc/
/third_party/flatbuffers/src/
/third_party/flatbuffers/

# gclient files
/third_party/.gclient_entries
2 changes: 1 addition & 1 deletion BUILD.gn
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import("//third_party/v8/gni/v8.gni")
import("//third_party/v8/snapshot_toolchain.gni")
import("//third_party/flatbuffers/flatbuffer.gni")
import("//build_extra/flatbuffers/flatbuffer.gni")
import("//build_extra/deno.gni")
import("//build_extra/rust/rust.gni")

Expand Down
122 changes: 122 additions & 0 deletions build_extra/flatbuffers/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
# 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",
]
}
}

# 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_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_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" ]
# }
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@

import("//build/compiled_action.gni")

declare_args() {
# Location of flatbuffers source code.
flatbuffers_source_location = "//third_party/flatbuffers/"

# Absolute location flatbuffers BUILD.gn file.
flatbuffers_build_location = "//build_extra/flatbuffers/"
}

# Compile a flatbuffer for C++.
#
# flatc_out_dir (optional)
Expand Down Expand Up @@ -64,7 +72,7 @@ template("flatbuffer") {
compiled_action_foreach(action_name) {
visibility = [ ":$source_set_name" ]

tool = "//third_party/flatbuffers:flatc"
tool = "$flatbuffers_build_location:flatc"

sources = invoker.sources
deps = []
Expand Down Expand Up @@ -122,12 +130,12 @@ template("flatbuffer") {
testonly = invoker.testonly
}

public_configs = [ "//third_party/flatbuffers:flatbuffers_config" ]
public_configs = [ "$flatbuffers_build_location:flatbuffers_config" ]

public_deps = [
# The generated headers reference headers within FlatBuffers, so
# dependencies must be able to find those headers too.
"//third_party/flatbuffers",
flatbuffers_build_location,
]
deps = [
":$action_name",
Expand Down Expand Up @@ -180,12 +188,12 @@ template("ts_flatbuffer") {
copy_name = target_name + "_copy"

copy(copy_name) {
sources = [ "//third_party/flatbuffers/src/js/flatbuffers.js" ]
sources = [ "$flatbuffers_source_location/js/flatbuffers.js" ]
outputs = [ "$target_gen_dir/flatbuffers.js" ]
}

compiled_action_foreach(target_name) {
tool = "//third_party/flatbuffers:flatc"
tool = "$flatbuffers_build_location:flatc"

sources = invoker.sources
deps = [ ":" + copy_name ]
Expand Down
2 changes: 1 addition & 1 deletion gclient_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
'url':
'https://github.com/rw/flatbuffers.git@2018-02--rust',
'name':
'flatbuffers/src'
'flatbuffers'
}, {
'url':
'https://github.com/rust-lang/libc.git@8a85d662b90c14d458bc4ae9521a05564e20d7ae',
Expand Down
120 changes: 0 additions & 120 deletions third_party/flatbuffers/BUILD.gn

This file was deleted.

Loading

0 comments on commit 740b47d

Please sign in to comment.