| Index: chrome/tools/build/generate_policy_source.py
|
| diff --git a/chrome/tools/build/generate_policy_source.py b/chrome/tools/build/generate_policy_source.py
|
| index 95234398eaf6a03a374f4701786771ba9b8dda86..9cef5ea1bc700059d0982c783a0bd2cd3684056e 100644
|
| --- a/chrome/tools/build/generate_policy_source.py
|
| +++ b/chrome/tools/build/generate_policy_source.py
|
| @@ -3,10 +3,11 @@
|
| # Use of this source code is governed by a BSD-style license that can be
|
| # found in the LICENSE file.
|
|
|
| -'''python %prog [options] platform template
|
| +'''python %prog [options] platform chromium_os_flag template
|
|
|
| platform specifies which platform source is being generated for
|
| - and can be one of (win, mac, linux).
|
| + and can be one of (win, mac, linux)
|
| +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
|
| @@ -47,11 +48,11 @@ def main():
|
|
|
| (opts, args) = parser.parse_args();
|
|
|
| - if len(args) < 2 or len(args) > 2:
|
| - print "exactly one platform and input file must be specified."
|
| + if len(args) != 3:
|
| + print "exactly platform, chromium_os flag and input file must be specified."
|
| parser.print_help()
|
| sys.exit(2)
|
| - template_file_contents = _LoadJSONFile(args[1]);
|
| + template_file_contents = _LoadJSONFile(args[2]);
|
| if opts.header_path is not None:
|
| _WritePolicyConstantHeader(template_file_contents, args, opts);
|
| if opts.source_path is not None:
|
| @@ -80,7 +81,7 @@ def _GetPolicyDetails(policy):
|
| print "Unknown policy type for %s: %s" % (policy['name'], policy['type'])
|
| sys.exit(3)
|
| # platforms is a list of "chrome", "chrome_os" and/or "chrome_frame".
|
| - platforms = [ x.split('.')[0].split(':')[0] for x in policy['supported_on'] ]
|
| + platforms = [ x.split(':')[0] for x in policy['supported_on'] ]
|
| is_device_policy = policy.get('device_only', False)
|
| return (policy['name'], TYPE_MAP[policy['type']], platforms, is_device_policy)
|
|
|
| @@ -104,17 +105,8 @@ def _GetPolicyNameList(template_file_contents):
|
|
|
|
|
| def _GetChromePolicyList(template_file_contents):
|
| - return [(name, vtype) for (name, vtype, platforms, is_device_only)
|
| - in _GetPolicyList(template_file_contents)
|
| - if 'chrome' in platforms and not is_device_only]
|
| -
|
| -
|
| -def _GetChromeOSPolicyList(template_file_contents):
|
| - return [(name, vtype) for (name, vtype, platforms, is_device_only)
|
| - in _GetPolicyList(template_file_contents)
|
| - if 'chrome_os' in platforms
|
| - and not 'chrome' in platforms
|
| - and not is_device_only]
|
| + return [(name, platforms, vtype) for (name, vtype, platforms, is_device_only)
|
| + in _GetPolicyList(template_file_contents)]
|
|
|
|
|
| def _LoadJSONFile(json_file):
|
| @@ -125,9 +117,9 @@ def _LoadJSONFile(json_file):
|
|
|
| #------------------ policy constants header ------------------------#
|
| def _WritePolicyConstantHeader(template_file_contents, args, opts):
|
| - platform = args[0];
|
| + os = args[0];
|
| with open(opts.header_path, "w") as f:
|
| - _OutputGeneratedWarningForC(f, args[1])
|
| + _OutputGeneratedWarningForC(f, args[2])
|
|
|
| f.write('#ifndef CHROME_COMMON_POLICY_CONSTANTS_H_\n'
|
| '#define CHROME_COMMON_POLICY_CONSTANTS_H_\n'
|
| @@ -138,7 +130,7 @@ def _WritePolicyConstantHeader(template_file_contents, args, opts):
|
| '\n'
|
| 'namespace policy {\n\n')
|
|
|
| - if platform == "win":
|
| + if os == "win":
|
| f.write('// The windows registry path where policy configuration '
|
| 'resides.\n'
|
| 'extern const wchar_t kRegistrySubKey[];\n\n')
|
| @@ -172,9 +164,17 @@ def _WritePolicyConstantHeader(template_file_contents, args, opts):
|
|
|
| #------------------ policy constants source ------------------------#
|
| def _WritePolicyConstantSource(template_file_contents, args, opts):
|
| - platform = args[0];
|
| + os = args[0];
|
| + is_chromium_os = args[1] == "1"
|
| + platform = None
|
| + platform_wildcard = None
|
| + if is_chromium_os:
|
| + platform = 'chrome_os'
|
| + else:
|
| + platform = 'chrome.' + os.lower()
|
| + platform_wildcard = 'chrome.*'
|
| with open(opts.source_path, "w") as f:
|
| - _OutputGeneratedWarningForC(f, args[1])
|
| + _OutputGeneratedWarningForC(f, args[2])
|
|
|
| f.write('#include "base/basictypes.h"\n'
|
| '#include "base/logging.h"\n'
|
| @@ -185,13 +185,11 @@ def _WritePolicyConstantSource(template_file_contents, args, opts):
|
| f.write('namespace {\n\n')
|
|
|
| f.write('PolicyDefinitionList::Entry entries[] = {\n')
|
| - for (name, vtype) in _GetChromePolicyList(template_file_contents):
|
| - f.write(' { kPolicy%s, Value::%s, key::k%s },\n' % (name, vtype, name))
|
| - f.write('\n#if defined(OS_CHROMEOS)\n')
|
| - for (name, vtype) in _GetChromeOSPolicyList(template_file_contents):
|
| - f.write(' { kPolicy%s, Value::%s, key::k%s },\n' % (name, vtype, name))
|
| - f.write('#endif\n'
|
| - '};\n\n')
|
| + policy_list = _GetChromePolicyList(template_file_contents)
|
| + for (name, platforms, vtype) in policy_list:
|
| + if (platform in platforms) or (platform_wildcard in platforms):
|
| + f.write(' { kPolicy%s, Value::%s, key::k%s },\n' % (name, vtype, name))
|
| + f.write('};\n\n')
|
|
|
| f.write('PolicyDefinitionList chrome_policy_list = {\n'
|
| ' entries,\n'
|
| @@ -206,7 +204,7 @@ def _WritePolicyConstantSource(template_file_contents, args, opts):
|
|
|
| f.write('} // namespace\n\n')
|
|
|
| - if platform == "win":
|
| + if os == "win":
|
| f.write('#if defined(GOOGLE_CHROME_BUILD)\n'
|
| 'const wchar_t kRegistrySubKey[] = '
|
| 'L"' + CHROME_SUBKEY + '";\n'
|
|
|