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

Side by Side Diff: build/android/gyp/finalize_apk.py

Issue 1348533006: Make use of md5_check within finalize_apk.py (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@md5-check-with-outputs
Patch Set: rebase Created 5 years, 3 months 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
« no previous file with comments | « no previous file | no next file » | 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/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright 2013 The Chromium Authors. All rights reserved. 3 # Copyright 2013 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 """Signs and zipaligns APK. 6 """Signs and zipaligns APK.
7 7
8 """ 8 """
9 9
10 import optparse 10 import optparse
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 def AlignApk(zipalign_path, unaligned_path, final_path): 58 def AlignApk(zipalign_path, unaligned_path, final_path):
59 align_cmd = [ 59 align_cmd = [
60 zipalign_path, 60 zipalign_path,
61 '-f', '4', # 4 bytes 61 '-f', '4', # 4 bytes
62 unaligned_path, 62 unaligned_path,
63 final_path, 63 final_path,
64 ] 64 ]
65 build_utils.CheckOutput(align_cmd) 65 build_utils.CheckOutput(align_cmd)
66 66
67 67
68 def main(): 68 def main(args):
69 args = build_utils.ExpandFileArgs(args)
70
69 parser = optparse.OptionParser() 71 parser = optparse.OptionParser()
70 build_utils.AddDepfileOption(parser) 72 build_utils.AddDepfileOption(parser)
71 73
72 parser.add_option('--rezip-apk-jar-path', 74 parser.add_option('--rezip-apk-jar-path',
73 help='Path to the RezipApk jar file.') 75 help='Path to the RezipApk jar file.')
74 parser.add_option('--zipalign-path', help='Path to the zipalign tool.') 76 parser.add_option('--zipalign-path', help='Path to the zipalign tool.')
75 parser.add_option('--unsigned-apk-path', help='Path to input unsigned APK.') 77 parser.add_option('--unsigned-apk-path', help='Path to input unsigned APK.')
76 parser.add_option('--final-apk-path', 78 parser.add_option('--final-apk-path',
77 help='Path to output signed and aligned APK.') 79 help='Path to output signed and aligned APK.')
78 parser.add_option('--key-path', help='Path to keystore for signing.') 80 parser.add_option('--key-path', help='Path to keystore for signing.')
79 parser.add_option('--key-passwd', help='Keystore password') 81 parser.add_option('--key-passwd', help='Keystore password')
80 parser.add_option('--key-name', help='Keystore name') 82 parser.add_option('--key-name', help='Keystore name')
81 parser.add_option('--stamp', help='Path to touch on success.') 83 parser.add_option('--stamp', help='Path to touch on success.')
82 parser.add_option('--load-library-from-zip', type='int', 84 parser.add_option('--load-library-from-zip', type='int',
83 help='If non-zero, build the APK such that the library can be loaded ' + 85 help='If non-zero, build the APK such that the library can be loaded ' +
84 'directly from the zip file using the crazy linker. The library ' + 86 'directly from the zip file using the crazy linker. The library ' +
85 'will be renamed, uncompressed and page aligned.') 87 'will be renamed, uncompressed and page aligned.')
86 88
87 options, _ = parser.parse_args() 89 options, _ = parser.parse_args()
88 90
89 FinalizeApk(options) 91 input_paths = [
92 options.unsigned_apk_path,
93 options.key_path,
94 ]
90 95
91 if options.depfile: 96 if options.load_library_from_zip:
92 build_utils.WriteDepfile( 97 input_paths.append(options.rezip_apk_jar_path)
93 options.depfile, build_utils.GetPythonDependencies())
94 98
95 if options.stamp: 99 input_strings = [
96 build_utils.Touch(options.stamp) 100 options.load_library_from_zip,
101 options.key_name,
102 options.key_passwd,
103 ]
104
105 build_utils.CallAndWriteDepfileIfStale(
106 lambda: FinalizeApk(options),
107 options,
108 record_path=options.unsigned_apk_path + '.finalize.md5.stamp',
109 input_paths=input_paths,
110 input_strings=input_strings,
111 output_paths=[options.final_apk_path])
97 112
98 113
99 def FinalizeApk(options): 114 def FinalizeApk(options):
100 with tempfile.NamedTemporaryFile() as signed_apk_path_tmp, \ 115 with tempfile.NamedTemporaryFile() as signed_apk_path_tmp, \
101 tempfile.NamedTemporaryFile() as apk_to_sign_tmp: 116 tempfile.NamedTemporaryFile() as apk_to_sign_tmp:
102 117
103 if options.load_library_from_zip: 118 if options.load_library_from_zip:
104 # We alter the name of the library so that the Android Package Manager 119 # We alter the name of the library so that the Android Package Manager
105 # does not extract it into a separate file. This must be done before 120 # does not extract it into a separate file. This must be done before
106 # signing, as the filename is part of the signed manifest. At the same 121 # signing, as the filename is part of the signed manifest. At the same
(...skipping 15 matching lines...) Expand all
122 # order which means the library will be back at its page aligned location. 137 # order which means the library will be back at its page aligned location.
123 # This step also aligns uncompressed items to 4 bytes. 138 # This step also aligns uncompressed items to 4 bytes.
124 ReorderAndAlignApk( 139 ReorderAndAlignApk(
125 options.rezip_apk_jar_path, signed_apk_path, options.final_apk_path) 140 options.rezip_apk_jar_path, signed_apk_path, options.final_apk_path)
126 else: 141 else:
127 # Align uncompressed items to 4 bytes 142 # Align uncompressed items to 4 bytes
128 AlignApk(options.zipalign_path, signed_apk_path, options.final_apk_path) 143 AlignApk(options.zipalign_path, signed_apk_path, options.final_apk_path)
129 144
130 145
131 if __name__ == '__main__': 146 if __name__ == '__main__':
132 sys.exit(main()) 147 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698