| # Copyright 2016 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 the FeatureProviders files for extension features files. |
| # The following variables are required: |
| # sources: The features.json files to use. |
| # feature_class: The name of the feature class to generate, e.g. APIFeature. |
| # provider_class: The name of the provider class to generate, e.g. |
| # APIFeatureProvider. |
| template("json_features") { |
| assert(defined(invoker.sources), |
| "\"sources\" must be defined for the $target_name template.") |
| assert(defined(invoker.feature_class), |
| "\"feature_class\" must be defined for the $target_name template.") |
| assert(defined(invoker.provider_class), |
| "\"provider_class\" must be defined for the $target_name template.") |
| feature_class = invoker.feature_class |
| provider_class = invoker.provider_class |
| |
| compiler_root = "//tools/json_schema_compiler" |
| base_filename = target_name |
| action_name = "${target_name}_json_features" |
| generated_files = [ |
| "$target_gen_dir/$base_filename.cc", |
| "$target_gen_dir/$base_filename.h", |
| ] |
| |
| action(action_name) { |
| sources = invoker.sources |
| script = "$compiler_root/feature_compiler.py" |
| inputs = [ |
| "$compiler_root/code.py", |
| "$compiler_root/json_parse.py", |
| ] |
| outputs = generated_files |
| rebased = rebase_path(sources, root_build_dir) |
| args = [ |
| ".", |
| "$feature_class", |
| "$provider_class", |
| rebase_path(target_gen_dir, root_build_dir), |
| "$base_filename", |
| ] + rebased |
| } |
| |
| source_set(target_name) { |
| sources = generated_files |
| public_deps = [ |
| ":$action_name", |
| ] |
| } |
| } |