1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312
|
# Copyright 2014 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/python.gni")
import("//build/toolchain/toolchain.gni")
import("//third_party/blink/renderer/config.gni")
import("//third_party/jinja2/jinja2.gni")
if (is_ios) {
import("//build/config/ios/ios_sdk.gni")
} else if (host_os == "mac") {
import("//build/config/mac/mac_sdk.gni")
}
# All paths in this file should be absolute so targets in any directory can use
# them without worrying about the current directory.
_scripts_dir = "//third_party/blink/renderer/build/scripts"
scripts_for_json5_files = jinja2_sources + [
"//third_party/pyjson5/src/json5/__init__.py",
"//third_party/pyjson5/src/json5/lib.py",
"//third_party/pyjson5/src/json5/parser.py",
"//third_party/pyjson5/src/json5/version.py",
"$_scripts_dir/blinkbuild/name_style_converter.py",
"$_scripts_dir/json5_generator.py",
"$_scripts_dir/license.py",
"$_scripts_dir/name_utilities.py",
"$_scripts_dir/template_expander.py",
"$_scripts_dir/templates/macros.tmpl",
"$_scripts_dir/core/css/field_alias_expander.py",
"$_scripts_dir/core/css/properties/templates/style_builder_functions.tmpl",
]
css_properties_files = scripts_for_json5_files + [
"$_scripts_dir/core/css/css_properties.py",
"$_scripts_dir/make_origin_trials.py",
"$_scripts_dir/make_runtime_features_utilities.py",
"$_scripts_dir/make_runtime_features.py",
]
make_event_factory_files = scripts_for_json5_files + [
"$_scripts_dir/make_event_factory.py",
"$_scripts_dir/templates/event_factory.cc.tmpl",
]
make_names_files = scripts_for_json5_files + [
"$_scripts_dir/make_names.py",
"$_scripts_dir/templates/make_names.cc.tmpl",
"$_scripts_dir/templates/make_names.h.tmpl",
]
make_qualified_names_files =
scripts_for_json5_files + [
"$_scripts_dir/aria_properties.py",
"$_scripts_dir/make_qualified_names.py",
"$_scripts_dir/templates/make_qualified_names.cc.tmpl",
"$_scripts_dir/templates/make_qualified_names.h.tmpl",
]
make_element_factory_files =
make_qualified_names_files + [
"$_scripts_dir/make_element_factory.py",
"$_scripts_dir/templates/element_factory.cc.tmpl",
"$_scripts_dir/templates/element_factory.h.tmpl",
]
make_element_type_helpers_files =
make_qualified_names_files + [
"$_scripts_dir/make_element_type_helpers.py",
"$_scripts_dir/templates/element_type_helpers.cc.tmpl",
"$_scripts_dir/templates/element_type_helpers.h.tmpl",
]
make_trie_helpers_files =
scripts_for_json5_files + [ "$_scripts_dir/trie_builder.py" ]
# The executables are relative to the build directory. Don't rebase it because
# on Posix we want to run the system one on the path.
if (host_os == "win") {
gperf_exe = rebase_path("//third_party/gperf/bin/gperf.exe", root_build_dir)
} else if (is_ios) {
gperf_exe = ios_bin_path + "gperf"
} else if (host_os == "mac") {
# TODO(thakis): This should probably run in the host toolchain and check
# is_mac instead of checking host_os.
gperf_exe = mac_bin_path + "gperf"
} else {
gperf_exe = "gperf"
}
# Templates --------------------------------------------------------------------
_blink_gen_dir = "$root_gen_dir/third_party/blink/renderer"
make_core_generated_deps = [
"//third_party/blink/renderer/core:core_event_interfaces",
"//third_party/blink/renderer/core:generated_testing_idls",
]
# A wrapper for python scripts. This adds the following paths to PYTHONPATH,
# then run invoker.script.
# - //third_party/blink/renderer/build/scripts
# - //third_party
# - //third_party/pyjson5/src
# - //tools
template("blink_python_runner") {
action(target_name) {
script = "$_scripts_dir/run_with_pythonpath.py"
sources = [ invoker.script ]
if (defined(invoker.sources)) {
sources += invoker.sources
}
if (defined(invoker.inputs)) {
inputs = invoker.inputs
}
if (defined(invoker.data)) {
data = invoker.data
}
outputs = invoker.outputs
args = [
"-I",
rebase_path(_scripts_dir, root_build_dir),
"-I",
rebase_path("//third_party", root_build_dir),
"-I",
rebase_path("//third_party/pyjson5/src", root_build_dir),
"-I",
rebase_path("//tools", root_build_dir),
rebase_path(invoker.script, root_build_dir),
] + invoker.args
if (defined(invoker.deps)) {
deps = invoker.deps
}
if (defined(invoker.data_deps)) {
data_deps = invoker.data_deps
}
forward_variables_from(invoker, [ "visibility" ])
}
}
# TODO(crbug.com/732657): Remove this once everything that uses this switches over to
# the 'code_generator' template instead.
# Template to run most of scripts that process "*.json5" files.
# script: script to run.
# in_files: input ".json5" files to pass to the script
# other_inputs: (optional) other input files the script depends on
# defaults to "scripts_for_json5_files" (if specified, we assume
# that the contents of "scripts_for_json5_files" are included in
# this list).
# outputs: expected results. Note that the directory of the 0th item in this
# list will be taken to be the output path.
# other_args: (optional) other arguments to pass to the script.
# deps [optional]:
# Depenendencies. If unspecified defaults to make_core_generated_deps.
template("process_json5_files") {
blink_python_runner(target_name) {
script = invoker.script
inputs = invoker.in_files
if (defined(invoker.other_inputs)) {
inputs += invoker.other_inputs
} else {
inputs += scripts_for_json5_files
}
outputs = invoker.outputs
# Extract the directory to write files to.
output_dir = get_path_info(outputs[0], "dir")
args = rebase_path(invoker.in_files, root_build_dir) + [
"--output_dir",
rebase_path(output_dir, root_build_dir),
]
if (defined(invoker.other_args)) {
args += invoker.other_args
}
if (defined(invoker.deps)) {
deps = invoker.deps
} else {
deps = make_core_generated_deps
}
forward_variables_from(invoker, [ "visibility" ])
}
}
# Template to run code generators in build/scripts/.
# script: the path to the script to run.
# json_inputs: ".json5" files to pass to the generator.
# templates: ".tmpl" files that this generator depends on.
# other_inputs: (optional) other input files the generator depends on
# in addition to "scripts_for_json5_files"
# outputs: expected results. Note that the directory of the 0th item in this
# list will be taken to be the output path.
# other_args: (optional) other arguments to pass to the script.
# deps [optional]:
# Depenendencies. If unspecified defaults to make_core_generated_deps.
template("code_generator") {
blink_python_runner(target_name) {
script = invoker.script
inputs = invoker.json_inputs + invoker.templates + scripts_for_json5_files
if (defined(invoker.other_inputs)) {
inputs += invoker.other_inputs
}
outputs = invoker.outputs
# Extract the directory to write files to.
output_dir = get_path_info(outputs[0], "dir")
args = rebase_path(invoker.json_inputs, root_build_dir) + [
"--output_dir",
rebase_path(output_dir, root_build_dir),
]
if (defined(invoker.other_args)) {
args += invoker.other_args
}
if (defined(invoker.deps)) {
deps = invoker.deps
} else {
deps = make_core_generated_deps
}
forward_variables_from(invoker, [ "visibility" ])
}
}
# Template for scripts using css_properties.py. This is a special case of
# process_json5_files.
# outputs: expected results
template("css_properties") {
process_json5_files(target_name) {
script = invoker.script
in_files = [
"css/css_properties.json5",
"css/computed_style_field_aliases.json5",
"../platform/runtime_enabled_features.json5",
]
if (defined(invoker.in_files)) {
in_files += invoker.in_files
}
other_inputs = css_properties_files
if (defined(invoker.other_inputs)) {
other_inputs += invoker.other_inputs
}
other_args = [
"--gperf",
gperf_exe,
]
outputs = invoker.outputs
}
}
# Template to run the make_names script. This is a special case of
# process_json5_files.
# in_files: input files to pass to the script
# output_dir: output directory
# deps [optional]:
# Dependencies. See process_json5_files for definition.
template("make_names") {
output_dir = invoker.output_dir
outputs = process_file_template(invoker.in_files,
[
"$output_dir/{{source_name_part}}.cc",
"$output_dir/{{source_name_part}}.h",
])
process_json5_files(target_name) {
script = "//third_party/blink/renderer/build/scripts/make_names.py"
other_inputs = make_names_files
forward_variables_from(invoker,
[
"deps",
"in_files",
"public_deps",
"visibility",
])
}
}
# Template to run the make_qualified_names script. This is a special case of
# process_json5_files.
# in_files: list of input ".json5" files to process.
# outputs: list of output files
template("make_qualified_names") {
process_json5_files(target_name) {
script =
"//third_party/blink/renderer/build/scripts/make_qualified_names.py"
in_files = invoker.in_files
other_inputs = make_qualified_names_files
outputs = invoker.outputs
}
}
# Calls the make_event_factory script. This is a special case of
# process_json5_files.
# in_files: list of input ".json5" files to process.
# outputs: list of output files
# deps [optional]
# Dependencies. See process_json5_files for definition.
template("make_event_factory") {
process_json5_files(target_name) {
script = "//third_party/blink/renderer/build/scripts/make_event_factory.py"
other_inputs = make_event_factory_files
forward_variables_from(invoker,
[
"deps",
"in_files",
"outputs",
"visibility",
])
}
}
|