[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [35670] trunk/blender: CMake package_archive target to create a .zip/.tar.bz2 package on mac/unix ,

Brecht Van Lommel brechtvanlommel at pandora.be
Mon Mar 21 17:42:21 CET 2011


Revision: 35670
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=35670
Author:   blendix
Date:     2011-03-21 16:42:21 +0000 (Mon, 21 Mar 2011)
Log Message:
-----------
CMake package_archive target to create a .zip/.tar.bz2 package on mac/unix,
to be used by buildbot.

Modified Paths:
--------------
    trunk/blender/GNUmakefile
    trunk/blender/build_files/cmake/packaging.cmake

Added Paths:
-----------
    trunk/blender/build_files/package_spec/build_archive.py

Modified: trunk/blender/GNUmakefile
===================================================================
--- trunk/blender/GNUmakefile	2011-03-21 12:57:05 UTC (rev 35669)
+++ trunk/blender/GNUmakefile	2011-03-21 16:42:21 UTC (rev 35670)
@@ -90,6 +90,10 @@
 package_pacman:
 	cd build_files/package_spec/pacman ; MAKEFLAGS="-j$(NPROCS)" makepkg --asroot
 
+package_archive:
+	cd $(BUILD_DIR) ; make -s package_archive
+	@echo archive in "$(BUILD_DIR)/release"
+
 # forward build targets
 test:
 	cd $(BUILD_DIR) ; ctest . --output-on-failure

Modified: trunk/blender/build_files/cmake/packaging.cmake
===================================================================
--- trunk/blender/build_files/cmake/packaging.cmake	2011-03-21 12:57:05 UTC (rev 35669)
+++ trunk/blender/build_files/cmake/packaging.cmake	2011-03-21 16:42:21 UTC (rev 35670)
@@ -51,7 +51,35 @@
 
 	# Libraries are bundled directly
 	set(CPACK_COMPONENT_LIBRARIES_HIDDEN TRUE)
-endif(APPLE)
+endif()
 
 set(CPACK_PACKAGE_EXECUTABLES "blender")
 include(CPack)
+
+# Target for build_archive.py script, to automatically pass along
+# version, revision, platform, build directory
+macro(add_package_archive packagename extension)
+	set(build_archive python ${CMAKE_SOURCE_DIR}/build_files/package_spec/build_archive.py)
+	set(package_output ${CMAKE_BINARY_DIR}/release/${packagename}.${extension})
+
+	add_custom_target(package_archive DEPENDS ${package_output})
+
+	add_custom_command(
+		OUTPUT ${package_output}
+		COMMAND ${build_archive} ${packagename} ${extension} bin release
+		WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
+endmacro()
+
+if(APPLE)
+	add_package_archive(
+		"blender-${BLENDER_VERSION}-r${BUILD_REV}-OSX-${CMAKE_OSX_ARCHITECTURES}"
+		"zip")
+elseif(UNIX)
+	# platform name could be tweaked, to include glibc, and ensure processor is correct (i386 vs i686)
+	string(TOLOWER ${CMAKE_SYSTEM_NAME} PACKAGE_SYSTEM_NAME)
+
+	add_package_archive(
+		"blender-${BLENDER_VERSION}-r${BUILD_REV}-${PACKAGE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}"
+		"tar.bz2")
+endif()
+

Added: trunk/blender/build_files/package_spec/build_archive.py
===================================================================
--- trunk/blender/build_files/package_spec/build_archive.py	                        (rev 0)
+++ trunk/blender/build_files/package_spec/build_archive.py	2011-03-21 16:42:21 UTC (rev 35670)
@@ -0,0 +1,69 @@
+#!/usr/bin/python
+
+import os
+import shutil
+import subprocess
+import sys
+
+# todo:
+# strip executables
+
+# get parameters
+if len(sys.argv) < 5:
+	sys.stderr.write('Excepted arguments: ./build_archive.py name extension install_dir output_dir')
+	sys.exit(1)
+
+package_name = sys.argv[1]
+extension = sys.argv[2]
+install_dir = sys.argv[3]
+output_dir = sys.argv[4]
+
+package_archive = os.path.join(output_dir, package_name + '.' + extension)
+package_dir = package_name
+
+# remove existing package with the same name
+try:
+	if os.path.exists(package_archive):
+		os.remove(package_archive)
+	if os.path.exists(package_dir):
+		shutil.rmtree(package_dir)
+except:
+	sys.stderr.write('Failed to clean up old package files: ' + sys.exc_info()[0] + '\n')
+	sys.exit(1)
+
+# create temporary package dir
+try:
+	shutil.copytree(install_dir, package_dir)
+
+	for f in os.listdir(package_dir):
+		if f.startswith('makes'):
+			os.remove(os.path.join(package_dir, f))
+except:
+	sys.stderr.write('Failed to copy install directory: ' + sys.exc_info()[0] + '\n')
+	sys.exit(1)
+
+# create archive
+try:
+	if not os.path.exists(output_dir):
+		os.mkdir(output_dir)
+
+	if extension == 'zip':
+		archive_cmd = ['zip', '-9', '-r', package_archive, package_dir]
+	elif extension == 'tar.bz2':
+		archive_cmd = ['tar', 'cjf', package_archive, package_dir]
+	else:
+		sys.stderr.write('Unknown archive extension: ' + extension)
+		sys.exit(-1)
+
+	subprocess.call(archive_cmd)
+except:
+	sys.stderr.write('Failed to create package archive: ' + sys.exc_info()[0] + '\n')
+	sys.exit(1)
+
+# empty temporary package dir
+try:
+	shutil.rmtree(package_dir)
+except:
+	sys.stderr.write('Failed to clean up package directory: ' + sys.exc_info()[0] + '\n')
+	sys.exit(1)
+


Property changes on: trunk/blender/build_files/package_spec/build_archive.py
___________________________________________________________________
Added: svn:executable
   + *




More information about the Bf-blender-cvs mailing list