summaryrefslogtreecommitdiffstats
path: root/build/json_schema_compile.gypi
diff options
context:
space:
mode:
authorcalamity@chromium.org <calamity@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-27 07:29:48 +0000
committercalamity@chromium.org <calamity@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-27 07:29:48 +0000
commit15f08dde26dbb02c8e4441492ab967cb48fcd4e4 (patch)
tree28f8e2f7e038575d9ac47873829e4792fc1ebb38 /build/json_schema_compile.gypi
parent195a0a026bc7a3916705fdf9a2a8c029d1cce9f2 (diff)
downloadchromium_src-15f08dde26dbb02c8e4441492ab967cb48fcd4e4.zip
chromium_src-15f08dde26dbb02c8e4441492ab967cb48fcd4e4.tar.gz
chromium_src-15f08dde26dbb02c8e4441492ab967cb48fcd4e4.tar.bz2
Code generation for extensions api
This is a preliminary code review for a code generator. The tool's purpose is to generate the tedious serialization code that needs to be written when defining a new extensions api. It generates from the json files in chrome/common/extensions/api. As an example usage, chrome/browser/extensions/extension_permissions_api.cc has been changed to use a class generated from permissions.json. The tool has been integrated into the build system and generates compiling and working code (for permissions.json at least) BUG= TEST= Review URL: http://codereview.chromium.org/9114036 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@119405 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'build/json_schema_compile.gypi')
-rw-r--r--build/json_schema_compile.gypi59
1 files changed, 59 insertions, 0 deletions
diff --git a/build/json_schema_compile.gypi b/build/json_schema_compile.gypi
new file mode 100644
index 0000000..940e65c
--- /dev/null
+++ b/build/json_schema_compile.gypi
@@ -0,0 +1,59 @@
+# Copyright (c) 2012 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.
+
+{
+ 'variables': {
+ # When including this gypi, the following variables must be set:
+ # json_schema_files: an array of json files that comprise the api model.
+ # cc_dir: path to generated files
+ # root_namespace: the C++ namespace that all generated files go under
+ 'api_gen_dir': '<(DEPTH)/tools/json_schema_compiler',
+ 'api_gen': '<(api_gen_dir)/compiler.py',
+ },
+ 'rules': [
+ {
+ 'rule_name': 'genapi',
+ 'extension': 'json',
+ 'inputs': [
+ '<(api_gen_dir)/code.py',
+ '<(api_gen_dir)/compiler.py',
+ '<(api_gen_dir)/model.py',
+ '<(api_gen_dir)/cc_generator.py',
+ '<(api_gen_dir)/h_generator.py',
+ '<(api_gen_dir)/cpp_type_generator.py',
+ '<@(json_schema_files)',
+ ],
+ 'outputs': [
+ '<(SHARED_INTERMEDIATE_DIR)/<(cc_dir)/<(RULE_INPUT_ROOT).cc',
+ '<(SHARED_INTERMEDIATE_DIR)/<(cc_dir)/<(RULE_INPUT_ROOT).h',
+ ],
+ 'action': [
+ 'python',
+ '<(api_gen)',
+ '<(RULE_INPUT_PATH)',
+ '--root=<(DEPTH)',
+ '--destdir=<(SHARED_INTERMEDIATE_DIR)',
+ '--namespace=<(root_namespace)',
+ '<@(json_schema_files)',
+ ],
+ 'message': 'Generating C++ code from <(RULE_INPUT_PATH) jsons',
+ 'process_outputs_as_sources': 1,
+ },
+ ],
+ 'include_dirs': [
+ '<(SHARED_INTERMEDIATE_DIR)',
+ '<(DEPTH)',
+ ],
+ 'dependencies':[
+ '<(DEPTH)/tools/json_schema_compiler/api_gen_util.gyp:api_gen_util',
+ ],
+ 'direct_dependent_settings': {
+ 'include_dirs': [
+ '<(SHARED_INTERMEDIATE_DIR)',
+ ]
+ },
+ # This target exports a hard dependency because it generates header
+ # files.
+ 'hard_dependency': 1,
+}