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

Side by Side Diff: visual_studio/NativeClientVSAddIn/create_package.py

Issue 10831030: NaCl settings and completed install scripts. (Closed) Base URL: https://nativeclient-sdk.googlecode.com/svn/trunk/src
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
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 """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 os 13 import os
14 import zipfile 14 import zipfile
15 15
16 # Root output directory 16 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
17 BUILD_OUTPUT_DIRECTORY = "../../out/NativeClientVSAddIn/"
18 17
19 # Directory containing static installer resources 18 # Root output directory.
20 RESOURCE_DIRECTORY = "./InstallerResources" 19 BUILD_OUTPUT_DIRECTORY = os.path.join(
20 SCRIPT_DIR,
21 "../../out/NativeClientVSAddIn/")
21 22
22 # Directory that contains the build assemblies 23 # Directory containing static installer resources.
24 RESOURCE_DIRECTORY = os.path.join(SCRIPT_DIR, "InstallerResources/")
25
26 # Directory that contains the build assemblies.
23 ASSEMBLY_DIRECTORY = os.path.join(BUILD_OUTPUT_DIRECTORY, "Debug") 27 ASSEMBLY_DIRECTORY = os.path.join(BUILD_OUTPUT_DIRECTORY, "Debug")
24 28
25 # Base name of the final zip file 29 # Base name of the final zip file.
26 OUTPUT_NAME = os.path.join(BUILD_OUTPUT_DIRECTORY, "NativeClientVSAddIn.zip") 30 OUTPUT_NAME = os.path.join(BUILD_OUTPUT_DIRECTORY, "NativeClientVSAddIn.zip")
27 31
28 # List of paths to files to include in the zip file 32 # List of source/destination pairs to include in zip file.
29 FILE_LIST = [ 33 FILE_LIST = [
30 os.path.join(RESOURCE_DIRECTORY, 'NativeClientVSAddIn.AddIn'), 34 (os.path.join(ASSEMBLY_DIRECTORY, "NativeClientVSAddIn.dll"), ''),
31 os.path.join(RESOURCE_DIRECTORY, 'install.py'), 35 (os.path.join(ASSEMBLY_DIRECTORY, "NaCl.Build.CPPTasks.dll"), 'NaCl')]
32 os.path.join(ASSEMBLY_DIRECTORY, 'NativeClientVSAddIn.dll')] 36
37
38 def AddFolderToZip(path, zip_file):
39 """Adds an entire folder and sub folders to an open zipfile object.
40
41 The zip_file must already be open and it is not closed by this function.
42
43 Args:
44 path: Folder to add.
45 zipfile: Already open zip file.
46
47 Returns:
48 Nothing.
49 """
50 # Ensure the path ends in trailing slash.
51 path = path.rstrip("/\\") + "\\"
52 for dir_path, dir_names, files in os.walk(path):
53 for file in files:
54 read_path = os.path.join(dir_path, file)
55 zip_based_dir = dir_path[len(path):]
56 write_path = os.path.join(zip_based_dir, file)
57 zip_file.write(read_path, write_path, zipfile.ZIP_DEFLATED)
58
33 59
34 def main(): 60 def main():
35 # Zip the package 61 # Zip the package.
36 out_file = zipfile.ZipFile(OUTPUT_NAME, 'w') 62 out_file = zipfile.ZipFile(OUTPUT_NAME, 'w')
37 for file_path in FILE_LIST: 63 for source_dest in FILE_LIST:
38 out_file.write(file_path, os.path.basename(file_path), zipfile.ZIP_DEFLATED) 64 file_name = os.path.basename(source_dest[0])
65 dest = os.path.join(source_dest[1], file_name)
66 out_file.write(source_dest[0], dest, zipfile.ZIP_DEFLATED)
67 AddFolderToZip(RESOURCE_DIRECTORY, out_file)
39 out_file.close() 68 out_file.close()
40 69
70
41 if __name__ == '__main__': 71 if __name__ == '__main__':
42 main() 72 main()
OLDNEW
« no previous file with comments | « visual_studio/NativeClientVSAddIn/build.bat ('k') | visual_studio/NativeClientVSAddIn/developer_deploy.bat » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698