Add an UMA stat to be able to see if the User pods are show on start screen,
[chromium-blink-merge.git] / components / webui_generator / generator / wug.gni
blob28009a0724cee766bb2e39ff3bace02d9b615c3e
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.
5 # Generates native and HTML/JS supporting code for Web UI element from element's
6 # declaration JSON file.
8 # Parameters:
10 #   source (required)
11 #      declaration file.
13 # Example:
14 # wug("some_type_wug_generated") {
15 #   source = "some_type.json"
16 # }
18 # Target's name should be deduced from declaration file name by removing
19 # extension and adding '_wug_generated' prefix. This is needed to properly
20 # handle dependencies between declaration files and their imports.
22 # For declaration file with a full path 'src/full/path/some_type.json' 5 files
23 # will be generated and compiled:
24 #   $root_gen_dir/wug/full/path/some_type_export.h
25 #   $root_gen_dir/wug/full/path/some_type_view.h
26 #   $root_gen_dir/wug/full/path/some_type_view_model.cc
27 #   $root_gen_dir/wug/full/path/some_type_view_model.h
28 #   $root_gen_dir/wug/full/path/some_type_webui_view.cc
30 template("wug") {
31   declaration_path = invoker.source
32   generator_dir = "//components/webui_generator/generator"
33   generator_path = "$generator_dir/gen_sources.py"
34   src_root = rebase_path("//", root_build_dir)
36   helper_path = "$generator_dir/build_helper.py"
37   target_name = "${target_name}"
38   action_name = target_name + "_gen"
39   out_dir = "$root_gen_dir/wug"
41   helper_args = [
42     rebase_path(declaration_path, root_build_dir),
43     "--destination",
44     rebase_path(out_dir, root_build_dir),
45     "--root",
46     src_root,
47     "--gn",
48     "--output",
49   ]
51   expected_target_name =
52       exec_script(helper_path, helper_args + [ "target_name" ], "trim string")
53   assert(target_name == expected_target_name,
54          "Wrong target name. " + "Expected '" + expected_target_name +
55              "', got '" + target_name + "'.")
57   action(action_name) {
58     script = generator_path
59     sources = [
60       "$generator_dir/declaration.py",
61       "$generator_dir/export_h.py",
62       "$generator_dir/html_view.py",
63       "$generator_dir/util.py",
64       "$generator_dir/view_model.py",
65       "$generator_dir/web_ui_view.py",
66     ]
67     inputs = [
68       declaration_path,
69     ]
70     inputs +=
71         exec_script(helper_path, helper_args + [ "imports" ], "list lines")
72     common_prefix = process_file_template(
73             [ declaration_path ],
74             "$out_dir/{{source_root_relative_dir}}/{{source_name_part}}_")
75     common_prefix = common_prefix[0]
76     outputs = [
77       common_prefix + "export.h",
78       common_prefix + "view_model.h",
79       common_prefix + "view_model.cc",
80       common_prefix + "web_ui_view.h",
81       common_prefix + "web_ui_view.cc",
82     ]
83     args = [
84       rebase_path(declaration_path, root_build_dir),
85       "--root",
86       src_root,
87       "--destination",
88       rebase_path(out_dir, root_build_dir),
89     ]
90   }
92   component(target_name) {
93     sources = get_target_outputs(":$action_name")
94     defines = [ exec_script(helper_path,
95                             helper_args + [ "impl_macro" ],
96                             "trim string") ]
97     deps = [
98       "//base",
99       "//components/login",
100       "//components/strings",
101     ]
102     deps += exec_script(helper_path,
103                         helper_args + [ "import_dependencies" ],
104                         "list lines")
105     public_deps = [
106       "//components/webui_generator",
107     ]
109     all_dependent_configs =
110         [ "//components/webui_generator:wug_generated_config" ]
111   }