Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(702)

Side by Side Diff: third_party/flatbuffers/flatc.gni

Issue 1907603005: Add a dependency for FlatBuffers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 # Compile a flatbuffer.
6 #
7 # flatc_out_dir (optional)
8 # Specifies the path suffix that output files are generated under. This
9 # path will be appended to root_gen_dir.
10 #
11 # Targets that depend on the proto target will be able to include the
12 # resulting flatbuffers header with an include like:
13 # #include "dir/for/my_flatbuffer/buffer_generated.h"
14 # If undefined, this defaults to matchign the input directory for each
15 # .fbs file (you should almost always use the default mode).
16 #
17 # deps (optional)
18 # Additional dependencies.
19 #
20 # Parameters for compiling the generated code:
21 #
22 # defines (optional)
23 # Defines to supply to the source set that compiles the generated source
24 # code.
25 #
26 # extra_configs (optional)
27 # A list of config labels that will be appended to the configs applying
28 # to the source set.
29 #
30 # Example:
31 # flatbuffers_library("mylib") {
32 # sources = [
33 # "foo.fbs",
34 # ]
35 # }
36
37 template("flatbuffers_library") {
38 assert(defined(invoker.sources), "Need sources for flatbuffers_library")
39
40 # Don't apply OS-specific sources filtering to the assignments later on.
41 # Platform files should have gotten filtered out in the sources assignment
42 # when this template was invoked. If they weren't, it was on purpose and
43 # this template shouldn't re-apply the filter.
44 set_sources_assignment_filter([])
45
46 action_name = "${target_name}_gen"
47 source_set_name = target_name
48 action_foreach(action_name) {
49 visibility = [ ":$source_set_name" ]
50
51 deps = [
52 "//third_party/flatbuffers:flatc",
53 ]
54
55 script = "//third_party/flatbuffers/flatc_wrapper.py"
56
57 sources = invoker.sources
58
59 if (defined(invoker.flatc_out_dir)) {
60 out_dir = "$root_gen_dir/" + invoker.flatc_out_dir
61 } else {
62 out_dir = "{{source_gen_dir}}"
63 }
64
65 outputs = [
66 "$out_dir/{{source_name_part}}_generated.h",
67 ]
68
69 args = [
70 "./flatc",
71 "-c",
72 "-o",
73 "$out_dir",
74 "{{source}}",
75 ]
76
77 # The deps may have steps that have to run before running flatc.
78 if (defined(invoker.deps)) {
79 deps += invoker.deps
80 }
81 }
82
83 source_set(target_name) {
84 forward_variables_from(invoker,
85 [
86 "visibility",
87 "defines",
88 ])
89
90 sources = get_target_outputs(":$action_name")
91
92 if (defined(invoker.extra_configs)) {
93 configs += invoker.extra_configs
94 }
95
96 public_configs = [ "//third_party/flatbuffers:flatbuffers_config" ]
97
98 public_deps = [
99 # The generated headers reference headers within flatbuffers, so
100 # dependencies must be able to find those headers too.
101 "//third_party/flatbuffers:flatbuffers",
102 ]
103 deps = [
104 ":$action_name",
105 ]
106
107 # This will link any libraries in the deps (the use of invoker.deps in the
108 # action won't link it).
109 if (defined(invoker.deps)) {
110 deps += invoker.deps
111 }
112 }
113 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698