naiveproxy/tools/json_schema_compiler/json_features.gni

79 lines
2.6 KiB
Plaintext
Raw Permalink Normal View History

2018-01-28 19:30:36 +03:00
# 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_type: The type of the features to generate, e.g. APIFeature.
# provider_class: The name of the provider class to generate, e.g.
# APIFeatureProvider.
# deps/public_deps/visibility: normal meaning
template("json_features") {
assert(defined(invoker.sources),
"\"sources\" must be defined for the $target_name template.")
assert(defined(invoker.feature_type),
"\"feature_type\" must be defined for the $target_name template.")
assert(defined(invoker.provider_class),
"\"provider_class\" must be defined for the $target_name template.")
feature_type = invoker.feature_type
provider_class = invoker.provider_class
compiler_root = "//tools/json_schema_compiler"
base_filename = target_name
action_name = "${target_name}_json_features"
source_set_name = target_name
generated_files = [
"$target_gen_dir/$base_filename.cc",
"$target_gen_dir/$base_filename.h",
]
action(action_name) {
visibility = [ ":$source_set_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_type",
"$provider_class",
rebase_path(target_gen_dir, root_build_dir),
"$base_filename",
] + rebased
# Add the deps in for the action as well, in case the deps generate the
# inputs used by the action.
forward_variables_from(invoker,
[
"deps",
"public_deps",
])
}
source_set(target_name) {
sources = generated_files
forward_variables_from(invoker,
[
"deps",
"public_deps",
"visibility",
])
if (!defined(public_deps)) {
public_deps = []
}
public_deps += [ ":$action_name" ]
# Append a dependency on the extensions system. Headers in this target
# are included by the feature compiler automatically.
if (!defined(deps)) {
deps = []
}
deps += [ "//extensions/common" ]
}
}