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

Side by Side Diff: native_client_sdk/src/build_tools/build_sdk.py

Issue 720233003: [NaCl SDK] Convert python scripts from optparse to argparse. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 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 """Entry point for both build and try bots. 6 """Entry point for both build and try bots.
7 7
8 This script is invoked from XXX, usually without arguments 8 This script is invoked from XXX, usually without arguments
9 to package an SDK. It automatically determines whether 9 to package an SDK. It automatically determines whether
10 this SDK is for mac, win, linux. 10 this SDK is for mac, win, linux.
11 11
12 The script inspects the following environment variables: 12 The script inspects the following environment variables:
13 13
14 BUILDBOT_BUILDERNAME to determine whether the script is run locally 14 BUILDBOT_BUILDERNAME to determine whether the script is run locally
15 and whether it should upload an SDK to file storage (GSTORE) 15 and whether it should upload an SDK to file storage (GSTORE)
16 """ 16 """
17 17
18 # pylint: disable=W0621 18 # pylint: disable=W0621
19 19
20 # std python includes 20 # std python includes
21 import argparse
21 import datetime 22 import datetime
22 import glob 23 import glob
23 import optparse
24 import os 24 import os
25 import re 25 import re
26 import sys 26 import sys
27 27
28 if sys.version_info < (2, 6, 0): 28 if sys.version_info < (2, 6, 0):
29 sys.stderr.write("python 2.6 or later is required run this script\n") 29 sys.stderr.write("python 2.6 or later is required run this script\n")
30 sys.exit(1) 30 sys.exit(1)
31 31
32 # local includes 32 # local includes
33 import buildbot_common 33 import buildbot_common
(...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 """Build the projects found in src/gonacl_appengine/src""" 888 """Build the projects found in src/gonacl_appengine/src"""
889 buildbot_common.BuildStep('Build GoNaCl AppEngine Projects') 889 buildbot_common.BuildStep('Build GoNaCl AppEngine Projects')
890 cmd = ['make', 'upload', 'REVISION=%s' % chrome_revision] 890 cmd = ['make', 'upload', 'REVISION=%s' % chrome_revision]
891 env = dict(os.environ) 891 env = dict(os.environ)
892 env['NACL_SDK_ROOT'] = pepperdir 892 env['NACL_SDK_ROOT'] = pepperdir
893 env['NACLPORTS_NO_ANNOTATE'] = "1" 893 env['NACLPORTS_NO_ANNOTATE'] = "1"
894 buildbot_common.Run(cmd, env=env, cwd=GONACL_APPENGINE_SRC_DIR) 894 buildbot_common.Run(cmd, env=env, cwd=GONACL_APPENGINE_SRC_DIR)
895 895
896 896
897 def main(args): 897 def main(args):
898 parser = optparse.OptionParser(description=__doc__) 898 parser = argparse.ArgumentParser(description=__doc__)
899 parser.add_option('--nacl-tree-path', 899 parser.add_argument('--nacl-tree-path',
900 help='Path to native client tree for bionic build.', 900 help='Path to native client tree for bionic build.',
901 dest='nacl_tree_path') 901 dest='nacl_tree_path')
902 parser.add_option('--qemu', help='Add qemu for ARM.', 902 parser.add_argument('--qemu', help='Add qemu for ARM.',
903 action='store_true') 903 action='store_true')
904 parser.add_option('--bionic', help='Add bionic build.', 904 parser.add_argument('--bionic', help='Add bionic build.',
905 action='store_true') 905 action='store_true')
906 parser.add_option('--tar', help='Force the tar step.', 906 parser.add_argument('--tar', help='Force the tar step.',
907 action='store_true') 907 action='store_true')
908 parser.add_option('--archive', help='Force the archive step.', 908 parser.add_argument('--archive', help='Force the archive step.',
909 action='store_true') 909 action='store_true')
910 parser.add_option('--release', help='PPAPI release version.', 910 parser.add_argument('--release', help='PPAPI release version.',
911 dest='release', default=None) 911 dest='release', default=None)
912 parser.add_option('--build-ports', 912 parser.add_argument('--build-ports',
913 help='Build naclport bundle.', action='store_true') 913 help='Build naclport bundle.', action='store_true')
914 parser.add_option('--build-app-engine', 914 parser.add_argument('--build-app-engine',
915 help='Build AppEngine demos.', action='store_true') 915 help='Build AppEngine demos.', action='store_true')
916 parser.add_option('--experimental', 916 parser.add_argument('--experimental',
917 help='build experimental examples and libraries', action='store_true', 917 help='build experimental examples and libraries', action='store_true',
918 dest='build_experimental') 918 dest='build_experimental')
919 parser.add_option('--skip-toolchain', help='Skip toolchain untar', 919 parser.add_argument('--skip-toolchain', help='Skip toolchain untar',
920 action='store_true') 920 action='store_true')
921 parser.add_option('--mac-sdk', 921 parser.add_argument('--mac-sdk',
922 help='Set the mac-sdk (e.g. 10.6) to use when building with ninja.') 922 help='Set the mac-sdk (e.g. 10.6) to use when building with ninja.')
923 parser.add_option('--no-arm-trusted', action='store_true', 923 parser.add_argument('--no-arm-trusted', action='store_true',
924 help='Disable building of ARM trusted components (sel_ldr, etc).') 924 help='Disable building of ARM trusted components (sel_ldr, etc).')
925 925
926 # To setup bash completion for this command first install optcomplete 926 # To setup bash completion for this command first install optcomplete
927 # and then add this line to your .bashrc: 927 # and then add this line to your .bashrc:
928 # complete -F _optcomplete build_sdk.py 928 # complete -F _optcomplete build_sdk.py
929 try: 929 try:
930 import optcomplete 930 import optcomplete
931 optcomplete.autocomplete(parser) 931 optcomplete.autocomplete(parser)
932 except ImportError: 932 except ImportError:
933 pass 933 pass
934 934
935 global options 935 global options
936 options, args = parser.parse_args(args[1:]) 936 options = parser.parse_args(args)
937 if args:
938 parser.error("Unexpected arguments: %s" % str(args))
939 937
940 if options.nacl_tree_path: 938 if options.nacl_tree_path:
941 options.bionic = True 939 options.bionic = True
942 toolchain_build = os.path.join(options.nacl_tree_path, 'toolchain_build') 940 toolchain_build = os.path.join(options.nacl_tree_path, 'toolchain_build')
943 print 'WARNING: Building bionic toolchain from NaCl checkout.' 941 print 'WARNING: Building bionic toolchain from NaCl checkout.'
944 print 'This option builds bionic from the sources currently in the' 942 print 'This option builds bionic from the sources currently in the'
945 print 'provided NativeClient checkout, and the results instead of ' 943 print 'provided NativeClient checkout, and the results instead of '
946 print 'downloading a toolchain from the builder. This may result in a' 944 print 'downloading a toolchain from the builder. This may result in a'
947 print 'NaCl SDK that can not run on ToT chrome.' 945 print 'NaCl SDK that can not run on ToT chrome.'
948 print 'NOTE: To clobber you will need to run toolchain_build_bionic.py' 946 print 'NOTE: To clobber you will need to run toolchain_build_bionic.py'
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 if options.build_ports and getos.GetPlatform() == 'linux': 1059 if options.build_ports and getos.GetPlatform() == 'linux':
1062 BuildStepArchiveBundle('naclports', pepper_ver, chrome_revision, 1060 BuildStepArchiveBundle('naclports', pepper_ver, chrome_revision,
1063 nacl_revision, ports_tarfile) 1061 nacl_revision, ports_tarfile)
1064 BuildStepArchiveSDKTools() 1062 BuildStepArchiveSDKTools()
1065 1063
1066 return 0 1064 return 0
1067 1065
1068 1066
1069 if __name__ == '__main__': 1067 if __name__ == '__main__':
1070 try: 1068 try:
1071 sys.exit(main(sys.argv)) 1069 sys.exit(main(sys.argv[1:]))
1072 except KeyboardInterrupt: 1070 except KeyboardInterrupt:
1073 buildbot_common.ErrorExit('build_sdk: interrupted') 1071 buildbot_common.ErrorExit('build_sdk: interrupted')
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698