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

Side by Side Diff: build/secondary/tools/grit/grit_rule.gni

Issue 361633002: [Android][gn] Add android resources templates (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gn-java
Patch Set: Created 6 years, 5 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
1 # Copyright 2014 The Chromium Authors. All rights reserved. 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 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 # Instantiate grit. This will produce a script target to run grit, and a 5 # Instantiate grit. This will produce a script target to run grit, and a
6 # static library that compiles the .cc files. 6 # static library that compiles the .cc files.
7 # 7 #
8 # Parameters 8 # Parameters
9 # 9 #
10 # source 10 # source
(...skipping 26 matching lines...) Expand all
37 ] 37 ]
38 } 38 }
39 39
40 if (is_desktop_linux) { 40 if (is_desktop_linux) {
41 grit_defines += [ "-D", "desktop_linux" ] 41 grit_defines += [ "-D", "desktop_linux" ]
42 } 42 }
43 43
44 if (is_android) { 44 if (is_android) {
45 grit_defines += [ 45 grit_defines += [
46 "-t", "android", 46 "-t", "android",
47 "-E", "ANDROID_JAVA_TAGGED_ONLY=true",
48 ] 47 ]
49 } 48 }
50 49
51 if (enable_extensions) { 50 if (enable_extensions) {
52 grit_defines += [ "-D", "enable_extensions" ] 51 grit_defines += [ "-D", "enable_extensions" ]
53 } 52 }
54 if (enable_plugins) { 53 if (enable_plugins) {
55 grit_defines += [ "-D", "enable_plugins" ] 54 grit_defines += [ "-D", "enable_plugins" ]
56 } 55 }
57 if (enable_task_manager) { 56 if (enable_task_manager) {
(...skipping 14 matching lines...) Expand all
72 grit_resource_id_file = "//tools/gritsettings/resource_ids" 71 grit_resource_id_file = "//tools/gritsettings/resource_ids"
73 grit_info_script = "//tools/grit/grit_info.py" 72 grit_info_script = "//tools/grit/grit_info.py"
74 73
75 template("grit") { 74 template("grit") {
76 assert(defined(invoker.source), 75 assert(defined(invoker.source),
77 "\"source\" must be defined for the grit template $target_name") 76 "\"source\" must be defined for the grit template $target_name")
78 assert(!defined(invoker.sources) && !defined(invoker.outputs), 77 assert(!defined(invoker.sources) && !defined(invoker.outputs),
79 "Neither \"sources\" nor \"outputs\" can be defined for the grit " + 78 "Neither \"sources\" nor \"outputs\" can be defined for the grit " +
80 "template $target_name") 79 "template $target_name")
81 80
81 if (defined(invoker.resource_ids)) {
82 resource_ids = invoker.resource_ids
83 } else {
84 resource_ids = grit_resource_id_file
85 }
86
87 if (defined(invoker.output_dir)) {
88 output_dir = invoker.output_dir
89 } else {
90 output_dir = target_gen_dir
91 }
92
82 # These are all passed as arguments to the script so have to be relative to 93 # These are all passed as arguments to the script so have to be relative to
83 # the build directory. 94 # the build directory.
84 resource_ids = 95 if (resource_ids != "") {
85 rebase_path(grit_resource_id_file, root_build_dir) 96 resource_ids = rebase_path(resource_ids, root_build_dir)
86 output_dir = rebase_path(target_gen_dir, root_build_dir) 97 }
98 rebased_output_dir = rebase_path(output_dir, root_build_dir)
87 source_path = rebase_path(invoker.source, root_build_dir) 99 source_path = rebase_path(invoker.source, root_build_dir)
88 100
89 if (defined(invoker.grit_flags)) { 101 if (defined(invoker.grit_flags)) {
90 grit_flags = invoker.grit_flags 102 grit_flags = invoker.grit_flags
91 } else { 103 } else {
92 grit_flags = [] # These are optional so default to empty list. 104 grit_flags = [] # These are optional so default to empty list.
93 } 105 }
94 106
95 grit_inputs_build_rel = exec_script(grit_info_script, 107 grit_inputs_build_rel = exec_script(grit_info_script,
96 [ "--inputs", source_path, "-f", resource_ids] + grit_flags, "list lines") 108 [ "--inputs", source_path, "-f", resource_ids] + grit_flags, "list lines")
97 # The inputs are relative to the current (build) directory, rebase to 109 # The inputs are relative to the current (build) directory, rebase to
98 # the current one. 110 # the current one.
99 grit_inputs = rebase_path(grit_inputs_build_rel, ".", root_build_dir) + [ 111 grit_inputs = rebase_path(grit_inputs_build_rel, ".", root_build_dir) + [
100 grit_resource_id_file, 112 grit_resource_id_file,
101 ] 113 ]
102 114
103 grit_outputs_build_rel = exec_script(grit_info_script, 115 grit_outputs_build_rel = exec_script(grit_info_script,
104 [ "--outputs", "$output_dir", source_path, "-f", resource_ids ] + 116 [ "--outputs", "$rebased_output_dir", source_path, "-f", resource_ids ] +
105 grit_flags, 117 grit_flags,
106 "list lines") 118 "list lines")
107 119
108 # The inputs are relative to the current (build) directory, rebase to 120 # The inputs are relative to the current (build) directory, rebase to
109 # the current one. 121 # the current one.
110 grit_outputs = rebase_path(grit_outputs_build_rel, ".", root_build_dir) 122 grit_outputs = rebase_path(grit_outputs_build_rel, ".", root_build_dir)
111 123
112 # The config and the action below get this visibility son only the generated 124 # The config and the action below get this visibility son only the generated
113 # source set can depend on them. The variable "target_name" will get 125 # source set can depend on them. The variable "target_name" will get
114 # overwritten inside the innter classes so we need to compute it here. 126 # overwritten inside the innter classes so we need to compute it here.
115 target_visibility = ":$target_name" 127 target_visibility = ":$target_name"
116 128
117 # The current grit setup makes an file in $target_gen_dir/grit/foo.h that 129 # The current grit setup makes an file in $output_dir/grit/foo.h that
118 # the source code expects to include via "grit/foo.h". It would be nice to 130 # the source code expects to include via "grit/foo.h". It would be nice to
119 # change this to including absolute paths relative to the root gen directory 131 # change this to including absolute paths relative to the root gen directory
120 # (like "mycomponent/foo.h"). This config sets up the include path. 132 # (like "mycomponent/foo.h"). This config sets up the include path.
121 grit_config = target_name + "_grit_config" 133 grit_config = target_name + "_grit_config"
122 config(grit_config) { 134 config(grit_config) {
123 include_dirs = [ target_gen_dir ] 135 include_dirs = [ output_dir ]
124 visibility = target_visibility 136 visibility = target_visibility
125 } 137 }
126 138
127 grit_custom_target = target_name + "_grit" 139 grit_custom_target = target_name + "_grit"
128 action(grit_custom_target) { 140 action(grit_custom_target) {
129 script = "//tools/grit/grit.py" 141 script = "//tools/grit/grit.py"
130 source_prereqs = grit_inputs 142 source_prereqs = grit_inputs
131 outputs = grit_outputs 143 outputs = grit_outputs
132 144
133 args = [ 145 args = [
134 "-i", source_path, "build", 146 "-i", source_path, "build",
135 "-f", resource_ids, 147 "-f", resource_ids,
136 "-o", output_dir, 148 "-o", rebased_output_dir,
137 ] + grit_defines + grit_flags 149 ] + grit_defines + grit_flags
138 150
139 visibility = target_visibility 151 visibility = target_visibility
140 152
141 if (defined(invoker.deps)) { 153 if (defined(invoker.deps)) {
142 deps = invoker.deps 154 deps = invoker.deps
143 } 155 }
144 } 156 }
145 157
146 # This is the thing that people actually link with, it must be named the 158 # This is the thing that people actually link with, it must be named the
147 # same as the argument the template was invoked with. 159 # same as the argument the template was invoked with.
148 source_set(target_name) { 160 source_set(target_name) {
149 # Since we generate a file, we need to be run before the targets that 161 # Since we generate a file, we need to be run before the targets that
150 # depend on us. 162 # depend on us.
151 sources = grit_outputs 163 sources = grit_outputs
152 164
153 # Deps set on the template invocation will go on the grit script running 165 # Deps set on the template invocation will go on the grit script running
154 # target rather than this library. 166 # target rather than this library.
155 deps = [ ":$grit_custom_target" ] 167 deps = [ ":$grit_custom_target" ]
156 direct_dependent_configs = [ ":$grit_config" ] 168 direct_dependent_configs = [ ":$grit_config" ]
157 169
158 if (defined(invoker.visibility)) { 170 if (defined(invoker.visibility)) {
159 visibility = invoker.visibility 171 visibility = invoker.visibility
160 } 172 }
161 if (defined(invoker.output_name)) { 173 if (defined(invoker.output_name)) {
162 output_name = invoker.output_name 174 output_name = invoker.output_name
163 } 175 }
164 } 176 }
165 } 177 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698