Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(632)

Unified Diff: components/wug/generator/wug.gni

Issue 928163002: Initial implementation of WebUI generator (WUG) toolkit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Owners updated. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 ]
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698