mirror of
https://github.com/denoland/deno.git
synced 2024-10-29 08:58:01 -04:00
Merge flatbuffer.gni and ts_flatbuffer.gni
This commit is contained in:
parent
bcdd917d79
commit
d4c5ff841e
3 changed files with 81 additions and 89 deletions
1
BUILD.gn
1
BUILD.gn
|
@ -1,7 +1,6 @@
|
|||
import("//third_party/v8/gni/v8.gni")
|
||||
import("//third_party/v8/snapshot_toolchain.gni")
|
||||
import("//third_party/flatbuffers/flatbuffer.gni")
|
||||
import("//third_party/flatbuffers/ts_flatbuffer.gni")
|
||||
import("//build_extra/deno.gni")
|
||||
import("//build_extra/rust/rust.gni")
|
||||
|
||||
|
|
85
third_party/flatbuffers/flatbuffer.gni
vendored
85
third_party/flatbuffers/flatbuffer.gni
vendored
|
@ -2,7 +2,9 @@
|
|||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
# Compile a flatbuffer.
|
||||
import("//build/compiled_action.gni")
|
||||
|
||||
# Compile a flatbuffer for C++.
|
||||
#
|
||||
# flatc_out_dir (optional)
|
||||
# Specifies the path suffix that output files are generated under. This
|
||||
|
@ -48,9 +50,6 @@
|
|||
# "foo.fbs",
|
||||
# ]
|
||||
# }
|
||||
|
||||
import("//build/compiled_action.gni")
|
||||
|
||||
template("flatbuffer") {
|
||||
assert(defined(invoker.sources), "Need sources for flatbuffers_library")
|
||||
|
||||
|
@ -146,3 +145,81 @@ template("flatbuffer") {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Compile a flatbuffer to typescript.
|
||||
#
|
||||
# flatc_include_dirs (optional)
|
||||
# Specifies the directories which FlatBuffers compiler uses to find
|
||||
# included .fbs files in. Almost always should be empty.
|
||||
#
|
||||
# The list always has an implicit first item corresponding to the root of
|
||||
# the source tree. This enables including .fbs files by absolute path.
|
||||
#
|
||||
# The compiler will try the directories in the order given, and if all
|
||||
# fail it will try to load relative to the directory of the schema file
|
||||
# being parsed.
|
||||
#
|
||||
# deps (optional)
|
||||
# Additional dependencies.
|
||||
#
|
||||
# Example:
|
||||
# ts_flatbuffer("foo_ts") {
|
||||
# sources = [
|
||||
# "foo.fbs",
|
||||
# ]
|
||||
# }
|
||||
template("ts_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([])
|
||||
|
||||
copy_name = target_name + "_copy"
|
||||
|
||||
copy(copy_name) {
|
||||
sources = [ "//third_party/flatbuffers/src/js/flatbuffers.js" ]
|
||||
outputs = [ "$target_gen_dir/flatbuffers.js" ]
|
||||
}
|
||||
|
||||
compiled_action_foreach(target_name) {
|
||||
tool = "//third_party/flatbuffers:flatc"
|
||||
|
||||
sources = invoker.sources
|
||||
deps = [ ":" + copy_name ]
|
||||
|
||||
out_dir = target_gen_dir
|
||||
|
||||
outputs = [
|
||||
"$out_dir/{{source_name_part}}_generated.ts",
|
||||
]
|
||||
|
||||
args = [
|
||||
"--ts",
|
||||
"--no-fb-import",
|
||||
"--gen-mutable",
|
||||
"-o",
|
||||
rebase_path(out_dir, root_build_dir),
|
||||
"-I",
|
||||
rebase_path("//", root_build_dir),
|
||||
]
|
||||
|
||||
if (defined(invoker.flatc_include_dirs)) {
|
||||
foreach(include_dir, invoker.flatc_include_dirs) {
|
||||
args += [
|
||||
"-I",
|
||||
rebase_path(include_dir, root_build_dir),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
args += [ "{{source}}" ]
|
||||
|
||||
# The deps may have steps that have to run before running flatc.
|
||||
if (defined(invoker.deps)) {
|
||||
deps += invoker.deps
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
84
third_party/flatbuffers/ts_flatbuffer.gni
vendored
84
third_party/flatbuffers/ts_flatbuffer.gni
vendored
|
@ -1,84 +0,0 @@
|
|||
# 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.
|
||||
|
||||
# Compile a flatbuffer to typescript.
|
||||
#
|
||||
# flatc_include_dirs (optional)
|
||||
# Specifies the directories which FlatBuffers compiler uses to find
|
||||
# included .fbs files in. Almost always should be empty.
|
||||
#
|
||||
# The list always has an implicit first item corresponding to the root of
|
||||
# the source tree. This enables including .fbs files by absolute path.
|
||||
#
|
||||
# The compiler will try the directories in the order given, and if all
|
||||
# fail it will try to load relative to the directory of the schema file
|
||||
# being parsed.
|
||||
#
|
||||
# deps (optional)
|
||||
# Additional dependencies.
|
||||
#
|
||||
# Example:
|
||||
# ts_flatbuffer("foo_ts") {
|
||||
# sources = [
|
||||
# "foo.fbs",
|
||||
# ]
|
||||
# }
|
||||
|
||||
import("//build/compiled_action.gni")
|
||||
|
||||
template("ts_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([])
|
||||
|
||||
copy_name = target_name + "_copy"
|
||||
|
||||
copy(copy_name) {
|
||||
sources = [ "//third_party/flatbuffers/src/js/flatbuffers.js" ]
|
||||
outputs = [ "$target_gen_dir/flatbuffers.js" ]
|
||||
}
|
||||
|
||||
compiled_action_foreach(target_name) {
|
||||
tool = "//third_party/flatbuffers:flatc"
|
||||
|
||||
sources = invoker.sources
|
||||
deps = [ ":" + copy_name ]
|
||||
|
||||
out_dir = target_gen_dir
|
||||
|
||||
outputs = [
|
||||
"$out_dir/{{source_name_part}}_generated.ts",
|
||||
]
|
||||
|
||||
args = [
|
||||
"--ts",
|
||||
"--no-fb-import",
|
||||
"--gen-mutable",
|
||||
"-o",
|
||||
rebase_path(out_dir, root_build_dir),
|
||||
"-I",
|
||||
rebase_path("//", root_build_dir),
|
||||
]
|
||||
|
||||
if (defined(invoker.flatc_include_dirs)) {
|
||||
foreach(include_dir, invoker.flatc_include_dirs) {
|
||||
args += [
|
||||
"-I",
|
||||
rebase_path(include_dir, root_build_dir),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
args += [ "{{source}}" ]
|
||||
|
||||
# The deps may have steps that have to run before running flatc.
|
||||
if (defined(invoker.deps)) {
|
||||
deps += invoker.deps
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue