| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   42 ADDIN_METADATA = join(RESOURCE_DIRECTORY, 'NativeClientVSAddIn.AddIn') |   42 ADDIN_METADATA = join(RESOURCE_DIRECTORY, 'NativeClientVSAddIn.AddIn') | 
|   43  |   43  | 
|   44 # AddIn dll file path. We will obtain our add-in version from this. |   44 # AddIn dll file path. We will obtain our add-in version from this. | 
|   45 ADDIN_ASSEMBLY = join(ASSEMBLY_DIRECTORY, 'NativeClientVSAddIn.dll') |   45 ADDIN_ASSEMBLY = join(ASSEMBLY_DIRECTORY, 'NativeClientVSAddIn.dll') | 
|   46  |   46  | 
|   47 # Regex list to exclude from the archive. If a file path matches any of the |   47 # Regex list to exclude from the archive. If a file path matches any of the | 
|   48 # expressions during a call to AddFolderToArchive it is excluded from the |   48 # expressions during a call to AddFolderToArchive it is excluded from the | 
|   49 # archive file. |   49 # archive file. | 
|   50 EXCLUDES = [ |   50 EXCLUDES = [ | 
|   51     r'\.svn', # Exclude .svn directories. |   51     r'\.svn', # Exclude .svn directories. | 
 |   52     r'\.swp', # Exclude .swp files. | 
|   52     r'examples\\.*\\chrome_data', |   53     r'examples\\.*\\chrome_data', | 
|   53     r'examples\\.*\\Debug', |   54     r'examples\\.*\\Debug', | 
|   54     r'examples\\.*\\newlib', |   55     r'examples\\.*\\newlib', | 
|   55     r'examples\\.*\\win', |   56     r'examples\\.*\\win', | 
|   56     r'examples\\.*\\ipch', |   57     r'examples\\.*\\ipch', | 
|   57     r'examples\\.*\\*.sdf', |   58     r'examples\\.*\\*.sdf', | 
|   58     r'examples\\.*\\*.suo', |   59     r'examples\\.*\\*.suo', | 
|   59     # Exclude .AddIn file for now since we need to modify it with version info. |   60     # Exclude .AddIn file for now since we need to modify it with version info. | 
|   60     re.escape(ADDIN_METADATA)] |   61     re.escape(ADDIN_METADATA)] | 
|   61  |   62  | 
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  120  |  121  | 
|  121   WriteFileToArchive(archive, modified_file, metadata_filename) |  122   WriteFileToArchive(archive, modified_file, metadata_filename) | 
|  122  |  123  | 
|  123  |  124  | 
|  124 def Error(msg): |  125 def Error(msg): | 
|  125   sys.stderr.write(msg + '\n') |  126   sys.stderr.write(msg + '\n') | 
|  126   sys.exit(1) |  127   sys.exit(1) | 
|  127  |  128  | 
|  128  |  129  | 
|  129 def WriteFileToArchive(archive, filename, archive_name): |  130 def WriteFileToArchive(archive, filename, archive_name): | 
 |  131   archive_name = join('vs_addin', archive_name) | 
 |  132   if archive_name.replace('\\', '/') in archive.getnames(): | 
 |  133     print 'Skipping: %s' % archive_name | 
 |  134     return | 
|  130   print 'Adding: %s' % archive_name |  135   print 'Adding: %s' % archive_name | 
|  131   archive_name = join('vs_addin', archive_name) |  | 
|  132   archive.add(filename, archive_name) |  136   archive.add(filename, archive_name) | 
|  133  |  137  | 
|  134  |  138  | 
 |  139 def CopyWithReplacement(src, dest, replacements): | 
 |  140   if os.path.exists(dest): | 
 |  141     shutil.rmtree(dest) | 
 |  142   os.makedirs(dest) | 
 |  143   src_basename = os.path.basename(src) | 
 |  144   dest_basename = os.path.basename(dest) | 
 |  145   for filename in os.listdir(src): | 
 |  146     srcfile = join(src, filename) | 
 |  147     # skip non-files, in particular .svn folders. | 
 |  148     if not os.path.isfile(srcfile): | 
 |  149       continue | 
 |  150     destfile = join(dest, filename.replace(src_basename, dest_basename)) | 
 |  151     with open(srcfile, "rb") as f: | 
 |  152       data = f.read() | 
 |  153       for pat, subst in replacements.iteritems(): | 
 |  154         data = data.replace(pat, subst) | 
 |  155     with open(destfile, "wb") as f: | 
 |  156       f.write(data) | 
 |  157  | 
 |  158  | 
|  135 def main(): |  159 def main(): | 
|  136   if not os.path.exists(BUILD_DIR): |  160   if not os.path.exists(BUILD_DIR): | 
|  137     Error("build dir not found: %s" % BUILD_DIR) |  161     Error("build dir not found: %s" % BUILD_DIR) | 
|  138  |  162  | 
|  139   archive = tarfile.open(OUTPUT_NAME, 'w:gz') |  163   archive = tarfile.open(OUTPUT_NAME, 'w:gz') | 
|  140   for source_dest in FILE_LIST: |  164   for source_dest in FILE_LIST: | 
|  141     file_name = os.path.basename(source_dest[0]) |  165     file_name = os.path.basename(source_dest[0]) | 
|  142     dest = join(source_dest[1], file_name) |  166     dest = join(source_dest[1], file_name) | 
|  143     WriteFileToArchive(archive, source_dest[0], dest) |  167     WriteFileToArchive(archive, source_dest[0], dest) | 
|  144  |  168  | 
|  145   AddFolderToArchive(RESOURCE_DIRECTORY, archive) |  169   AddFolderToArchive(RESOURCE_DIRECTORY, archive) | 
|  146  |  170  | 
|  147   # Duplicate the NaCl64 platform but rename it to NaCl32 |  171   # Duplicate the NaCl64 platform but rename it to NaCl32 | 
|  148   src64 = join(RESOURCE_DIRECTORY, 'NaCl64') |  172   src64 = join(RESOURCE_DIRECTORY, 'NaCl64') | 
|  149   dest32 = join(BUILD_DIR, 'NaCl32') |  | 
|  150   if os.path.exists(dest32): |  | 
|  151     shutil.rmtree(dest32) |  | 
|  152   os.makedirs(dest32) |  | 
|  153   for filename in os.listdir(src64): |  | 
|  154     srcfile = join(src64, filename) |  | 
|  155     # skip non-files, in particular .svn folders. |  | 
|  156     if not os.path.isfile(srcfile): |  | 
|  157       continue |  | 
|  158     destfile = join(dest32, filename.replace('NaCl64', 'NaCl32')) |  | 
|  159     data = open(srcfile, "rb").read() |  | 
|  160     data = data.replace("x86_64", "i686") |  | 
|  161     data = data.replace("64", "32") |  | 
|  162     open(destfile, "wb").write(data) |  | 
|  163  |  173  | 
|  164   AddFolderToArchive(join(BUILD_DIR, "NaCl32"), archive, "NaCl32") |  174   dest = join(BUILD_DIR, 'NaCl32') | 
 |  175   CopyWithReplacement(src64, dest, {'x86_64': 'i686', '64': '32'}) | 
 |  176   AddFolderToArchive(dest, archive, "NaCl32") | 
 |  177  | 
 |  178   replacements = { | 
 |  179       'NaCl64': 'PNaCl', | 
 |  180       'x86_64': 'i686', | 
 |  181       '64': '32', | 
 |  182       '.nexe': '.pexe', | 
 |  183       'nacl_link.xml': 'pnacl_link.xml', | 
 |  184       '$(ProjectName)_$(PlatformArchitecture)': '$(ProjectName)', | 
 |  185   } | 
 |  186  | 
 |  187   dest = join(BUILD_DIR, 'PNaCl') | 
 |  188   CopyWithReplacement(src64, dest, replacements) | 
 |  189   AddFolderToArchive(dest, archive, "PNaCl") | 
|  165  |  190  | 
|  166   AddVersionModifiedAddinFile(archive) |  191   AddVersionModifiedAddinFile(archive) | 
|  167   archive.close() |  192   archive.close() | 
|  168  |  193  | 
|  169  |  194  | 
|  170 if __name__ == '__main__': |  195 if __name__ == '__main__': | 
|  171   main() |  196   main() | 
| OLD | NEW |