Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright 2015 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 # Generates native and HTML/JS supporting code for Web UI element from element's | |
| 6 # declaration JSON file. | |
| 7 # | |
| 8 # Parameters: | |
| 9 # | |
| 10 # source (required) | |
| 11 # declaration file. | |
| 12 # | |
| 13 # NOTE: target's name should be deduced from declaration file full path | |
| 14 # (relative to 'src'), by replacing every nonalphanumeric character with '_', | |
| 15 # e.g. for declaration file with full path 'full/path/to/file.json' target name | |
| 16 # should be 'full_path_to_file_json'. This is needed to properly handle | |
|
Nikita (slow)
2015/02/25 18:21:59
nit: update comment
dzhioev (left Google)
2015/02/26 14:01:39
Done.
| |
| 17 # dependencies between declaration files and their imports. | |
| 18 # | |
| 19 # Example: | |
| 20 # wug("full_path_to_file_json") { | |
| 21 # source = "file.json" | |
| 22 # } | |
| 23 | |
| 24 template("wug") { | |
| 25 declaration_path = invoker.source | |
| 26 generator_dir = "//components/wug/generator" | |
| 27 generator_path = "$generator_dir/gen_sources.py" | |
| 28 src_root = rebase_path("//", root_build_dir) | |
| 29 | |
| 30 helper_path = "$generator_dir/build_helper.py" | |
| 31 target_name = "${target_name}" | |
| 32 action_name = target_name + "_gen" | |
| 33 out_dir = "$root_gen_dir/wug" | |
| 34 | |
| 35 helper_args = [ | |
| 36 rebase_path(declaration_path, root_build_dir), | |
| 37 "--destination", | |
| 38 out_dir, | |
| 39 "--root", | |
| 40 src_root, | |
| 41 "--gn", | |
| 42 "--output", | |
| 43 ] | |
| 44 | |
| 45 expected_target_name = | |
| 46 exec_script(helper_path, helper_args + [ "target_name" ], "trim string") | |
| 47 assert(target_name == expected_target_name, | |
| 48 "Wrong target name. " + "Expected '" + expected_target_name + | |
| 49 "', got '" + target_name + "'.") | |
| 50 | |
| 51 action(action_name) { | |
| 52 script = generator_path | |
| 53 sources = [ | |
| 54 "$generator_dir/declaration.py", | |
| 55 "$generator_dir/export_h.py", | |
| 56 "$generator_dir/html_view.py", | |
| 57 "$generator_dir/util.py", | |
| 58 "$generator_dir/view_model.py", | |
| 59 "$generator_dir/web_ui_view.py", | |
| 60 ] | |
| 61 inputs = [ | |
| 62 declaration_path, | |
| 63 ] | |
| 64 inputs += | |
| 65 exec_script(helper_path, helper_args + [ "imports" ], "list lines") | |
| 66 common_prefix = process_file_template( | |
| 67 [ declaration_path ], | |
| 68 "$out_dir/{{source_root_relative_dir}}/{{source_name_part}}_") | |
| 69 common_prefix = common_prefix[0] | |
| 70 outputs = [ | |
| 71 common_prefix + "export.h", | |
| 72 common_prefix + "view_model.h", | |
| 73 common_prefix + "view_model.cc", | |
| 74 common_prefix + "web_ui_view.h", | |
| 75 common_prefix + "web_ui_view.cc", | |
| 76 ] | |
| 77 args = [ | |
| 78 rebase_path(declaration_path, root_build_dir), | |
| 79 "--root", | |
| 80 src_root, | |
| 81 "--destination", | |
| 82 out_dir, | |
| 83 ] | |
| 84 } | |
| 85 | |
| 86 component(target_name) { | |
| 87 sources = get_target_outputs(":$action_name") | |
| 88 defines = [ exec_script(helper_path, | |
| 89 helper_args + [ "impl_macro" ], | |
| 90 "trim string") ] | |
| 91 deps = [ | |
| 92 "//base", | |
| 93 "//components/login", | |
| 94 "//components/strings", | |
| 95 ] | |
| 96 deps += exec_script(helper_path, | |
| 97 helper_args + [ "import_dependencies" ], | |
| 98 "list lines") | |
| 99 public_deps = [ | |
| 100 "//components/wug", | |
| 101 ] | |
| 102 | |
| 103 all_dependent_configs = [ "//components/wug:wug_gen_config" ] | |
| 104 } | |
| 105 } | |
| OLD | NEW |