diff options
author | mnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-09 16:48:32 +0000 |
---|---|---|
committer | mnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-09 16:48:32 +0000 |
commit | 28ca4de42ee4eecaef6670118515533a3a44103f (patch) | |
tree | 0baf2c899988b496bb0cf5635277245bf0cf12cb /chrome/tools | |
parent | 736452c4c451baf100fe3452b45258e67f9b547e (diff) | |
download | chromium_src-28ca4de42ee4eecaef6670118515533a3a44103f.zip chromium_src-28ca4de42ee4eecaef6670118515533a3a44103f.tar.gz chromium_src-28ca4de42ee4eecaef6670118515533a3a44103f.tar.bz2 |
Include schema and platform support in ChromeSettingsProto comments.
This will help external consumers of the file make more sense of our
protobuf definitions.
BUG=None
TEST=Everything still compiles and passes tests.
R=joaodasilva@chromium.org
Review URL: https://chromiumcodereview.appspot.com/22673002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@216707 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/tools')
-rwxr-xr-x | chrome/tools/build/generate_policy_source.py | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/chrome/tools/build/generate_policy_source.py b/chrome/tools/build/generate_policy_source.py index 8998700..d88374d 100755 --- a/chrome/tools/build/generate_policy_source.py +++ b/chrome/tools/build/generate_policy_source.py @@ -11,6 +11,7 @@ chromium_os_flag should be 1 if this is a Chromium OS build template is the path to a .json policy template file.''' from __future__ import with_statement +import json from optparse import OptionParser import re import sys @@ -55,25 +56,32 @@ class PolicyDetails: if is_chromium_os: expected_platform = 'chrome_os' - wildcard_platform = None - elif os == 'android': - expected_platform = 'android' - wildcard_platform = None else: - expected_platform = 'chrome.' + os.lower() - wildcard_platform = 'chrome.*' - is_supported = False + expected_platform = os.lower() + + self.platforms = [] for platform, version in [ p.split(':') for p in policy['supported_on'] ]: - if (platform == expected_platform or platform == wildcard_platform) and \ - version.endswith('-'): - is_supported = True - self.is_supported = is_supported + if not version.endswith('-'): + continue + + if platform.startswith('chrome.'): + platform_sub = platform[7:] + if platform_sub == '*': + self.platforms.extend(['win', 'mac', 'linux']) + else: + self.platforms.append(platform_sub) + else: + self.platforms.append(platform) + + self.platforms.sort() + self.is_supported = expected_platform in self.platforms if not PolicyDetails.TYPE_MAP.has_key(policy['type']): raise NotImplementedError('Unknown policy type for %s: %s' % (policy['name'], policy['type'])) self.policy_type, self.protobuf_type, self.policy_protobuf_type = \ PolicyDetails.TYPE_MAP[policy['type']] + self.schema = policy['schema'] self.desc = '\n'.join( map(str.strip, @@ -397,6 +405,11 @@ def _WritePolicyProto(f, policy, fields): _OutputComment(f, '\nValid values:') for item in policy.items: _OutputComment(f, ' %s: %s' % (str(item.value), item.caption)) + if policy.policy_type == 'TYPE_DICTIONARY': + _OutputComment(f, '\nValue schema:\n%s' % + json.dumps(policy.schema, sort_keys=True, indent=4, + separators=(',', ': '))) + _OutputComment(f, '\nSupported on: %s' % ', '.join(policy.platforms)) f.write('message %sProto {\n' % policy.name) f.write(' optional PolicyOptions policy_options = 1;\n') f.write(' optional %s %s = 2;\n' % (policy.protobuf_type, policy.name)) |