| Index: extensions/generated_extensions_api.gni
|
| diff --git a/extensions/generated_extensions_api.gni b/extensions/generated_extensions_api.gni
|
| index c8817a6d443569ecdc4bb913f04a655165ff5840..e231157e65f35052f4878d1f97fda57a5055aa7e 100644
|
| --- a/extensions/generated_extensions_api.gni
|
| +++ b/extensions/generated_extensions_api.gni
|
| @@ -11,20 +11,27 @@
|
| #
|
| # sources [required] A list of schema files to be compiled.
|
| #
|
| -# root_namespace [required] The namespace in which generated API code is to be
|
| +# root_namespace [required]
|
| +# The namespace in which generated API code is to be
|
| # wrapped. C++ namespace syntax is accepted for nested namespace
|
| # (e.g. "foo::bar::api").
|
| #
|
| -# impl_dir [required] The path containing C++ implementations of API functions.
|
| -# This path is used as the root path when looking for
|
| -# {schema}/{schema}_api.h headers during the API bundle generation phase.
|
| -# Such headers, if found, are automatically included by the generated code.
|
| +# bundle [optional, default = false]
|
| +# Boolean indicating if the schema files should be bundled or not.
|
| #
|
| -# uncompiled_sources [optional] A list of schema files which should not be
|
| -# compiled, but which should still be processed for API bundle generation.
|
| +# impl_dir [required if bundle = true, otherwise unused]
|
| +# The path containing C++ implementations of API functions. This path is
|
| +# used as the root path when looking for {schema}/{schema}_api.h headers
|
| +# during the API bundle generation phase. Such headers, if found, are
|
| +# automatically included by the generated code.
|
| #
|
| -# deps [optional] If any deps are specified they will be inherited by the
|
| -# static library target.
|
| +# uncompiled_sources [optional, only used when bundle = true]
|
| +# A list of schema files which should not be compiled, but which should still
|
| +# be processed for API bundle generation.
|
| +#
|
| +# deps [optional]
|
| +# If any deps are specified they will be inherited by the static library
|
| +# target.
|
| #
|
| # The static libarary target also inherits the visibility and output_name
|
| # of its invoker.
|
| @@ -34,8 +41,8 @@ template("generated_extensions_api") {
|
| "\"sources\" must be defined for the $target_name template.")
|
| assert(defined(invoker.root_namespace),
|
| "\"root_namespace\" must be defined for the $target_name template.")
|
| - assert(defined(invoker.impl_dir),
|
| - "\"impl_dir\" must be defined for the $target_name template.")
|
| +
|
| + bundle = defined(invoker.bundle) && invoker.bundle
|
|
|
| # Keep a copy of the target_name here since it will be trampled
|
| # in nested targets.
|
| @@ -49,11 +56,6 @@ template("generated_extensions_api") {
|
|
|
| schemas = invoker.sources
|
| root_namespace = invoker.root_namespace
|
| - impl_dir = invoker.impl_dir
|
| - uncompiled_schemas = []
|
| - if (defined(invoker.uncompiled_sources)) {
|
| - uncompiled_schemas = invoker.uncompiled_sources
|
| - }
|
|
|
| compiler_root = "//tools/json_schema_compiler"
|
| compiler_script = "$compiler_root/compiler.py"
|
| @@ -88,38 +90,51 @@ template("generated_extensions_api") {
|
| visibility = target_visibility
|
| }
|
|
|
| - bundle_generator_name = target_name + "_bundle_generator"
|
| - action(bundle_generator_name) {
|
| - script = compiler_script
|
| - source_prereqs = compiler_sources + schemas + uncompiled_schemas
|
| - outputs = [
|
| - "$target_gen_dir/generated_api.cc",
|
| - "$target_gen_dir/generated_api.h",
|
| - "$target_gen_dir/generated_schemas.cc",
|
| - "$target_gen_dir/generated_schemas.h",
|
| - ]
|
| - args = [
|
| - "--root=" + rebase_path("//", root_build_dir),
|
| - "--destdir=" + rebase_path(root_gen_dir, root_build_dir),
|
| - "--namespace=$root_namespace",
|
| - "--generator=cpp-bundle",
|
| - "--impl-dir=" + rebase_path(impl_dir, "//"),
|
| - ] +
|
| - rebase_path(schemas, root_build_dir) +
|
| - rebase_path(uncompiled_schemas, root_build_dir)
|
| + if (bundle) {
|
| + assert(defined(invoker.impl_dir),
|
| + "\"impl_dir\" must be defined for the $target_name template.")
|
| + impl_dir = invoker.impl_dir
|
| +
|
| + uncompiled_schemas = []
|
| + if (defined(invoker.uncompiled_sources)) {
|
| + uncompiled_schemas = invoker.uncompiled_sources
|
| + }
|
| +
|
| + bundle_generator_name = target_name + "_bundle_generator"
|
| + action(bundle_generator_name) {
|
| + script = compiler_script
|
| + source_prereqs = compiler_sources + schemas + uncompiled_schemas
|
| + outputs = [
|
| + "$target_gen_dir/generated_api.cc",
|
| + "$target_gen_dir/generated_api.h",
|
| + "$target_gen_dir/generated_schemas.cc",
|
| + "$target_gen_dir/generated_schemas.h",
|
| + ]
|
| + args = [
|
| + "--root=" + rebase_path("//", root_build_dir),
|
| + "--destdir=" + rebase_path(root_gen_dir, root_build_dir),
|
| + "--namespace=$root_namespace",
|
| + "--generator=cpp-bundle",
|
| + "--impl-dir=" + rebase_path(impl_dir, "//"),
|
| + ] +
|
| + rebase_path(schemas, root_build_dir) +
|
| + rebase_path(uncompiled_schemas, root_build_dir)
|
| + }
|
| }
|
|
|
| source_set(target_name) {
|
| - sources =
|
| - get_target_outputs(":$schema_generator_name") +
|
| - get_target_outputs(":$bundle_generator_name")
|
| + sources = get_target_outputs(":$schema_generator_name")
|
|
|
| deps = [
|
| ":$schema_generator_name",
|
| - ":$bundle_generator_name",
|
| "//tools/json_schema_compiler:generated_api_util",
|
| ]
|
|
|
| + if (bundle) {
|
| + sources += get_target_outputs(":$bundle_generator_name")
|
| + deps += [ ":$bundle_generator_name" ]
|
| + }
|
| +
|
| if (defined(invoker.deps)) {
|
| deps += invoker.deps
|
| }
|
|
|