| Index: components/wug/generator/wug.gni
|
| diff --git a/components/wug/generator/wug.gni b/components/wug/generator/wug.gni
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..29f3e55f47ab3dc08683008e678a7cde465efe64
|
| --- /dev/null
|
| +++ b/components/wug/generator/wug.gni
|
| @@ -0,0 +1,95 @@
|
| +# Copyright 2015 The Chromium Authors. All rights reserved.
|
| +# Use of this source code is governed by a BSD-style license that can be
|
| +# found in the LICENSE file.
|
| +
|
| +# Generates native and HTML/JS supporting code for Web UI element from element's
|
| +# declaration JSON file.
|
| +#
|
| +# Parameters:
|
| +#
|
| +# source (required)
|
| +# declaration file.
|
| +#
|
| +# NOTE: target's name should be deduced from declaration file full path
|
| +# (relative to 'src'), by replacing every nonalphanumeric character with '_',
|
| +# e.g. for declaration file with full path 'full/path/to/file.json' target name
|
| +# should be 'full_path_to_file_json'. This is needed to properly handle
|
| +# dependencies between declaration files and their imports.
|
| +#
|
| +# Example:
|
| +# wug("full_path_to_file_json") {
|
| +# source = "file.json"
|
| +# }
|
| +
|
| +template("wug") {
|
| + declaration_path = invoker.source
|
| + generator_dir = "//components/wug/generator"
|
| + generator_path = "$generator_dir/gen_sources.py"
|
| + src_root = rebase_path("//", root_build_dir)
|
| +
|
| + helper_path = "$generator_dir/build_helper.py"
|
| + source_set_name = "${target_name}"
|
| + action_name = source_set_name + "_gen"
|
| + config_name = source_set_name + "_config"
|
| + out_dir = "$root_gen_dir/wug"
|
| +
|
| + helper_args = [
|
| + rebase_path(declaration_path, root_build_dir),
|
| + "--destination",
|
| + out_dir,
|
| + "--root",
|
| + src_root,
|
| + "--gn",
|
| + "--output",
|
| + ]
|
| +
|
| + expected_source_set_name =
|
| + exec_script(helper_path, helper_args + [ "target_name" ], "trim string")
|
| + assert(source_set_name == expected_source_set_name,
|
| + "Wrong target name. " + "Expected '" + expected_source_set_name +
|
| + "', got '" + source_set_name + "'.")
|
| +
|
| + action(action_name) {
|
| + script = generator_path
|
| + sources = [
|
| + "$generator_dir/declaration.py",
|
| + "$generator_dir/html_view.py",
|
| + "$generator_dir/util.py",
|
| + "$generator_dir/view_model.py",
|
| + "$generator_dir/web_ui_view.py",
|
| + ]
|
| +
|
| + inputs = [
|
| + declaration_path,
|
| + ]
|
| + inputs +=
|
| + exec_script(helper_path, helper_args + [ "imports" ], "list lines")
|
| + outputs =
|
| + exec_script(helper_path, helper_args + [ "list_outputs" ], "list lines")
|
| + args = [
|
| + rebase_path(declaration_path, root_build_dir),
|
| + "--root",
|
| + src_root,
|
| + "--destination",
|
| + out_dir,
|
| + ]
|
| + }
|
| +
|
| + config(config_name) {
|
| + include_dirs = [ out_dir ]
|
| + }
|
| +
|
| + source_set(source_set_name) {
|
| + sources = get_target_outputs(":$action_name")
|
| + deps = [
|
| + "//base",
|
| + "//components/strings",
|
| + "//components/wug",
|
| + "//skia",
|
| + ]
|
| + deps += exec_script(helper_path,
|
| + helper_args + [ "import_dependencies" ],
|
| + "list lines")
|
| + public_configs = [ ":" + config_name ]
|
| + }
|
| +}
|
|
|