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 5import("//third_party/WebKit/Source/config.gni") 6 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" 10 11scripts_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_macros.py", 21 "$_scripts_dir/name_utilities.py", 22 "$_scripts_dir/template_expander.py", 23 "$_scripts_dir/templates/macros.tmpl", 24] 25 26make_event_factory_files = scripts_for_in_files + [ 27 "$_scripts_dir/make_event_factory.py", 28 "$_scripts_dir/templates/EventFactory.cpp.tmpl", 29] 30 31make_names_files = scripts_for_in_files + [ 32 "$_scripts_dir/make_names.py", 33 "$_scripts_dir/templates/MakeNames.cpp.tmpl", 34 "$_scripts_dir/templates/MakeNames.h.tmpl", 35] 36 37make_qualified_names_files = scripts_for_in_files + [ 38 "$_scripts_dir/make_qualified_names.py", 39 "$_scripts_dir/templates/MakeQualifiedNames.cpp.tmpl", 40 "$_scripts_dir/templates/MakeQualifiedNames.h.tmpl", 41] 42 43make_element_factory_files = make_qualified_names_files + [ 44 "$_scripts_dir/make_element_factory.py", 45 "$_scripts_dir/templates/ElementFactory.cpp.tmpl", 46 "$_scripts_dir/templates/ElementFactory.h.tmpl", 47 "$_scripts_dir/templates/ElementWrapperFactory.cpp.tmpl", 48 "$_scripts_dir/templates/ElementWrapperFactory.h.tmpl", 49] 50 51make_element_type_helpers_files = make_qualified_names_files + [ 52 "$_scripts_dir/make_element_type_helpers.py", 53 "$_scripts_dir/templates/ElementTypeHelpers.h.tmpl", 54] 55 56# The executables are relative to the build directory. Don't rebase it because 57# on Posix we want to run the system one on the path. 58if (is_win) { 59 perl_exe = rebase_path("//third_party/perl/perl/bin/perl.exe", root_build_dir) 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) 62 # Using cl instead of cygwin gcc cuts the processing time from 63 # 1m58s to 0m52s. 64 preprocessor = "--preprocessor \"cl.exe -nologo -EP -TP\"" 65} else { 66 perl_exe = "perl" 67 gperf_exe = "gperf" 68 bison_exe = "bison" 69 # We specify a preprocess so it happens locally and won't get 70 # distributed to goma. 71 # FIXME: /usr/bin/gcc won't exist on OSX forever. We want to 72 # use /usr/bin/clang once we require Xcode 4.x. 73 preprocessor = "--preprocessor \"/usr/bin/gcc -E -P -x c++\"" 74} 75 76# Templates -------------------------------------------------------------------- 77 78_blink_gen_dir = "$root_gen_dir/blink" 79 80# The GYP target make_core_generated has some deps and a bunch of actions on 81# it, which means that the deps will be resolved before the actions run. Here 82# we have separate targets for each action. Its not clear which actions depend 83# on these deps, so for GYP compatibility, all of the below actions should 84# depend on the following deps. 85make_core_generated_deps = [ 86 "//third_party/WebKit/Source/core:generated_testing_idls", 87 "//third_party/WebKit/Source/core:core_event_interfaces", 88] 89 90# Template to run most of scripts that process "*.in" files. 91# script: script to run. 92# in_files: ".in" files to pass to the script 93# other_inputs: (optional) other input files the script depends on 94# defaults to "scripts_for_in_files" (if specified, we assume 95# that the contents of "scripts_for_in_files" are included in 96# this list specified since this is how these lists are filled 97# from the GYP build. 98# outputs: expected results. Note that the directory of the 0th item in this 99# list will be taken to be the output path. 100# other_args: (optional) other arguements to pass to the script. 101template("process_in_files") { 102 action(target_name) { 103 script = invoker.script 104 105 source_prereqs = invoker.in_files 106 if (defined(invoker.other_inputs)) { 107 source_prereqs += invoker.other_inputs 108 } else { 109 source_prereqs += scripts_for_in_files 110 } 111 outputs = invoker.outputs 112 113 # Extract the directory to write files to. 114 output_dir = get_path_info(outputs[0], "dir") 115 116 args = rebase_path(invoker.in_files, root_build_dir) + [ 117 "--output_dir", rebase_path(output_dir, root_build_dir), 118 ] 119 if (defined(invoker.other_args)) { 120 args += invoker.other_args 121 } 122 123 deps = make_core_generated_deps 124 } 125} 126 127# Template to run the make_names script. This is a special case of 128# process_in_files. 129# in_files: files to pass to the script 130# outputs: expected results 131template("make_names") { 132 process_in_files(target_name) { 133 script = "//third_party/WebKit/Source/build/scripts/make_names.py" 134 in_files = invoker.in_files 135 other_inputs = make_names_files 136 outputs = invoker.outputs 137 other_args = [ "--defines", feature_defines_string ] 138 } 139} 140 141# Template to run the make_qualified_names script. This is a special case of 142# process_in_files. 143# in_files: list of ".in" files to process. 144# outputs: list of output files 145template("make_qualified_names") { 146 process_in_files(target_name) { 147 script = "//third_party/WebKit/Source/build/scripts/make_qualified_names.py" 148 in_files = invoker.in_files 149 other_inputs = make_qualified_names_files 150 outputs = invoker.outputs 151 other_args = [ "--defines", feature_defines_string ] 152 } 153} 154 155# Calls the make_event_factory script. This is a special case of 156# process_in_files. 157# in_files: list of ".in" files to process. 158# outputs: list of output files 159template("make_event_factory") { 160 process_in_files(target_name) { 161 script = "//third_party/WebKit/Source/build/scripts/make_event_factory.py" 162 in_files = invoker.in_files 163 other_inputs = make_event_factory_files 164 outputs = invoker.outputs 165 } 166} 167 168# Calls the make_token_matcher script. 169# input_file: The "*-in.cpp" file 170# output_file: The output file 171template("make_token_matcher") { 172 action(target_name) { 173 script = "//third_party/WebKit/Source/build/scripts/make_token_matcher.py" 174 175 source_prereqs = scripts_for_in_files + [ invoker.input_file ] 176 outputs = [ invoker.output_file ] 177 178 args = [ 179 rebase_path(invoker.input_file, root_build_dir), 180 rebase_path(invoker.output_file, root_build_dir), 181 ] 182 183 deps = make_core_generated_deps 184 } 185} 186 187