Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(453)

Side by Side Diff: chrome/tools/build/generate_policy_source.py

Issue 8680018: Fix python scripts in src/chrome/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: copyright Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/tools/build/appid.py ('k') | chrome/tools/build/win/create_installer_archive.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/env python
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 '''python %prog [options] platform chromium_os_flag template 6 '''python %prog [options] platform chromium_os_flag template
7 7
8 platform specifies which platform source is being generated for 8 platform specifies which platform source is being generated for
9 and can be one of (win, mac, linux) 9 and can be one of (win, mac, linux)
10 chromium_os_flag should be 1 if this is a Chromium OS build 10 chromium_os_flag should be 1 if this is a Chromium OS build
11 template is the path to a .json policy template file.''' 11 template is the path to a .json policy template file.'''
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 metavar="FILE"); 44 metavar="FILE");
45 parser.add_option("--ppd", "--protobuf-decoder", dest="decoder_path", 45 parser.add_option("--ppd", "--protobuf-decoder", dest="decoder_path",
46 help="generate C++ code decoding the policy protobuf", 46 help="generate C++ code decoding the policy protobuf",
47 metavar="FILE"); 47 metavar="FILE");
48 48
49 (opts, args) = parser.parse_args(); 49 (opts, args) = parser.parse_args();
50 50
51 if len(args) != 3: 51 if len(args) != 3:
52 print "exactly platform, chromium_os flag and input file must be specified." 52 print "exactly platform, chromium_os flag and input file must be specified."
53 parser.print_help() 53 parser.print_help()
54 sys.exit(2) 54 return 2
55 template_file_contents = _LoadJSONFile(args[2]); 55 template_file_contents = _LoadJSONFile(args[2]);
56 if opts.header_path is not None: 56 if opts.header_path is not None:
57 _WritePolicyConstantHeader(template_file_contents, args, opts); 57 _WritePolicyConstantHeader(template_file_contents, args, opts);
58 if opts.source_path is not None: 58 if opts.source_path is not None:
59 _WritePolicyConstantSource(template_file_contents, args, opts); 59 _WritePolicyConstantSource(template_file_contents, args, opts);
60 if opts.type_path is not None: 60 if opts.type_path is not None:
61 _WritePolicyTypeEnumerationHeader(template_file_contents, args, opts); 61 _WritePolicyTypeEnumerationHeader(template_file_contents, args, opts);
62 if opts.proto_path is not None: 62 if opts.proto_path is not None:
63 _WriteProtobuf(template_file_contents, args, opts.proto_path) 63 _WriteProtobuf(template_file_contents, args, opts.proto_path)
64 if opts.decoder_path is not None: 64 if opts.decoder_path is not None:
65 _WriteProtobufParser(template_file_contents, args, opts.decoder_path) 65 _WriteProtobufParser(template_file_contents, args, opts.decoder_path)
66 return 0
66 67
67 68
68 #------------------ shared helpers ---------------------------------# 69 #------------------ shared helpers ---------------------------------#
69 def _OutputGeneratedWarningForC(f, template_file_path): 70 def _OutputGeneratedWarningForC(f, template_file_path):
70 f.write('//\n' 71 f.write('//\n'
71 '// DO NOT MODIFY THIS FILE DIRECTLY!\n' 72 '// DO NOT MODIFY THIS FILE DIRECTLY!\n'
72 '// IT IS GENERATED BY generate_policy_source.py\n' 73 '// IT IS GENERATED BY generate_policy_source.py\n'
73 '// FROM ' + template_file_path + '\n' 74 '// FROM ' + template_file_path + '\n'
74 '//\n\n') 75 '//\n\n')
75 76
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 f.write(CPP_HEAD) 456 f.write(CPP_HEAD)
456 for policy in template_file_contents['policy_definitions']: 457 for policy in template_file_contents['policy_definitions']:
457 if policy['type'] == 'group': 458 if policy['type'] == 'group':
458 for sub_policy in policy['policies']: 459 for sub_policy in policy['policies']:
459 _WritePolicyCode(f, sub_policy) 460 _WritePolicyCode(f, sub_policy)
460 else: 461 else:
461 _WritePolicyCode(f, policy) 462 _WritePolicyCode(f, policy)
462 f.write(CPP_FOOT) 463 f.write(CPP_FOOT)
463 464
464 465
465 #------------------ main() -----------------------------------------#
466 if __name__ == '__main__': 466 if __name__ == '__main__':
467 main(); 467 sys.exit(main())
OLDNEW
« no previous file with comments | « chrome/tools/build/appid.py ('k') | chrome/tools/build/win/create_installer_archive.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698