Home | History | Annotate | Download | only in scripts
      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 import("//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 
     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",
     23 ]
     24 
     25 css_properties_files = scripts_for_in_files + [
     26   "$_scripts_dir/css_properties.py",
     27 ]
     28 
     29 make_event_factory_files = scripts_for_in_files + [
     30   "$_scripts_dir/make_event_factory.py",
     31   "$_scripts_dir/templates/EventFactory.cpp.tmpl",
     32 ]
     33 
     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",
     38 ]
     39 
     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",
     44 ]
     45 
     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",
     50 ]
     51 
     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",
     55 ]
     56 
     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.
     59 if (is_win) {
     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 } else {
     63   gperf_exe = "gperf"
     64   bison_exe = "bison"
     65 }
     66 
     67 # Templates --------------------------------------------------------------------
     68 
     69 _blink_gen_dir = "$root_gen_dir/blink"
     70 
     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",
     79 ]
     80 
     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
     88 #                 from the GYP build.
     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 template("process_in_files") {
     93   action(target_name) {
     94     script = invoker.script
     95 
     96     inputs = invoker.in_files
     97     if (defined(invoker.other_inputs)) {
     98       inputs += invoker.other_inputs
     99     } else {
    100       inputs += scripts_for_in_files
    101     }
    102     outputs = invoker.outputs
    103 
    104     # Extract the directory to write files to.
    105     output_dir = get_path_info(outputs[0], "dir")
    106 
    107     args = rebase_path(invoker.in_files, root_build_dir) + [
    108       "--output_dir", rebase_path(output_dir, root_build_dir),
    109     ]
    110     if (defined(invoker.other_args)) {
    111       args += invoker.other_args
    112     }
    113 
    114     deps = make_core_generated_deps
    115   }
    116 }
    117 
    118 # Template for scripts using css_properties.py. This is a special case of
    119 # process_in_files.
    120 #   outputs: expected results
    121 template("css_properties") {
    122   process_in_files(target_name) {
    123     script = invoker.script
    124     in_files = ["css/CSSProperties.in"]
    125     other_inputs = css_properties_files
    126     if (defined(invoker.other_inputs)) {
    127       other_inputs += invoker.other_inputs
    128     }
    129     other_args = [
    130       "--gperf", gperf_exe,
    131     ]
    132     outputs = invoker.outputs
    133   }
    134 }
    135 
    136 # Template to run the make_names script. This is a special case of
    137 # process_in_files.
    138 #   in_files: files to pass to the script
    139 #   outputs: expected results
    140 template("make_names") {
    141   process_in_files(target_name) {
    142     script = "//third_party/WebKit/Source/build/scripts/make_names.py"
    143     in_files = invoker.in_files
    144     other_inputs = make_names_files
    145     outputs = invoker.outputs
    146   }
    147 }
    148 
    149 # Template to run the make_qualified_names script. This is a special case of
    150 # process_in_files.
    151 #   in_files: list of ".in" files to process.
    152 #   outputs: list of output files
    153 template("make_qualified_names") {
    154   process_in_files(target_name) {
    155     script = "//third_party/WebKit/Source/build/scripts/make_qualified_names.py"
    156     in_files = invoker.in_files
    157     other_inputs = make_qualified_names_files
    158     outputs = invoker.outputs
    159   }
    160 }
    161 
    162 # Calls the make_event_factory script. This is a special case of
    163 # process_in_files.
    164 #   in_files: list of ".in" files to process.
    165 #   outputs: list of output files
    166 template("make_event_factory") {
    167   process_in_files(target_name) {
    168     script = "//third_party/WebKit/Source/build/scripts/make_event_factory.py"
    169     in_files = invoker.in_files
    170     other_inputs = make_event_factory_files
    171     outputs = invoker.outputs
    172   }
    173 }
    174 
    175 # Calls the make_token_matcher script.
    176 #   input_file: The "*-in.cpp" file
    177 #   output_file: The output file
    178 template("make_token_matcher") {
    179   action(target_name) {
    180     script = "//third_party/WebKit/Source/build/scripts/make_token_matcher.py"
    181 
    182     inputs = scripts_for_in_files + [ invoker.input_file ]
    183     outputs = [ invoker.output_file ]
    184 
    185     args = [
    186       rebase_path(invoker.input_file, root_build_dir),
    187       rebase_path(invoker.output_file, root_build_dir),
    188     ]
    189 
    190     deps = make_core_generated_deps
    191   }
    192 }
    193