OLD | NEW |
(Empty) | |
| 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 |
| 3 # found in the LICENSE file. |
| 4 |
| 5 # Generates the FeatureProviders files for extension features files. |
| 6 # The following variables are required: |
| 7 # sources: The features.json files to use. |
| 8 # feature_class: The name of the feature class to generate, e.g. APIFeature. |
| 9 # provider_class: The name of the provider class to generate, e.g. |
| 10 # APIFeatureProvider. |
| 11 template("json_features") { |
| 12 assert(defined(invoker.sources), |
| 13 "\"sources\" must be defined for the $target_name template.") |
| 14 assert(defined(invoker.feature_class), |
| 15 "\"feature_class\" must be defined for the $target_name template.") |
| 16 assert(defined(invoker.provider_class), |
| 17 "\"provider_class\" must be defined for the $target_name template.") |
| 18 feature_class = invoker.feature_class |
| 19 provider_class = invoker.provider_class |
| 20 |
| 21 compiler_root = "//tools/json_schema_compiler" |
| 22 base_filename = target_name |
| 23 action_name = "${target_name}_json_features" |
| 24 generated_files = [ |
| 25 "$target_gen_dir/$base_filename.cc", |
| 26 "$target_gen_dir/$base_filename.h", |
| 27 ] |
| 28 |
| 29 action(action_name) { |
| 30 sources = invoker.sources |
| 31 script = "$compiler_root/feature_compiler.py" |
| 32 inputs = [ |
| 33 "$compiler_root/code.py", |
| 34 "$compiler_root/json_parse.py", |
| 35 ] |
| 36 outputs = generated_files |
| 37 rebased = rebase_path(sources, root_build_dir) |
| 38 args = [ |
| 39 ".", |
| 40 "$feature_class", |
| 41 "$provider_class", |
| 42 rebase_path(target_gen_dir, root_build_dir), |
| 43 "$base_filename", |
| 44 ] + rebased |
| 45 } |
| 46 |
| 47 source_set(target_name) { |
| 48 sources = generated_files |
| 49 public_deps = [ |
| 50 ":$action_name", |
| 51 ] |
| 52 } |
| 53 } |
OLD | NEW |