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.
5 import("//third_party/WebKit/Source/config.gni")
7 # All paths in this file should be absolute so targets in any directory can use
8 # them without worrying about the current directory.
9 _scripts_dir = "//third_party/WebKit/Source/build/scripts"
11 scripts_for_in_files = [
12 # jinja2/__init__.py contains version string, so sufficient as
13 # dependency for whole jinja2 package
14 "//third_party/jinja2/__init__.py",
15 "//third_party/markupsafe/__init__.py", # jinja2 dep
16 "$_scripts_dir/hasher.py",
17 "$_scripts_dir/in_file.py",
18 "$_scripts_dir/in_generator.py",
19 "$_scripts_dir/license.py",
20 "$_scripts_dir/name_utilities.py",
21 "$_scripts_dir/template_expander.py",
22 "$_scripts_dir/templates/macros.tmpl",
25 css_properties_files = scripts_for_in_files + [
26 "$_scripts_dir/css_properties.py",
29 make_event_factory_files = scripts_for_in_files + [
30 "$_scripts_dir/make_event_factory.py",
31 "$_scripts_dir/templates/EventFactory.cpp.tmpl",
34 make_names_files = scripts_for_in_files + [
35 "$_scripts_dir/make_names.py",
36 "$_scripts_dir/templates/MakeNames.cpp.tmpl",
37 "$_scripts_dir/templates/MakeNames.h.tmpl",
40 make_qualified_names_files = scripts_for_in_files + [
41 "$_scripts_dir/make_qualified_names.py",
42 "$_scripts_dir/templates/MakeQualifiedNames.cpp.tmpl",
43 "$_scripts_dir/templates/MakeQualifiedNames.h.tmpl",
46 make_element_factory_files = make_qualified_names_files + [
47 "$_scripts_dir/make_element_factory.py",
48 "$_scripts_dir/templates/ElementFactory.cpp.tmpl",
49 "$_scripts_dir/templates/ElementFactory.h.tmpl",
52 make_element_type_helpers_files = make_qualified_names_files + [
53 "$_scripts_dir/make_element_type_helpers.py",
54 "$_scripts_dir/templates/ElementTypeHelpers.h.tmpl",
57 # The executables are relative to the build directory. Don't rebase it because
58 # on Posix we want to run the system one on the path.
60 gperf_exe = rebase_path("//third_party/gperf/bin/gperf.exe", root_build_dir)
61 bison_exe = rebase_path("//third_party/bison/bin/bison.exe", root_build_dir)
67 # Templates --------------------------------------------------------------------
69 _blink_gen_dir = "$root_gen_dir/blink"
71 # The GYP target make_core_generated has some deps and a bunch of actions on
72 # it, which means that the deps will be resolved before the actions run. Here
73 # we have separate targets for each action. Its not clear which actions depend
74 # on these deps, so for GYP compatibility, all of the below actions should
75 # depend on the following deps.
76 make_core_generated_deps = [
77 "//third_party/WebKit/Source/core:generated_testing_idls",
78 "//third_party/WebKit/Source/core:core_event_interfaces",
81 # Template to run most of scripts that process "*.in" files.
82 # script: script to run.
83 # in_files: ".in" files to pass to the script
84 # other_inputs: (optional) other input files the script depends on
85 # defaults to "scripts_for_in_files" (if specified, we assume
86 # that the contents of "scripts_for_in_files" are included in
87 # this list specified since this is how these lists are filled
89 # outputs: expected results. Note that the directory of the 0th item in this
90 # list will be taken to be the output path.
91 # other_args: (optional) other arguments to pass to the script.
92 # deps [optional]: additional depenendencies
93 template("process_in_files") {
95 script = invoker.script
97 inputs = invoker.in_files
98 if (defined(invoker.other_inputs)) {
99 inputs += invoker.other_inputs
101 inputs += scripts_for_in_files
103 outputs = invoker.outputs
105 # Extract the directory to write files to.
106 output_dir = get_path_info(outputs[0], "dir")
108 args = rebase_path(invoker.in_files, root_build_dir) + [
109 "--output_dir", rebase_path(output_dir, root_build_dir),
111 if (defined(invoker.other_args)) {
112 args += invoker.other_args
115 deps = make_core_generated_deps
116 if (defined(invoker.deps)) {
122 # Template for scripts using css_properties.py. This is a special case of
124 # outputs: expected results
125 template("css_properties") {
126 process_in_files(target_name) {
127 script = invoker.script
128 in_files = ["css/CSSProperties.in"]
129 other_inputs = css_properties_files
130 if (defined(invoker.other_inputs)) {
131 other_inputs += invoker.other_inputs
134 "--gperf", gperf_exe,
136 outputs = invoker.outputs
140 # Template to run the make_names script. This is a special case of
142 # in_files: files to pass to the script
143 # outputs: expected results
144 # deps [optional]: additional dependencies
145 template("make_names") {
146 process_in_files(target_name) {
147 script = "//third_party/WebKit/Source/build/scripts/make_names.py"
148 in_files = invoker.in_files
149 other_inputs = make_names_files
150 outputs = invoker.outputs
151 if (defined(invoker.deps)) {
157 # Template to run the make_qualified_names script. This is a special case of
159 # in_files: list of ".in" files to process.
160 # outputs: list of output files
161 template("make_qualified_names") {
162 process_in_files(target_name) {
163 script = "//third_party/WebKit/Source/build/scripts/make_qualified_names.py"
164 in_files = invoker.in_files
165 other_inputs = make_qualified_names_files
166 outputs = invoker.outputs
170 # Calls the make_event_factory script. This is a special case of
172 # in_files: list of ".in" files to process.
173 # outputs: list of output files
174 # deps [optional]: additional depenendencies
175 template("make_event_factory") {
176 process_in_files(target_name) {
177 script = "//third_party/WebKit/Source/build/scripts/make_event_factory.py"
178 in_files = invoker.in_files
179 other_inputs = make_event_factory_files
180 outputs = invoker.outputs
181 if (defined(invoker.deps)) {
187 # Calls the make_token_matcher script.
188 # input_file: The "*-in.cpp" file
189 # output_file: The output file
190 template("make_token_matcher") {
191 action(target_name) {
192 script = "//third_party/WebKit/Source/build/scripts/make_token_matcher.py"
194 inputs = scripts_for_in_files + [ invoker.input_file ]
195 outputs = [ invoker.output_file ]
198 rebase_path(invoker.input_file, root_build_dir),
199 rebase_path(invoker.output_file, root_build_dir),
202 deps = make_core_generated_deps