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
This commit is contained in:
Родитель
f53754d074
Коммит
7bf8f122f5
|
@ -31,6 +31,11 @@
|
|||
# bundle_registration [optional, default = false]
|
||||
# Boolean indicating if the API registration bundle files should be generated.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# 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
|
||||
|
@ -86,6 +91,7 @@ template("json_schema_api") {
|
|||
"$compiler_root/cc_generator.py",
|
||||
"$compiler_root/code.py",
|
||||
"$compiler_root/compiler.py",
|
||||
"$compiler_root/cpp_bundle_generator.py",
|
||||
"$compiler_root/cpp_generator.py",
|
||||
"$compiler_root/cpp_type_generator.py",
|
||||
"$compiler_root/cpp_util.py",
|
||||
|
@ -122,6 +128,9 @@ template("json_schema_api") {
|
|||
}
|
||||
|
||||
if (bundle) {
|
||||
assert(defined(invoker.bundle_name),
|
||||
"\"bundle_name\" must be defined for bundles")
|
||||
|
||||
uncompiled_sources = []
|
||||
if (defined(invoker.uncompiled_sources)) {
|
||||
uncompiled_sources = invoker.uncompiled_sources
|
||||
|
@ -139,6 +148,7 @@ template("json_schema_api") {
|
|||
"--root=" + rebase_path("//", root_build_dir),
|
||||
"--destdir=" + rebase_path(root_gen_dir, root_build_dir),
|
||||
"--namespace=$root_namespace",
|
||||
"--bundle-name=" + invoker.bundle_name,
|
||||
"--generator=cpp-bundle-schema",
|
||||
"--include-rules=$schema_include_rules",
|
||||
] + rebase_path(invoker.sources, root_build_dir) +
|
||||
|
@ -147,6 +157,9 @@ template("json_schema_api") {
|
|||
}
|
||||
|
||||
if (bundle_registration) {
|
||||
assert(defined(invoker.bundle_name),
|
||||
"\"bundle_name\" must be defined for bundle registrations")
|
||||
|
||||
uncompiled_sources = []
|
||||
if (defined(invoker.uncompiled_sources)) {
|
||||
uncompiled_sources = invoker.uncompiled_sources
|
||||
|
@ -171,6 +184,7 @@ template("json_schema_api") {
|
|||
"--root=" + rebase_path("//", root_build_dir),
|
||||
"--destdir=" + rebase_path(root_gen_dir, root_build_dir),
|
||||
"--namespace=$root_namespace",
|
||||
"--bundle-name=" + invoker.bundle_name,
|
||||
"--generator=cpp-bundle-registration",
|
||||
"--impl-dir=$gen_child_dir",
|
||||
"--include-rules=$schema_include_rules",
|
||||
|
|
|
@ -18,6 +18,10 @@
|
|||
# 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".
|
||||
# bundle_name:
|
||||
# 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.
|
||||
#
|
||||
# Functions and namespaces can be excluded by setting "nocompile" to true.
|
||||
# The default root path of API implementation sources is
|
||||
|
@ -57,6 +61,7 @@
|
|||
'--root=<(DEPTH)',
|
||||
'--destdir=<(SHARED_INTERMEDIATE_DIR)',
|
||||
'--namespace=<(root_namespace)',
|
||||
'--bundle-name=<(bundle_name)',
|
||||
'--generator=cpp-bundle-schema',
|
||||
'--include-rules=<(schema_include_rules)',
|
||||
'<@(schema_files)',
|
||||
|
|
|
@ -15,6 +15,10 @@
|
|||
# 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".
|
||||
# bundle_name:
|
||||
# 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.
|
||||
#
|
||||
# Functions and namespaces can be excluded by setting "nocompile" to true.
|
||||
'api_gen_dir': '<(DEPTH)/tools/json_schema_compiler',
|
||||
|
@ -52,6 +56,7 @@
|
|||
'--root=<(DEPTH)',
|
||||
'--destdir=<(SHARED_INTERMEDIATE_DIR)',
|
||||
'--namespace=<(root_namespace)',
|
||||
'--bundle-name=<(bundle_name)',
|
||||
'--generator=cpp-bundle-registration',
|
||||
'--impl-dir=<(impl_dir_)',
|
||||
'<@(schema_files)',
|
||||
|
|
Загрузка…
Ссылка в новой задаче