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

Unified 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, 5 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 side-by-side diff with in-line comments
Download patch
Index: visual_studio/NativeClientVSAddIn/create_package.py
diff --git a/visual_studio/NativeClientVSAddIn/create_package.py b/visual_studio/NativeClientVSAddIn/create_package.py
index e5bc0f80afb43db667463bc7c2dfc4c20a09ca92..d0fdcc5378bba65a8824db1106fe6bc6b8d1353a 100644
--- a/visual_studio/NativeClientVSAddIn/create_package.py
+++ b/visual_studio/NativeClientVSAddIn/create_package.py
@@ -13,30 +13,60 @@ result in out/NativeClientVSAddin.zip
import os
import zipfile
-# Root output directory
-BUILD_OUTPUT_DIRECTORY = "../../out/NativeClientVSAddIn/"
+SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
-# Directory containing static installer resources
-RESOURCE_DIRECTORY = "./InstallerResources"
+# Root output directory.
+BUILD_OUTPUT_DIRECTORY = os.path.join(
+ SCRIPT_DIR,
+ "../../out/NativeClientVSAddIn/")
-# Directory that contains the build assemblies
+# Directory containing static installer resources.
+RESOURCE_DIRECTORY = os.path.join(SCRIPT_DIR, "InstallerResources/")
+
+# Directory that contains the build assemblies.
ASSEMBLY_DIRECTORY = os.path.join(BUILD_OUTPUT_DIRECTORY, "Debug")
-# Base name of the final zip file
+# Base name of the final zip file.
OUTPUT_NAME = os.path.join(BUILD_OUTPUT_DIRECTORY, "NativeClientVSAddIn.zip")
-# List of paths to files to include in the zip file
+# List of source/destination pairs to include in zip file.
FILE_LIST = [
- os.path.join(RESOURCE_DIRECTORY, 'NativeClientVSAddIn.AddIn'),
- os.path.join(RESOURCE_DIRECTORY, 'install.py'),
- os.path.join(ASSEMBLY_DIRECTORY, 'NativeClientVSAddIn.dll')]
+ (os.path.join(ASSEMBLY_DIRECTORY, 'NativeClientVSAddIn.dll'),
+ 'NativeClientVSAddIn.dll'),
binji 2012/07/26 23:32:17 Maybe change to (path, zip_dir) to remove duplicat
tysand 2012/07/28 01:13:11 I assume you mean have the source be the path to t
+ (os.path.join(ASSEMBLY_DIRECTORY, 'NaCl.Build.CPPTasks.dll'),
+ 'NaCl\\NaCl.Build.CPPTasks.dll')]
+
+
+def AddFolderToZip(path, zip_file):
+ """Adds an entire folder and sub folders to an open zipfile object.
+
+ The zip_file must already be open and it is not closed by this function.
+
+ Args:
+ path: Folder to add.
+ zipfile: Already open zip file.
+
+ Returns:
+ Nothing.
+ """
+ # Ensure the path ends in trailing slash.
+ path = path.rstrip("/\\") + "\\"
+ for dir_path, dir_names, files in os.walk(path):
+ for file in files:
+ read_path = os.path.join(dir_path, file)
+ zip_based_dir = dir_path[len(path):]
+ write_path = os.path.join(zip_based_dir, file)
+ zip_file.write(read_path, write_path, zipfile.ZIP_DEFLATED)
+
def main():
- # Zip the package
+ # Zip the package.
out_file = zipfile.ZipFile(OUTPUT_NAME, 'w')
- for file_path in FILE_LIST:
- out_file.write(file_path, os.path.basename(file_path), zipfile.ZIP_DEFLATED)
+ for source_dest in FILE_LIST:
+ out_file.write(source_dest[0], source_dest[1], zipfile.ZIP_DEFLATED)
+ AddFolderToZip(RESOURCE_DIRECTORY, out_file)
out_file.close()
+
if __name__ == '__main__':
main()

Powered by Google App Engine
This is Rietveld 408576698