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

Side by Side Diff: extensions/generated_extensions_api.gni

Issue 256453002: Add GN template for generated extensions API targets. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
« no previous file with comments | « extensions/common/api/BUILD.gn ('k') | tools/json_schema_compiler/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2014 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 # Defines a static library corresponding to the output of schema compiler tools
6 # over a set of extensions API schemas (IDL or JSON format.) The library target
7 # has implicit hard dependencies on all schema files listed by the invoker and
8 # is itself a hard dependency.
9 #
10 # Invocations of this template may use the following variables:
11 #
12 # schemas [required] A list of schema files to be compiled.
brettw 2014/04/24 18:29:44 I'm thinking we should generally name this kind of
Ken Rockot(use gerrit already) 2014/04/24 19:39:54 Debated this for a while myself. I agree with your
13 #
14 # root_namespace [required] The namespace in which generated API code is to be
15 # wrapped. C++ namespace syntax is accepted for nested namespace
16 # (e.g. "foo::bar::api").
17 #
18 # impl_dir [required] The path containing C++ implementations of API functions.
19 # This path is used as the root path when looking for
20 # {schema}/{schema}_api.h headers during the API bundle generation phase.
21 # Such headers, if found, are automatically included by the generated code.
22 #
23 # uncompiled_schemas [optional] A list of schema files which should not be
24 # compiled, but which should still be processed for API bundle generation.
25 #
26 # deps [optional] If any deps are specified they will be inherited by the
27 # static library target.
28 #
29 # The static libarary target also inherits the visibility and output_name
30 # of its invoker.
31
32 template("generated_extensions_api") {
33 assert(defined(invoker.schemas),
34 "\"schemas\" must be defined for the $target_name template.")
35 assert(defined(invoker.root_namespace),
36 "\"root_namespace\" must be defined for the $target_name template.")
37 assert(defined(invoker.impl_dir),
38 "\"impl_dir\" must be defined for the $target_name template.")
39
40 # Keep a copy of the target_name here since it will be trampled
41 # in nested targets.
42 target_visibility = ":$target_name"
43
44 generated_config_name = target_name + "_generated_config"
45 config(generated_config_name) {
46 include_dirs = [ target_gen_dir ]
47 visibility = target_visibility
48 }
49
50 schemas = invoker.schemas
51 root_namespace = invoker.root_namespace
52 impl_dir = invoker.impl_dir
53 uncompiled_schemas = []
54 if (defined(invoker.uncompiled_schemas)) {
55 uncompiled_schemas = invoker.uncompiled_schemas
56 }
57
58 compiler_root = "//tools/json_schema_compiler"
59 compiler_script = "$compiler_root/compiler.py"
60 compiler_sources = [
61 "$compiler_root/cc_generator.py",
brettw 2014/04/24 18:29:44 Be consistent with the indenting. I would use 2 sp
Ken Rockot(use gerrit already) 2014/04/24 19:39:54 Done. Force of habit from C++ style...
62 "$compiler_root/code.py",
63 "$compiler_root/compiler.py",
64 "$compiler_root/cpp_generator.py",
65 "$compiler_root/cpp_type_generator.py",
66 "$compiler_root/cpp_util.py",
67 "$compiler_root/h_generator.py",
68 "$compiler_root/idl_schema.py",
69 "$compiler_root/model.py",
70 "$compiler_root/util_cc_helper.py" ]
brettw 2014/04/24 18:29:44 For these multiline lists, I put the ] on the next
Ken Rockot(use gerrit already) 2014/04/24 19:39:54 Done.
71
72 # This list mirrors the outputs that will be generated by the following
73 # action_foreach. It's used by the static_library target.
74 compiled_schema_outputs = process_file_template(
75 schemas,
76 [ "$target_gen_dir/{{source_name_part}}.cc",
77 "$target_gen_dir/{{source_name_part}}.h" ])
78
79 schema_generator_name = target_name + "_schema_generator"
80 action_foreach(schema_generator_name) {
81 script = compiler_script
82 hard_dep = true
83 source_prereqs = compiler_sources
84 sources = schemas
85 outputs = [
86 "$target_gen_dir/{{source_name_part}}.cc",
87 "$target_gen_dir/{{source_name_part}}.h" ]
88 args = [
89 "{{source}}",
90 "--root=" + rebase_path("//", root_build_dir),
brettw 2014/04/24 18:29:44 FWIW I have no way to tell if this is correct othe
Ken Rockot(use gerrit already) 2014/04/24 19:39:54 Yep. I' pretty confident the arguments are concept
91 "--destdir=" + rebase_path(root_gen_dir, root_build_dir),
92 "--namespace=$root_namespace",
93 "--generator=cpp" ]
94 visibility = target_visibility
95 }
96
97 bundle_generator_name = target_name + "_bundle_generator"
98 bundle_outputs = [
99 "$target_gen_dir/generated_api.cc",
brettw 2014/04/24 18:29:44 Ditto previous comments.
100 "$target_gen_dir/generated_api.h",
101 "$target_gen_dir/generated_schemas.cc",
102 "$target_gen_dir/generated_schemas.h" ]
103 action(bundle_generator_name) {
104 script = compiler_script
105 hard_dep = true
106 source_prereqs = compiler_sources + schemas + uncompiled_schemas
107 outputs = bundle_outputs
108 args = [
109 "--root=" + rebase_path("//", root_build_dir),
110 "--destdir=" + rebase_path(root_gen_dir, root_build_dir),
111 "--namespace=$root_namespace",
112 "--generator=cpp-bundle",
113 "--impl-dir=" + rebase_path(impl_dir, "//")] +
114 rebase_path(schemas, root_build_dir) +
115 rebase_path(uncompiled_schemas, root_build_dir)
116 }
117
118 static_library(target_name) {
brettw 2014/04/24 18:29:44 CAn this be a source_set instead of a static_libra
Ken Rockot(use gerrit already) 2014/04/24 19:39:54 I guess I don't see why it couldn't. Done. Some d
119 hard_dep = true
120 sources = compiled_schema_outputs + bundle_outputs
121 deps = [
122 ":$schema_generator_name",
123 ":$bundle_generator_name",
124 "//tools/json_schema_compiler:generated_api_util" ]
125
126 if (defined(invoker.deps)) {
127 deps += invoker.deps
128 }
129 direct_dependent_configs = [ ":$generated_config_name" ]
130
131 if (defined(invoker.visibility)) {
132 visibility = invoker.visibility
133 }
134 if (defined(invoker.output_name)) {
135 output_name = invoker.output_name
136 }
137 }
138 }
OLDNEW
« no previous file with comments | « extensions/common/api/BUILD.gn ('k') | tools/json_schema_compiler/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698