OLD | NEW |
---|---|
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 """Takes the output of the build step and zips the distributable package. | 6 """Takes the output of the build step and zips the distributable package. |
7 | 7 |
8 This script assumes the build script has been run to compile the add-in. | 8 This script assumes the build script has been run to compile the add-in. |
9 It zips up all files required for the add-in installation and places the | 9 It zips up all files required for the add-in installation and places the |
10 result in out/NativeClientVSAddin.zip | 10 result in out/NativeClientVSAddin.zip |
11 """ | 11 """ |
12 | 12 |
13 import codecs | 13 import codecs |
noelallen1
2012/09/18 23:05:23
Do you still need this?
| |
14 import os | 14 import os |
15 import re | 15 import re |
16 import fileinput | 16 import fileinput |
17 import win32api | 17 import win32api |
18 import shutil | 18 import shutil |
19 import zipfile | 19 import zipfile |
20 | 20 |
21 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) | 21 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) |
22 | 22 |
23 # Root output directory. | 23 # Root output directory. |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
93 ls = info['FileVersionLS'] | 93 ls = info['FileVersionLS'] |
94 version = "[%i.%i.%i.%i]" % ( | 94 version = "[%i.%i.%i.%i]" % ( |
95 win32api.HIWORD(ms), win32api.LOWORD(ms), | 95 win32api.HIWORD(ms), win32api.LOWORD(ms), |
96 win32api.HIWORD(ls), win32api.LOWORD(ls)) | 96 win32api.HIWORD(ls), win32api.LOWORD(ls)) |
97 print "\nNaCl VS Add-in Build version: %s\n" % (version) | 97 print "\nNaCl VS Add-in Build version: %s\n" % (version) |
98 | 98 |
99 metadata_filename = os.path.basename(ADDIN_METADATA) | 99 metadata_filename = os.path.basename(ADDIN_METADATA) |
100 modified_file = os.path.join(ASSEMBLY_DIRECTORY, metadata_filename) | 100 modified_file = os.path.join(ASSEMBLY_DIRECTORY, metadata_filename) |
101 | 101 |
102 # Copy the metadata file to new location and modify the version info. | 102 # Copy the metadata file to new location and modify the version info. |
103 with codecs.open(ADDIN_METADATA, 'r', encoding='utf-16') as source_file: | 103 with open(ADDIN_METADATA, 'r') as source_file: |
104 with codecs.open(modified_file, 'w', encoding='utf-16') as dest_file: | 104 with open(modified_file, 'w') as dest_file: |
105 for line in source_file: | 105 for line in source_file: |
106 dest_file.write(line.replace("[REPLACE_ADDIN_VERSION]", version)) | 106 dest_file.write(line.replace("[REPLACE_ADDIN_VERSION]", version)) |
107 | 107 |
108 zip_file.write(modified_file, metadata_filename, zipfile.ZIP_DEFLATED) | 108 zip_file.write(modified_file, metadata_filename, zipfile.ZIP_DEFLATED) |
109 | 109 |
110 | 110 |
111 def main(): | 111 def main(): |
112 # Zip the package. | 112 # Zip the package. |
113 out_file = zipfile.ZipFile(OUTPUT_NAME, 'w') | 113 out_file = zipfile.ZipFile(OUTPUT_NAME, 'w') |
114 for source_dest in FILE_LIST: | 114 for source_dest in FILE_LIST: |
115 file_name = os.path.basename(source_dest[0]) | 115 file_name = os.path.basename(source_dest[0]) |
116 dest = os.path.join(source_dest[1], file_name) | 116 dest = os.path.join(source_dest[1], file_name) |
117 out_file.write(source_dest[0], dest, zipfile.ZIP_DEFLATED) | 117 out_file.write(source_dest[0], dest, zipfile.ZIP_DEFLATED) |
118 AddFolderToZip(RESOURCE_DIRECTORY, out_file) | 118 AddFolderToZip(RESOURCE_DIRECTORY, out_file) |
119 AddVersionModifiedAddinFile(out_file) | 119 AddVersionModifiedAddinFile(out_file) |
120 out_file.close() | 120 out_file.close() |
121 | 121 |
122 | 122 |
123 if __name__ == '__main__': | 123 if __name__ == '__main__': |
124 main() | 124 main() |
OLD | NEW |