2014-10-01 02:26:52 +04:00
|
|
|
# Copyright 2014 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.
|
|
|
|
|
|
|
|
# Defines a static library corresponding to the output of schema compiler tools
|
|
|
|
# over a set of extensions API schemas (IDL or JSON format.) The library target
|
|
|
|
# has implicit hard dependencies on all schema files listed by the invoker and
|
|
|
|
# is itself a hard dependency.
|
|
|
|
#
|
|
|
|
# Invocations of this template may use the following variables:
|
|
|
|
#
|
|
|
|
# sources [required] A list of schema files to be compiled.
|
|
|
|
#
|
|
|
|
# root_namespace [required]
|
|
|
|
# A Python string substituion pattern used to generate the C++
|
|
|
|
# namespace for each API. Use %(namespace)s to replace with the API
|
|
|
|
# namespace, like "toplevel::%(namespace)s_api".
|
|
|
|
#
|
|
|
|
# schema_include_rules [optional]
|
|
|
|
# A list of paths to include when searching for referenced objects,
|
|
|
|
# with the namespace separated by a :.
|
|
|
|
# Example:
|
|
|
|
# [ '/foo/bar:Foo::Bar::%(namespace)s' ]
|
|
|
|
#
|
|
|
|
# schemas [optional, default = false]
|
|
|
|
# Boolean indicating if the schema files should be generated.
|
|
|
|
#
|
|
|
|
# bundle [optional, default = false]
|
|
|
|
# Boolean indicating if the schema bundle files should be generated.
|
|
|
|
#
|
|
|
|
# bundle_registration [optional, default = false]
|
|
|
|
# Boolean indicating if the API registration bundle files should be generated.
|
|
|
|
#
|
Generate all extension schema namespaces as "api" and instead vary the generated bundle names.
At the moment the 3 modules that use extension API schemas, those in
extensions/common/api, chrome/common/extensions/api, and extensions/shell/api,
are generated with different C++ namespaces: "core_api", "api", and
"shell::api" respectively.
This is a pointless distinction to make since as far as JS is concerned they
must all go on the window.chrome object, therefore namespace conflicts are
impossible. It just ends up adding code noise.
The only problem it solves is that all bundle compiles are generated to the
same name, "GeneratedSchemas" and "GeneratedFunctionRegistry". This patch
solves that a different way, by adding a JSON schema compiler option to give
those generated classes a prefix such that they are "GeneratedSchemas",
"ChromeGeneratedSchemas", and "ShellGeneratedSchemas" respectively.
This lets us to a global substitution from "core_api" to just "api".
R=rockot@chromium.org, dpranke@chromium.org
TBR=ben@chromium.org
Review URL: https://codereview.chromium.org/1226353004
Cr-Original-Commit-Position: refs/heads/master@{#340119}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: e58e6223146f09405229146fce6c1bfe6b71e4ce
2015-07-23 21:27:22 +03:00
|
|
|
# bundle_name [required if bundle or bundle_registrations]:
|
|
|
|
# A string to prepend to generated bundle class names, so that multiple
|
|
|
|
# bundle rules can be used without conflicting. Only used with one of
|
|
|
|
# the cpp-bundle generators.
|
|
|
|
#
|
2014-10-01 02:26:52 +04:00
|
|
|
# impl_dir [required if bundle_registration = 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
|
|
|
|
# when generating API registration bundles. Such headers, if found, are
|
|
|
|
# automatically included by the generated code.
|
|
|
|
#
|
|
|
|
# uncompiled_sources [optional, only used when bundle = true or
|
|
|
|
# bundle_registration = true]
|
|
|
|
# A list of schema files which should not be compiled, but which should still
|
|
|
|
# be processed for API bundle generation.
|
|
|
|
#
|
2015-07-28 21:24:42 +03:00
|
|
|
# configs [optional]
|
|
|
|
# Extra configs to apply to the compile step.
|
|
|
|
#
|
2014-10-01 02:26:52 +04:00
|
|
|
# deps [optional]
|
|
|
|
# If any deps are specified they will be inherited by the static library
|
|
|
|
# target.
|
|
|
|
#
|
2015-05-02 03:42:59 +03:00
|
|
|
# generate_static_library [optional, defaults to false]
|
|
|
|
# Produces a static library instead of a source_set.
|
|
|
|
#
|
|
|
|
# The generated library target also inherits the visibility and output_name
|
2014-10-01 02:26:52 +04:00
|
|
|
# of its invoker.
|
|
|
|
|
|
|
|
template("json_schema_api") {
|
|
|
|
assert(defined(invoker.sources),
|
|
|
|
"\"sources\" must be defined for the $target_name template.")
|
|
|
|
assert(defined(invoker.root_namespace),
|
|
|
|
"\"root_namespace\" must be defined for the $target_name template.")
|
|
|
|
|
|
|
|
schemas = defined(invoker.schemas) && invoker.schemas
|
|
|
|
bundle = defined(invoker.bundle) && invoker.bundle
|
gn format //build
A starting point for doing all of src, and adding a PRESUBMIT.
Includes https://codereview.chromium.org/772663002/ and https://codereview.chromium.org/770053002/.
I haven't pushed new binaries yet.
Generated via:
> cd build
> git ls-files *.gn *.gni | sed -e "s/^/@..\\\\out\\\\Debug\\\\gn format --in-place /" >x.bat && x.bat
The only things that I don't love in the current output are:
1. Turning
args = [
"--depfile", rebase_path(depfile, root_build_dir),
"--android-sdk-tools", rebased_android_sdk_build_tools,
"--dex-path", rebased_output,
]
into:
args = [
"--depfile",
rebase_path(depfile, root_build_dir),
"--android-sdk-tools",
rebased_android_sdk_build_tools,
"--dex-path",
rebased_output,
]
The heuristic for this isn't trivial though, and it also affects e.g. '-Xclang' in cflags, as well
as assignments to temporaries that are later assigned to args.
2. Turning single line
if (defined(invoker.inputs)) { inputs = invoker.inputs }
into
if (defined(invoker.inputs)) {
inputs = invoker.inputs
}
This could be argued to be an improvement, but as it's very boilerplate-y perhaps an exception to
allow single line in this case is worthwhile. I think there was discussion of new syntax for this
case too, something like "inputs ?= invoker.inputs" maybe.
In both cases, I think it's worthwhile to get formatting turned on, and then go back and special
case these if we decide it's worthwhile.
R=brettw@chromium.org
BUG=348474
Review URL: https://codereview.chromium.org/766573003
Cr-Original-Commit-Position: refs/heads/master@{#306305}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: b199254f481c5db36d56e83fce40594b06d2b81f
2014-12-02 03:25:20 +03:00
|
|
|
bundle_registration =
|
|
|
|
defined(invoker.bundle_registration) && invoker.bundle_registration
|
2014-10-01 02:26:52 +04:00
|
|
|
|
|
|
|
schema_include_rules = ""
|
|
|
|
if (defined(invoker.schema_include_rules)) {
|
|
|
|
schema_include_rules = invoker.schema_include_rules
|
|
|
|
}
|
|
|
|
|
|
|
|
# Keep a copy of the target_name here since it will be trampled
|
|
|
|
# in nested targets.
|
|
|
|
target_visibility = [ ":$target_name" ]
|
|
|
|
|
|
|
|
generated_config_name = target_name + "_generated_config"
|
|
|
|
config(generated_config_name) {
|
2015-01-13 21:34:46 +03:00
|
|
|
include_dirs = [ root_gen_dir ]
|
2014-10-01 02:26:52 +04:00
|
|
|
visibility = target_visibility
|
|
|
|
}
|
|
|
|
|
|
|
|
root_namespace = invoker.root_namespace
|
|
|
|
|
|
|
|
compiler_root = "//tools/json_schema_compiler"
|
|
|
|
compiler_script = "$compiler_root/compiler.py"
|
|
|
|
compiler_sources = [
|
|
|
|
"$compiler_root/cc_generator.py",
|
|
|
|
"$compiler_root/code.py",
|
|
|
|
"$compiler_root/compiler.py",
|
Generate all extension schema namespaces as "api" and instead vary the generated bundle names.
At the moment the 3 modules that use extension API schemas, those in
extensions/common/api, chrome/common/extensions/api, and extensions/shell/api,
are generated with different C++ namespaces: "core_api", "api", and
"shell::api" respectively.
This is a pointless distinction to make since as far as JS is concerned they
must all go on the window.chrome object, therefore namespace conflicts are
impossible. It just ends up adding code noise.
The only problem it solves is that all bundle compiles are generated to the
same name, "GeneratedSchemas" and "GeneratedFunctionRegistry". This patch
solves that a different way, by adding a JSON schema compiler option to give
those generated classes a prefix such that they are "GeneratedSchemas",
"ChromeGeneratedSchemas", and "ShellGeneratedSchemas" respectively.
This lets us to a global substitution from "core_api" to just "api".
R=rockot@chromium.org, dpranke@chromium.org
TBR=ben@chromium.org
Review URL: https://codereview.chromium.org/1226353004
Cr-Original-Commit-Position: refs/heads/master@{#340119}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: e58e6223146f09405229146fce6c1bfe6b71e4ce
2015-07-23 21:27:22 +03:00
|
|
|
"$compiler_root/cpp_bundle_generator.py",
|
2014-10-01 02:26:52 +04:00
|
|
|
"$compiler_root/cpp_generator.py",
|
|
|
|
"$compiler_root/cpp_type_generator.py",
|
|
|
|
"$compiler_root/cpp_util.py",
|
|
|
|
"$compiler_root/h_generator.py",
|
|
|
|
"$compiler_root/idl_schema.py",
|
|
|
|
"$compiler_root/model.py",
|
|
|
|
"$compiler_root/util_cc_helper.py",
|
|
|
|
]
|
|
|
|
|
|
|
|
if (schemas) {
|
|
|
|
schema_generator_name = target_name + "_schema_generator"
|
|
|
|
action_foreach(schema_generator_name) {
|
|
|
|
script = compiler_script
|
2015-05-02 03:42:59 +03:00
|
|
|
sources = invoker.sources
|
2014-10-01 02:26:52 +04:00
|
|
|
inputs = compiler_sources
|
|
|
|
outputs = [
|
|
|
|
"$target_gen_dir/{{source_name_part}}.cc",
|
|
|
|
"$target_gen_dir/{{source_name_part}}.h",
|
|
|
|
]
|
|
|
|
args = [
|
|
|
|
"{{source}}",
|
|
|
|
"--root=" + rebase_path("//", root_build_dir),
|
|
|
|
"--destdir=" + rebase_path(root_gen_dir, root_build_dir),
|
|
|
|
"--namespace=$root_namespace",
|
|
|
|
"--generator=cpp",
|
gn format //build
A starting point for doing all of src, and adding a PRESUBMIT.
Includes https://codereview.chromium.org/772663002/ and https://codereview.chromium.org/770053002/.
I haven't pushed new binaries yet.
Generated via:
> cd build
> git ls-files *.gn *.gni | sed -e "s/^/@..\\\\out\\\\Debug\\\\gn format --in-place /" >x.bat && x.bat
The only things that I don't love in the current output are:
1. Turning
args = [
"--depfile", rebase_path(depfile, root_build_dir),
"--android-sdk-tools", rebased_android_sdk_build_tools,
"--dex-path", rebased_output,
]
into:
args = [
"--depfile",
rebase_path(depfile, root_build_dir),
"--android-sdk-tools",
rebased_android_sdk_build_tools,
"--dex-path",
rebased_output,
]
The heuristic for this isn't trivial though, and it also affects e.g. '-Xclang' in cflags, as well
as assignments to temporaries that are later assigned to args.
2. Turning single line
if (defined(invoker.inputs)) { inputs = invoker.inputs }
into
if (defined(invoker.inputs)) {
inputs = invoker.inputs
}
This could be argued to be an improvement, but as it's very boilerplate-y perhaps an exception to
allow single line in this case is worthwhile. I think there was discussion of new syntax for this
case too, something like "inputs ?= invoker.inputs" maybe.
In both cases, I think it's worthwhile to get formatting turned on, and then go back and special
case these if we decide it's worthwhile.
R=brettw@chromium.org
BUG=348474
Review URL: https://codereview.chromium.org/766573003
Cr-Original-Commit-Position: refs/heads/master@{#306305}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: b199254f481c5db36d56e83fce40594b06d2b81f
2014-12-02 03:25:20 +03:00
|
|
|
"--include-rules=$schema_include_rules",
|
|
|
|
]
|
2014-10-01 02:26:52 +04:00
|
|
|
|
|
|
|
if (defined(invoker.visibility)) {
|
|
|
|
# If visibility is restricted, add our own target to it.
|
2015-02-01 05:54:07 +03:00
|
|
|
visibility = invoker.visibility + target_visibility
|
2014-10-01 02:26:52 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bundle) {
|
Generate all extension schema namespaces as "api" and instead vary the generated bundle names.
At the moment the 3 modules that use extension API schemas, those in
extensions/common/api, chrome/common/extensions/api, and extensions/shell/api,
are generated with different C++ namespaces: "core_api", "api", and
"shell::api" respectively.
This is a pointless distinction to make since as far as JS is concerned they
must all go on the window.chrome object, therefore namespace conflicts are
impossible. It just ends up adding code noise.
The only problem it solves is that all bundle compiles are generated to the
same name, "GeneratedSchemas" and "GeneratedFunctionRegistry". This patch
solves that a different way, by adding a JSON schema compiler option to give
those generated classes a prefix such that they are "GeneratedSchemas",
"ChromeGeneratedSchemas", and "ShellGeneratedSchemas" respectively.
This lets us to a global substitution from "core_api" to just "api".
R=rockot@chromium.org, dpranke@chromium.org
TBR=ben@chromium.org
Review URL: https://codereview.chromium.org/1226353004
Cr-Original-Commit-Position: refs/heads/master@{#340119}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: e58e6223146f09405229146fce6c1bfe6b71e4ce
2015-07-23 21:27:22 +03:00
|
|
|
assert(defined(invoker.bundle_name),
|
|
|
|
"\"bundle_name\" must be defined for bundles")
|
|
|
|
|
2014-10-01 02:26:52 +04:00
|
|
|
uncompiled_sources = []
|
|
|
|
if (defined(invoker.uncompiled_sources)) {
|
gn format //build
A starting point for doing all of src, and adding a PRESUBMIT.
Includes https://codereview.chromium.org/772663002/ and https://codereview.chromium.org/770053002/.
I haven't pushed new binaries yet.
Generated via:
> cd build
> git ls-files *.gn *.gni | sed -e "s/^/@..\\\\out\\\\Debug\\\\gn format --in-place /" >x.bat && x.bat
The only things that I don't love in the current output are:
1. Turning
args = [
"--depfile", rebase_path(depfile, root_build_dir),
"--android-sdk-tools", rebased_android_sdk_build_tools,
"--dex-path", rebased_output,
]
into:
args = [
"--depfile",
rebase_path(depfile, root_build_dir),
"--android-sdk-tools",
rebased_android_sdk_build_tools,
"--dex-path",
rebased_output,
]
The heuristic for this isn't trivial though, and it also affects e.g. '-Xclang' in cflags, as well
as assignments to temporaries that are later assigned to args.
2. Turning single line
if (defined(invoker.inputs)) { inputs = invoker.inputs }
into
if (defined(invoker.inputs)) {
inputs = invoker.inputs
}
This could be argued to be an improvement, but as it's very boilerplate-y perhaps an exception to
allow single line in this case is worthwhile. I think there was discussion of new syntax for this
case too, something like "inputs ?= invoker.inputs" maybe.
In both cases, I think it's worthwhile to get formatting turned on, and then go back and special
case these if we decide it's worthwhile.
R=brettw@chromium.org
BUG=348474
Review URL: https://codereview.chromium.org/766573003
Cr-Original-Commit-Position: refs/heads/master@{#306305}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: b199254f481c5db36d56e83fce40594b06d2b81f
2014-12-02 03:25:20 +03:00
|
|
|
uncompiled_sources = invoker.uncompiled_sources
|
2014-10-01 02:26:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bundle_generator_schema_name = target_name + "_bundle_generator_schema"
|
|
|
|
action(bundle_generator_schema_name) {
|
|
|
|
script = compiler_script
|
2015-05-02 03:42:59 +03:00
|
|
|
inputs = compiler_sources + invoker.sources + uncompiled_sources
|
2014-10-01 02:26:52 +04:00
|
|
|
outputs = [
|
|
|
|
"$target_gen_dir/generated_schemas.cc",
|
|
|
|
"$target_gen_dir/generated_schemas.h",
|
|
|
|
]
|
|
|
|
args = [
|
gn format //build
A starting point for doing all of src, and adding a PRESUBMIT.
Includes https://codereview.chromium.org/772663002/ and https://codereview.chromium.org/770053002/.
I haven't pushed new binaries yet.
Generated via:
> cd build
> git ls-files *.gn *.gni | sed -e "s/^/@..\\\\out\\\\Debug\\\\gn format --in-place /" >x.bat && x.bat
The only things that I don't love in the current output are:
1. Turning
args = [
"--depfile", rebase_path(depfile, root_build_dir),
"--android-sdk-tools", rebased_android_sdk_build_tools,
"--dex-path", rebased_output,
]
into:
args = [
"--depfile",
rebase_path(depfile, root_build_dir),
"--android-sdk-tools",
rebased_android_sdk_build_tools,
"--dex-path",
rebased_output,
]
The heuristic for this isn't trivial though, and it also affects e.g. '-Xclang' in cflags, as well
as assignments to temporaries that are later assigned to args.
2. Turning single line
if (defined(invoker.inputs)) { inputs = invoker.inputs }
into
if (defined(invoker.inputs)) {
inputs = invoker.inputs
}
This could be argued to be an improvement, but as it's very boilerplate-y perhaps an exception to
allow single line in this case is worthwhile. I think there was discussion of new syntax for this
case too, something like "inputs ?= invoker.inputs" maybe.
In both cases, I think it's worthwhile to get formatting turned on, and then go back and special
case these if we decide it's worthwhile.
R=brettw@chromium.org
BUG=348474
Review URL: https://codereview.chromium.org/766573003
Cr-Original-Commit-Position: refs/heads/master@{#306305}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: b199254f481c5db36d56e83fce40594b06d2b81f
2014-12-02 03:25:20 +03:00
|
|
|
"--root=" + rebase_path("//", root_build_dir),
|
|
|
|
"--destdir=" + rebase_path(root_gen_dir, root_build_dir),
|
|
|
|
"--namespace=$root_namespace",
|
Generate all extension schema namespaces as "api" and instead vary the generated bundle names.
At the moment the 3 modules that use extension API schemas, those in
extensions/common/api, chrome/common/extensions/api, and extensions/shell/api,
are generated with different C++ namespaces: "core_api", "api", and
"shell::api" respectively.
This is a pointless distinction to make since as far as JS is concerned they
must all go on the window.chrome object, therefore namespace conflicts are
impossible. It just ends up adding code noise.
The only problem it solves is that all bundle compiles are generated to the
same name, "GeneratedSchemas" and "GeneratedFunctionRegistry". This patch
solves that a different way, by adding a JSON schema compiler option to give
those generated classes a prefix such that they are "GeneratedSchemas",
"ChromeGeneratedSchemas", and "ShellGeneratedSchemas" respectively.
This lets us to a global substitution from "core_api" to just "api".
R=rockot@chromium.org, dpranke@chromium.org
TBR=ben@chromium.org
Review URL: https://codereview.chromium.org/1226353004
Cr-Original-Commit-Position: refs/heads/master@{#340119}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: e58e6223146f09405229146fce6c1bfe6b71e4ce
2015-07-23 21:27:22 +03:00
|
|
|
"--bundle-name=" + invoker.bundle_name,
|
gn format //build
A starting point for doing all of src, and adding a PRESUBMIT.
Includes https://codereview.chromium.org/772663002/ and https://codereview.chromium.org/770053002/.
I haven't pushed new binaries yet.
Generated via:
> cd build
> git ls-files *.gn *.gni | sed -e "s/^/@..\\\\out\\\\Debug\\\\gn format --in-place /" >x.bat && x.bat
The only things that I don't love in the current output are:
1. Turning
args = [
"--depfile", rebase_path(depfile, root_build_dir),
"--android-sdk-tools", rebased_android_sdk_build_tools,
"--dex-path", rebased_output,
]
into:
args = [
"--depfile",
rebase_path(depfile, root_build_dir),
"--android-sdk-tools",
rebased_android_sdk_build_tools,
"--dex-path",
rebased_output,
]
The heuristic for this isn't trivial though, and it also affects e.g. '-Xclang' in cflags, as well
as assignments to temporaries that are later assigned to args.
2. Turning single line
if (defined(invoker.inputs)) { inputs = invoker.inputs }
into
if (defined(invoker.inputs)) {
inputs = invoker.inputs
}
This could be argued to be an improvement, but as it's very boilerplate-y perhaps an exception to
allow single line in this case is worthwhile. I think there was discussion of new syntax for this
case too, something like "inputs ?= invoker.inputs" maybe.
In both cases, I think it's worthwhile to get formatting turned on, and then go back and special
case these if we decide it's worthwhile.
R=brettw@chromium.org
BUG=348474
Review URL: https://codereview.chromium.org/766573003
Cr-Original-Commit-Position: refs/heads/master@{#306305}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: b199254f481c5db36d56e83fce40594b06d2b81f
2014-12-02 03:25:20 +03:00
|
|
|
"--generator=cpp-bundle-schema",
|
|
|
|
"--include-rules=$schema_include_rules",
|
2015-05-02 03:42:59 +03:00
|
|
|
] + rebase_path(invoker.sources, root_build_dir) +
|
gn format //build
A starting point for doing all of src, and adding a PRESUBMIT.
Includes https://codereview.chromium.org/772663002/ and https://codereview.chromium.org/770053002/.
I haven't pushed new binaries yet.
Generated via:
> cd build
> git ls-files *.gn *.gni | sed -e "s/^/@..\\\\out\\\\Debug\\\\gn format --in-place /" >x.bat && x.bat
The only things that I don't love in the current output are:
1. Turning
args = [
"--depfile", rebase_path(depfile, root_build_dir),
"--android-sdk-tools", rebased_android_sdk_build_tools,
"--dex-path", rebased_output,
]
into:
args = [
"--depfile",
rebase_path(depfile, root_build_dir),
"--android-sdk-tools",
rebased_android_sdk_build_tools,
"--dex-path",
rebased_output,
]
The heuristic for this isn't trivial though, and it also affects e.g. '-Xclang' in cflags, as well
as assignments to temporaries that are later assigned to args.
2. Turning single line
if (defined(invoker.inputs)) { inputs = invoker.inputs }
into
if (defined(invoker.inputs)) {
inputs = invoker.inputs
}
This could be argued to be an improvement, but as it's very boilerplate-y perhaps an exception to
allow single line in this case is worthwhile. I think there was discussion of new syntax for this
case too, something like "inputs ?= invoker.inputs" maybe.
In both cases, I think it's worthwhile to get formatting turned on, and then go back and special
case these if we decide it's worthwhile.
R=brettw@chromium.org
BUG=348474
Review URL: https://codereview.chromium.org/766573003
Cr-Original-Commit-Position: refs/heads/master@{#306305}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: b199254f481c5db36d56e83fce40594b06d2b81f
2014-12-02 03:25:20 +03:00
|
|
|
rebase_path(uncompiled_sources, root_build_dir)
|
2014-10-01 02:26:52 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bundle_registration) {
|
Generate all extension schema namespaces as "api" and instead vary the generated bundle names.
At the moment the 3 modules that use extension API schemas, those in
extensions/common/api, chrome/common/extensions/api, and extensions/shell/api,
are generated with different C++ namespaces: "core_api", "api", and
"shell::api" respectively.
This is a pointless distinction to make since as far as JS is concerned they
must all go on the window.chrome object, therefore namespace conflicts are
impossible. It just ends up adding code noise.
The only problem it solves is that all bundle compiles are generated to the
same name, "GeneratedSchemas" and "GeneratedFunctionRegistry". This patch
solves that a different way, by adding a JSON schema compiler option to give
those generated classes a prefix such that they are "GeneratedSchemas",
"ChromeGeneratedSchemas", and "ShellGeneratedSchemas" respectively.
This lets us to a global substitution from "core_api" to just "api".
R=rockot@chromium.org, dpranke@chromium.org
TBR=ben@chromium.org
Review URL: https://codereview.chromium.org/1226353004
Cr-Original-Commit-Position: refs/heads/master@{#340119}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: e58e6223146f09405229146fce6c1bfe6b71e4ce
2015-07-23 21:27:22 +03:00
|
|
|
assert(defined(invoker.bundle_name),
|
|
|
|
"\"bundle_name\" must be defined for bundle registrations")
|
|
|
|
|
2014-10-01 02:26:52 +04:00
|
|
|
uncompiled_sources = []
|
|
|
|
if (defined(invoker.uncompiled_sources)) {
|
gn format //build
A starting point for doing all of src, and adding a PRESUBMIT.
Includes https://codereview.chromium.org/772663002/ and https://codereview.chromium.org/770053002/.
I haven't pushed new binaries yet.
Generated via:
> cd build
> git ls-files *.gn *.gni | sed -e "s/^/@..\\\\out\\\\Debug\\\\gn format --in-place /" >x.bat && x.bat
The only things that I don't love in the current output are:
1. Turning
args = [
"--depfile", rebase_path(depfile, root_build_dir),
"--android-sdk-tools", rebased_android_sdk_build_tools,
"--dex-path", rebased_output,
]
into:
args = [
"--depfile",
rebase_path(depfile, root_build_dir),
"--android-sdk-tools",
rebased_android_sdk_build_tools,
"--dex-path",
rebased_output,
]
The heuristic for this isn't trivial though, and it also affects e.g. '-Xclang' in cflags, as well
as assignments to temporaries that are later assigned to args.
2. Turning single line
if (defined(invoker.inputs)) { inputs = invoker.inputs }
into
if (defined(invoker.inputs)) {
inputs = invoker.inputs
}
This could be argued to be an improvement, but as it's very boilerplate-y perhaps an exception to
allow single line in this case is worthwhile. I think there was discussion of new syntax for this
case too, something like "inputs ?= invoker.inputs" maybe.
In both cases, I think it's worthwhile to get formatting turned on, and then go back and special
case these if we decide it's worthwhile.
R=brettw@chromium.org
BUG=348474
Review URL: https://codereview.chromium.org/766573003
Cr-Original-Commit-Position: refs/heads/master@{#306305}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: b199254f481c5db36d56e83fce40594b06d2b81f
2014-12-02 03:25:20 +03:00
|
|
|
uncompiled_sources = invoker.uncompiled_sources
|
2014-10-01 02:26:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
assert(defined(invoker.impl_dir),
|
|
|
|
"\"impl_dir\" must be defined for the $target_name template.")
|
2015-05-27 22:41:42 +03:00
|
|
|
|
|
|
|
# Child directory inside the generated file tree.
|
|
|
|
gen_child_dir = rebase_path(invoker.impl_dir, "//")
|
2014-10-01 02:26:52 +04:00
|
|
|
|
gn format //build
A starting point for doing all of src, and adding a PRESUBMIT.
Includes https://codereview.chromium.org/772663002/ and https://codereview.chromium.org/770053002/.
I haven't pushed new binaries yet.
Generated via:
> cd build
> git ls-files *.gn *.gni | sed -e "s/^/@..\\\\out\\\\Debug\\\\gn format --in-place /" >x.bat && x.bat
The only things that I don't love in the current output are:
1. Turning
args = [
"--depfile", rebase_path(depfile, root_build_dir),
"--android-sdk-tools", rebased_android_sdk_build_tools,
"--dex-path", rebased_output,
]
into:
args = [
"--depfile",
rebase_path(depfile, root_build_dir),
"--android-sdk-tools",
rebased_android_sdk_build_tools,
"--dex-path",
rebased_output,
]
The heuristic for this isn't trivial though, and it also affects e.g. '-Xclang' in cflags, as well
as assignments to temporaries that are later assigned to args.
2. Turning single line
if (defined(invoker.inputs)) { inputs = invoker.inputs }
into
if (defined(invoker.inputs)) {
inputs = invoker.inputs
}
This could be argued to be an improvement, but as it's very boilerplate-y perhaps an exception to
allow single line in this case is worthwhile. I think there was discussion of new syntax for this
case too, something like "inputs ?= invoker.inputs" maybe.
In both cases, I think it's worthwhile to get formatting turned on, and then go back and special
case these if we decide it's worthwhile.
R=brettw@chromium.org
BUG=348474
Review URL: https://codereview.chromium.org/766573003
Cr-Original-Commit-Position: refs/heads/master@{#306305}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: b199254f481c5db36d56e83fce40594b06d2b81f
2014-12-02 03:25:20 +03:00
|
|
|
bundle_generator_registration_name =
|
|
|
|
target_name + "_bundle_generator_registration"
|
2014-10-01 02:26:52 +04:00
|
|
|
action(bundle_generator_registration_name) {
|
|
|
|
script = compiler_script
|
2015-05-02 03:42:59 +03:00
|
|
|
inputs = compiler_sources + invoker.sources + uncompiled_sources
|
2014-10-01 02:26:52 +04:00
|
|
|
outputs = [
|
2015-05-27 22:41:42 +03:00
|
|
|
"$root_gen_dir/$gen_child_dir/generated_api_registration.cc",
|
|
|
|
"$root_gen_dir/$gen_child_dir/generated_api_registration.h",
|
2014-10-01 02:26:52 +04:00
|
|
|
]
|
|
|
|
args = [
|
gn format //build
A starting point for doing all of src, and adding a PRESUBMIT.
Includes https://codereview.chromium.org/772663002/ and https://codereview.chromium.org/770053002/.
I haven't pushed new binaries yet.
Generated via:
> cd build
> git ls-files *.gn *.gni | sed -e "s/^/@..\\\\out\\\\Debug\\\\gn format --in-place /" >x.bat && x.bat
The only things that I don't love in the current output are:
1. Turning
args = [
"--depfile", rebase_path(depfile, root_build_dir),
"--android-sdk-tools", rebased_android_sdk_build_tools,
"--dex-path", rebased_output,
]
into:
args = [
"--depfile",
rebase_path(depfile, root_build_dir),
"--android-sdk-tools",
rebased_android_sdk_build_tools,
"--dex-path",
rebased_output,
]
The heuristic for this isn't trivial though, and it also affects e.g. '-Xclang' in cflags, as well
as assignments to temporaries that are later assigned to args.
2. Turning single line
if (defined(invoker.inputs)) { inputs = invoker.inputs }
into
if (defined(invoker.inputs)) {
inputs = invoker.inputs
}
This could be argued to be an improvement, but as it's very boilerplate-y perhaps an exception to
allow single line in this case is worthwhile. I think there was discussion of new syntax for this
case too, something like "inputs ?= invoker.inputs" maybe.
In both cases, I think it's worthwhile to get formatting turned on, and then go back and special
case these if we decide it's worthwhile.
R=brettw@chromium.org
BUG=348474
Review URL: https://codereview.chromium.org/766573003
Cr-Original-Commit-Position: refs/heads/master@{#306305}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: b199254f481c5db36d56e83fce40594b06d2b81f
2014-12-02 03:25:20 +03:00
|
|
|
"--root=" + rebase_path("//", root_build_dir),
|
|
|
|
"--destdir=" + rebase_path(root_gen_dir, root_build_dir),
|
|
|
|
"--namespace=$root_namespace",
|
Generate all extension schema namespaces as "api" and instead vary the generated bundle names.
At the moment the 3 modules that use extension API schemas, those in
extensions/common/api, chrome/common/extensions/api, and extensions/shell/api,
are generated with different C++ namespaces: "core_api", "api", and
"shell::api" respectively.
This is a pointless distinction to make since as far as JS is concerned they
must all go on the window.chrome object, therefore namespace conflicts are
impossible. It just ends up adding code noise.
The only problem it solves is that all bundle compiles are generated to the
same name, "GeneratedSchemas" and "GeneratedFunctionRegistry". This patch
solves that a different way, by adding a JSON schema compiler option to give
those generated classes a prefix such that they are "GeneratedSchemas",
"ChromeGeneratedSchemas", and "ShellGeneratedSchemas" respectively.
This lets us to a global substitution from "core_api" to just "api".
R=rockot@chromium.org, dpranke@chromium.org
TBR=ben@chromium.org
Review URL: https://codereview.chromium.org/1226353004
Cr-Original-Commit-Position: refs/heads/master@{#340119}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: e58e6223146f09405229146fce6c1bfe6b71e4ce
2015-07-23 21:27:22 +03:00
|
|
|
"--bundle-name=" + invoker.bundle_name,
|
gn format //build
A starting point for doing all of src, and adding a PRESUBMIT.
Includes https://codereview.chromium.org/772663002/ and https://codereview.chromium.org/770053002/.
I haven't pushed new binaries yet.
Generated via:
> cd build
> git ls-files *.gn *.gni | sed -e "s/^/@..\\\\out\\\\Debug\\\\gn format --in-place /" >x.bat && x.bat
The only things that I don't love in the current output are:
1. Turning
args = [
"--depfile", rebase_path(depfile, root_build_dir),
"--android-sdk-tools", rebased_android_sdk_build_tools,
"--dex-path", rebased_output,
]
into:
args = [
"--depfile",
rebase_path(depfile, root_build_dir),
"--android-sdk-tools",
rebased_android_sdk_build_tools,
"--dex-path",
rebased_output,
]
The heuristic for this isn't trivial though, and it also affects e.g. '-Xclang' in cflags, as well
as assignments to temporaries that are later assigned to args.
2. Turning single line
if (defined(invoker.inputs)) { inputs = invoker.inputs }
into
if (defined(invoker.inputs)) {
inputs = invoker.inputs
}
This could be argued to be an improvement, but as it's very boilerplate-y perhaps an exception to
allow single line in this case is worthwhile. I think there was discussion of new syntax for this
case too, something like "inputs ?= invoker.inputs" maybe.
In both cases, I think it's worthwhile to get formatting turned on, and then go back and special
case these if we decide it's worthwhile.
R=brettw@chromium.org
BUG=348474
Review URL: https://codereview.chromium.org/766573003
Cr-Original-Commit-Position: refs/heads/master@{#306305}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: b199254f481c5db36d56e83fce40594b06d2b81f
2014-12-02 03:25:20 +03:00
|
|
|
"--generator=cpp-bundle-registration",
|
2015-05-27 22:41:42 +03:00
|
|
|
"--impl-dir=$gen_child_dir",
|
gn format //build
A starting point for doing all of src, and adding a PRESUBMIT.
Includes https://codereview.chromium.org/772663002/ and https://codereview.chromium.org/770053002/.
I haven't pushed new binaries yet.
Generated via:
> cd build
> git ls-files *.gn *.gni | sed -e "s/^/@..\\\\out\\\\Debug\\\\gn format --in-place /" >x.bat && x.bat
The only things that I don't love in the current output are:
1. Turning
args = [
"--depfile", rebase_path(depfile, root_build_dir),
"--android-sdk-tools", rebased_android_sdk_build_tools,
"--dex-path", rebased_output,
]
into:
args = [
"--depfile",
rebase_path(depfile, root_build_dir),
"--android-sdk-tools",
rebased_android_sdk_build_tools,
"--dex-path",
rebased_output,
]
The heuristic for this isn't trivial though, and it also affects e.g. '-Xclang' in cflags, as well
as assignments to temporaries that are later assigned to args.
2. Turning single line
if (defined(invoker.inputs)) { inputs = invoker.inputs }
into
if (defined(invoker.inputs)) {
inputs = invoker.inputs
}
This could be argued to be an improvement, but as it's very boilerplate-y perhaps an exception to
allow single line in this case is worthwhile. I think there was discussion of new syntax for this
case too, something like "inputs ?= invoker.inputs" maybe.
In both cases, I think it's worthwhile to get formatting turned on, and then go back and special
case these if we decide it's worthwhile.
R=brettw@chromium.org
BUG=348474
Review URL: https://codereview.chromium.org/766573003
Cr-Original-Commit-Position: refs/heads/master@{#306305}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: b199254f481c5db36d56e83fce40594b06d2b81f
2014-12-02 03:25:20 +03:00
|
|
|
"--include-rules=$schema_include_rules",
|
2015-05-02 03:42:59 +03:00
|
|
|
] + rebase_path(invoker.sources, root_build_dir) +
|
gn format //build
A starting point for doing all of src, and adding a PRESUBMIT.
Includes https://codereview.chromium.org/772663002/ and https://codereview.chromium.org/770053002/.
I haven't pushed new binaries yet.
Generated via:
> cd build
> git ls-files *.gn *.gni | sed -e "s/^/@..\\\\out\\\\Debug\\\\gn format --in-place /" >x.bat && x.bat
The only things that I don't love in the current output are:
1. Turning
args = [
"--depfile", rebase_path(depfile, root_build_dir),
"--android-sdk-tools", rebased_android_sdk_build_tools,
"--dex-path", rebased_output,
]
into:
args = [
"--depfile",
rebase_path(depfile, root_build_dir),
"--android-sdk-tools",
rebased_android_sdk_build_tools,
"--dex-path",
rebased_output,
]
The heuristic for this isn't trivial though, and it also affects e.g. '-Xclang' in cflags, as well
as assignments to temporaries that are later assigned to args.
2. Turning single line
if (defined(invoker.inputs)) { inputs = invoker.inputs }
into
if (defined(invoker.inputs)) {
inputs = invoker.inputs
}
This could be argued to be an improvement, but as it's very boilerplate-y perhaps an exception to
allow single line in this case is worthwhile. I think there was discussion of new syntax for this
case too, something like "inputs ?= invoker.inputs" maybe.
In both cases, I think it's worthwhile to get formatting turned on, and then go back and special
case these if we decide it's worthwhile.
R=brettw@chromium.org
BUG=348474
Review URL: https://codereview.chromium.org/766573003
Cr-Original-Commit-Position: refs/heads/master@{#306305}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: b199254f481c5db36d56e83fce40594b06d2b81f
2014-12-02 03:25:20 +03:00
|
|
|
rebase_path(uncompiled_sources, root_build_dir)
|
2014-10-01 02:26:52 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-02 03:42:59 +03:00
|
|
|
# Compute the contents of the library/source set.
|
|
|
|
lib_sources = invoker.sources
|
|
|
|
lib_deps = []
|
|
|
|
lib_public_deps = []
|
|
|
|
lib_extra_configs = []
|
2015-07-28 21:24:42 +03:00
|
|
|
if (defined(invoker.configs)) {
|
|
|
|
lib_extra_configs += invoker.configs
|
|
|
|
}
|
2014-10-01 02:26:52 +04:00
|
|
|
|
2015-05-02 03:42:59 +03:00
|
|
|
if (schemas) {
|
|
|
|
lib_sources += get_target_outputs(":$schema_generator_name")
|
|
|
|
lib_public_deps += [ ":$schema_generator_name" ]
|
|
|
|
lib_deps += [ "//tools/json_schema_compiler:generated_api_util" ]
|
|
|
|
lib_extra_configs += [ "//build/config/compiler:no_size_t_to_int_warning" ]
|
|
|
|
}
|
2014-10-01 02:26:52 +04:00
|
|
|
|
2015-05-02 03:42:59 +03:00
|
|
|
if (bundle) {
|
|
|
|
lib_sources += get_target_outputs(":$bundle_generator_schema_name")
|
|
|
|
lib_deps += [ ":$bundle_generator_schema_name" ]
|
|
|
|
}
|
2014-10-01 02:26:52 +04:00
|
|
|
|
2015-05-02 03:42:59 +03:00
|
|
|
if (bundle_registration) {
|
|
|
|
lib_sources += get_target_outputs(":$bundle_generator_registration_name")
|
|
|
|
lib_deps += [ ":$bundle_generator_registration_name" ]
|
|
|
|
}
|
2014-10-01 02:26:52 +04:00
|
|
|
|
2015-05-02 03:42:59 +03:00
|
|
|
if (defined(invoker.deps)) {
|
|
|
|
lib_deps += invoker.deps
|
|
|
|
}
|
|
|
|
|
|
|
|
# Generate either a static library or a source set.
|
|
|
|
if (defined(invoker.generate_static_library) &&
|
|
|
|
invoker.generate_static_library) {
|
|
|
|
static_library(target_name) {
|
|
|
|
sources = lib_sources
|
|
|
|
deps = lib_deps
|
|
|
|
public_deps = lib_public_deps
|
|
|
|
configs += lib_extra_configs
|
|
|
|
public_configs = [ ":$generated_config_name" ]
|
2014-10-01 02:26:52 +04:00
|
|
|
|
2015-05-02 03:42:59 +03:00
|
|
|
if (defined(invoker.visibility)) {
|
|
|
|
visibility = invoker.visibility
|
|
|
|
}
|
|
|
|
if (defined(invoker.output_name)) {
|
|
|
|
output_name = invoker.output_name
|
|
|
|
}
|
2014-10-01 02:26:52 +04:00
|
|
|
}
|
2015-05-02 03:42:59 +03:00
|
|
|
} else {
|
|
|
|
source_set(target_name) {
|
|
|
|
sources = lib_sources
|
|
|
|
deps = lib_deps
|
|
|
|
public_deps = lib_public_deps
|
|
|
|
configs += lib_extra_configs
|
|
|
|
public_configs = [ ":$generated_config_name" ]
|
|
|
|
|
|
|
|
if (defined(invoker.visibility)) {
|
|
|
|
visibility = invoker.visibility
|
|
|
|
}
|
|
|
|
if (defined(invoker.output_name)) {
|
|
|
|
output_name = invoker.output_name
|
|
|
|
}
|
2014-10-01 02:26:52 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|