OLD | NEW |
1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import("//build/config/dcheck_always_on.gni") | 5 import("//build/config/dcheck_always_on.gni") |
6 | 6 |
7 # Generates a static catalog manifest to be loaded at runtime. This manifest | 7 # Generates a static catalog manifest to be loaded at runtime. This manifest |
8 # contains the union of all individual service manifests specified by the | 8 # contains the union of all individual service manifests specified by the |
9 # template parameters. | 9 # template parameters. |
10 # | 10 # |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 catalog_target_name = get_label_info(catalog_target, "name") | 131 catalog_target_name = get_label_info(catalog_target, "name") |
132 catalog_filename = "$catalog_target_dir/${catalog_target_name}.json" | 132 catalog_filename = "$catalog_target_dir/${catalog_target_name}.json" |
133 | 133 |
134 inputs += [ "$catalog_filename" ] | 134 inputs += [ "$catalog_filename" ] |
135 deps += [ catalog_target ] | 135 deps += [ catalog_target ] |
136 args += [ rebase_path(catalog_filename, root_build_dir) ] | 136 args += [ rebase_path(catalog_filename, root_build_dir) ] |
137 } | 137 } |
138 } | 138 } |
139 } | 139 } |
140 } | 140 } |
| 141 |
| 142 # Generates a source_set target which defines a single string contstant |
| 143 # containing the contents of a compiled catalog manifest. |
| 144 # |
| 145 # Parameters: |
| 146 # |
| 147 # catalog |
| 148 # The catalog target whose output should be stringified. |
| 149 # |
| 150 # output_symbol_name |
| 151 # The fully qualified symbol name of the C++ string constant to define in |
| 152 # the generate source_set. |
| 153 # |
| 154 template("catalog_cpp_source") { |
| 155 assert(defined(invoker.catalog), "catalog is required") |
| 156 assert(defined(invoker.output_symbol_name), "output_symbol_name is required") |
| 157 |
| 158 catalog_target = invoker.catalog |
| 159 catalog_target_dir = get_label_info(catalog_target, "target_gen_dir") |
| 160 catalog_target_name = get_label_info(catalog_target, "name") |
| 161 catalog_filename = "$catalog_target_dir/${catalog_target_name}.json" |
| 162 |
| 163 generator_target_name = "${target_name}__generator" |
| 164 generated_filename = "${target_gen_dir}/${target_name}.cc" |
| 165 |
| 166 action(generator_target_name) { |
| 167 testonly = defined(invoker.testonly) && invoker.testonly |
| 168 script = "//services/catalog/public/tools/sourcify_manifest.py" |
| 169 inputs = [ |
| 170 catalog_filename, |
| 171 ] |
| 172 outputs = [ |
| 173 generated_filename, |
| 174 ] |
| 175 args = [ |
| 176 "--input=" + rebase_path(catalog_filename, root_build_dir), |
| 177 "--output=" + rebase_path(generated_filename, root_build_dir), |
| 178 "--symbol-name=" + invoker.output_symbol_name, |
| 179 ] |
| 180 if (is_debug || dcheck_always_on) { |
| 181 args += [ "--pretty" ] |
| 182 } |
| 183 deps = [ |
| 184 catalog_target, |
| 185 ] |
| 186 } |
| 187 |
| 188 source_set(target_name) { |
| 189 testonly = defined(invoker.testonly) && invoker.testonly |
| 190 sources = get_target_outputs(":$generator_target_name") |
| 191 deps = [ |
| 192 ":$generator_target_name", |
| 193 ] |
| 194 } |
| 195 } |
OLD | NEW |