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 turns it into a compressed | 6 """Takes the output of the build step and turns it into a compressed |
7 archive ready for distribution. | 7 archive ready for distribution. |
8 | 8 |
9 This script assumes the build script has been run to compile the add-in. | 9 This script assumes the build script has been run to compile the add-in. |
10 It zips up all files required for the add-in installation and places the | 10 It zips up all files required for the add-in installation and places the |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
91 | 91 |
92 def AddVersionModifiedAddinFile(archive): | 92 def AddVersionModifiedAddinFile(archive): |
93 """Modifies the .AddIn file with the build version and adds to the zip. | 93 """Modifies the .AddIn file with the build version and adds to the zip. |
94 | 94 |
95 The version number is obtained from the NativeClientAddIn.dll assembly which | 95 The version number is obtained from the NativeClientAddIn.dll assembly which |
96 is built during the build process. | 96 is built during the build process. |
97 | 97 |
98 Args: | 98 Args: |
99 archive: Already open archive file. | 99 archive: Already open archive file. |
100 """ | 100 """ |
101 info = win32api.GetFileVersionInfo(ADDIN_ASSEMBLY, "\\") | 101 path = '\\VarFileInfo\\Translation' |
102 ms = info['FileVersionMS'] | 102 pairs = win32api.GetFileVersionInfo(ADDIN_ASSEMBLY, path) |
103 ls = info['FileVersionLS'] | 103 lang, codepage = pairs[0] |
104 version = "[%i.%i.%i.%i]" % ( | 104 path = u'\\StringFileInfo\\%04X%04X\\ProductVersion' % (lang, codepage) |
binji
2012/10/11 20:23:00
needs to be unicode string?
| |
105 win32api.HIWORD(ms), win32api.LOWORD(ms), | 105 prodVersion = win32api.GetFileVersionInfo(ADDIN_ASSEMBLY, path) |
106 win32api.HIWORD(ls), win32api.LOWORD(ls)) | 106 version = "[%s]" % prodVersion |
107 print "\nNaCl VS Add-in Build version: %s\n" % (version) | 107 print "\nNaCl VS Add-in Build version: %s\n" % (version) |
108 | 108 |
109 metadata_filename = os.path.basename(ADDIN_METADATA) | 109 metadata_filename = os.path.basename(ADDIN_METADATA) |
110 modified_file = join(ASSEMBLY_DIRECTORY, metadata_filename) | 110 modified_file = join(ASSEMBLY_DIRECTORY, metadata_filename) |
111 | 111 |
112 # Copy the metadata file to new location and modify the version info. | 112 # Copy the metadata file to new location and modify the version info. |
113 with open(ADDIN_METADATA, 'r') as source_file: | 113 with open(ADDIN_METADATA, 'r') as source_file: |
114 with open(modified_file, 'w') as dest_file: | 114 with open(modified_file, 'w') as dest_file: |
115 for line in source_file: | 115 for line in source_file: |
116 dest_file.write(line.replace("[REPLACE_ADDIN_VERSION]", version)) | 116 dest_file.write(line.replace("[REPLACE_ADDIN_VERSION]", version)) |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
159 open(destfile, "wb").write(data) | 159 open(destfile, "wb").write(data) |
160 | 160 |
161 AddFolderToArchive(join(BUILD_DIR, "NaCl32"), archive, "NaCl32") | 161 AddFolderToArchive(join(BUILD_DIR, "NaCl32"), archive, "NaCl32") |
162 | 162 |
163 AddVersionModifiedAddinFile(archive) | 163 AddVersionModifiedAddinFile(archive) |
164 archive.close() | 164 archive.close() |
165 | 165 |
166 | 166 |
167 if __name__ == '__main__': | 167 if __name__ == '__main__': |
168 main() | 168 main() |
OLD | NEW |