summaryrefslogtreecommitdiff
path: root/cerbero
diff options
context:
space:
mode:
authorAndoni Morales Alastruey <ylatuya@gmail.com>2013-03-21 20:28:52 (GMT)
committerAndoni Morales Alastruey <ylatuya@gmail.com>2013-03-25 10:28:01 (GMT)
commit236f2cb53ef98374e8e1195db49763e8aa6d4747 (patch)
tree8cf23b8a1c4a6d9354266a14edbe88fe145746ba /cerbero
parentd33cb57c3a9de42423f750cfbdd584ce1c3503d8 (diff)
downloadcerbero-236f2cb53ef98374e8e1195db49763e8aa6d4747.tar.gz
cerbero-236f2cb53ef98374e8e1195db49763e8aa6d4747.tar.xz
packages:ios Improve iOS packaging
Create a real .pkg with productbuild, include only the static library, the header files and the templates and add a post install script to install the templates where XCode finds them
Diffstat (limited to 'cerbero')
-rw-r--r--cerbero/packages/osx/bundles.py1
-rw-r--r--cerbero/packages/osx/packager.py147
2 files changed, 82 insertions, 66 deletions
diff --git a/cerbero/packages/osx/bundles.py b/cerbero/packages/osx/bundles.py
index 8b3a245..450dbed 100644
--- a/cerbero/packages/osx/bundles.py
+++ b/cerbero/packages/osx/bundles.py
@@ -75,7 +75,6 @@ class BundlePackagerBase(PackagerBase):
shutil.copy(os.path.join(self.package.resources_postinstall),
os.path.join(resources, 'postinstall'))
packagebuild = PackageBuild()
- import pdb; pdb.set_trace()
packagebuild.create_package(root, self.package.identifier(),
self.package.version, self.title, output_file, install_dir,
resources)
diff --git a/cerbero/packages/osx/packager.py b/cerbero/packages/osx/packager.py
index 4ad6cda..93f0db7 100644
--- a/cerbero/packages/osx/packager.py
+++ b/cerbero/packages/osx/packager.py
@@ -405,89 +405,107 @@ class ApplicationPackage(PackagerBase):
shell.call(cmd)
return dmg_file
-class IOSFrameworkPackage(PackagerBase):
- def __init__(self, config, package, store):
- PackagerBase.__init__(self, config, package, store)
- self.packages = self.store.get_package_deps(package)
+
+class IOSPackage(ProductPackage, FrameworkrHeadersMixin):
+ '''
+ Creates an ios Framework package from a
+ L{cerbero.package.package.MetaPackage} using productbuild.
+
+ This platform only support static linking, so the final package
+ consists on a the framework library and the headers files.
+ The framework library is built merging all the static libraries
+ listed in this package and the headers are copied unversionned to
+ the 'Headers' directory of the framework bundle.
+ The product package will only contain the ios-framework package
+ '''
def pack(self, output_dir, devel=False, force=False, keep_temp=False):
PackagerBase.pack(self, output_dir, devel, force, keep_temp)
framework_name = self.package.ios_framework_library[0]
+ self._prepare_pack()
+ self.fw_path = os.path.join(self.tmp, '%s.framework' % framework_name)
+ os.mkdir(self.fw_path)
+
+ files = [os.path.join(self.config.prefix, x) for x in
+ self.package.all_files_list()]
+
+ version_dir = os.path.join(self.fw_path, 'Versions', self.package.sdk_version)
+ libname = os.path.join(version_dir, framework_name)
+ packager = self._create_framework_bundle_packager()
+ self._create_framework_bundle_layout(packager)
+ self._copy_templates(files)
+ self._copy_headers(files, version_dir)
+ self._create_framework_headers(self.config.prefix,
+ self.include_dirs, version_dir)
+ shutil.rmtree(os.path.join(version_dir, 'include'))
+ shutil.rmtree(os.path.join(version_dir, 'lib'))
+ self._create_merged_lib(libname, files)
+ self.package.packages = []
+ self.fw_path = self.tmp
+ self._create_framework_bundle_package(packager)
- self.include_dirs = PkgConfig.list_all_include_dirs()
- self.tmp = tempfile.mkdtemp()
- out_dir = self.fw_path = os.path.join(self.tmp, "%s.framework" % framework_name)
- shell.call ('mkdir -p %s' % self.fw_path, self.tmp)
- self._create_framework_bundle_package()
-
- root_dir = os.path.join(self.fw_path, "Versions", "Current")
-
- static_libs = []
-
- for p in self.packages:
- m.action(_("Creating package %s ") % p)
- packager = OSXPackage(self.config, p, self.store)
- try:
- files = packager.files_list(PackageType.DEVEL, force)
- except EmptyPackageError, e:
- files = []
- for f in files:
- #TODO merge together into common file copy routine
- in_path = os.path.join(self.config.prefix, f)
- if not os.path.exists(in_path):
- m.warning("File %s is missing and won't be added to the "
- "package" % in_path)
- continue
-
- if os.path.splitext(f)[-1] == '.a':
- static_libs.append(in_path) #libs are merged together later
-
- out_path = os.path.join(root_dir, f)
- odir = os.path.split(out_path)[0]
- if not os.path.exists(odir):
- os.makedirs(odir)
- shutil.copy(in_path, out_path)
+ paths = [self._create_product(PackageType.DEVEL)]
+ if not keep_temp:
+ shutil.rmtree(self.tmp)
+ return paths
- install_name = os.path.join(root_dir, 'lib', framework_name)
- self._create_merged_lib(install_name, static_libs)
+ def _copy_files (self, files, root):
+ for f in files:
+ out_path = f.replace(self.config.prefix, root)
+ out_dir = os.path.split(out_path)[0]
+ if not os.path.exists(out_dir):
+ os.makedirs(out_dir)
+ shutil.copy(f, out_path)
+
+ def _copy_templates(self, files):
+ templates_prefix = 'share/xcode/templates/ios'
+ templates = [x for x in files if templates_prefix in x]
+ for f in templates:
+ out_path = f.replace(self.config.prefix,
+ os.path.join(self.tmp, 'Templates'))
+ out_path = out_path.replace(templates_prefix, '')
+ out_dir = os.path.split(out_path)[0]
+ if not os.path.exists(out_dir):
+ os.makedirs(out_dir)
+ shutil.copy(f, out_path)
- #create <framework>/Versions/Current/<framework> file
- shell.call('cp %s %s' % (install_name, root_dir))
+ def _copy_headers(self, files, version_dir):
+ # Get the list of headers
+ incl_dir = os.path.join(self.config.prefix, 'include')
+ include_files = [os.path.join(incl_dir, x) for x in
+ os.listdir(incl_dir) if x.endswith('.h')]
+ for d in self.include_dirs:
+ include_files += [x for x in files if d in x]
+ self._copy_files (include_files, version_dir)
- _create_framework_headers(self.config.prefix, self.include_dirs, root_dir)
+ def _create_framework_bundle_packager(self):
+ m.action(_("Creating framework package"))
+ packager = FrameworkBundlePackager(self.package, 'ios-framework',
+ 'Framework Bundle',
+ '3ffe67c2-3421-411f-8287-e8faa892f853')
+ return packager
- return [None, self._create_dmg()]
+ def _create_merged_lib(self, libname, files):
+ # Get the list of static libraries
+ static_files = [x for x in files if x.endswith('.a')]
- def _create_merged_lib (self, install_name, libs_list):
- fwlib = StaticFrameworkLibrary(install_name, install_name, libs_list, self.config.target_arch)
+ fwlib = StaticFrameworkLibrary(libname, libname, static_files,
+ self.config.target_arch)
fwlib.use_pkgconfig = False
if self.config.target_arch == Architecture.UNIVERSAL:
fwlib.universal_archs = self.config.universal_archs
-
fwlib.create()
- def _create_dmg(self):
- dmg_file = os.path.join(self.output_dir, '%s-%s-ios-%s.dmg' % (
- self.package.name, self.package.version, self.config.target_arch))
- # Create Disk Image
- cmd = 'hdiutil create %s -volname %s -ov -srcfolder %s' % \
- (dmg_file, self.package.name, self.tmp)
- shell.call(cmd)
- return dmg_file
-
- def _create_framework_bundle_package(self):
- m.action(_("Creating framework package"))
- packager = FrameworkBundlePackager(self.package, 'ios-framework',
- 'Framework Bundle',
- '8E018220-CA82-4DFE-B409-248F8C841494')
- path = packager.create_bundle(self.fw_path)
- return path
-
class Packager(object):
def __new__(klass, config, package, store):
+ if config.target_platform == Platform.IOS:
+ if not isinstance(package, MetaPackage):
+ raise FatalError ("iOS platform only support packages",
+ "for MetaPackage")
+ return IOSPackage(config, package, store)
if isinstance(package, Package):
return OSXPackage(config, package, store)
elif isinstance(package, MetaPackage):
@@ -500,5 +518,4 @@ def register():
from cerbero.packages.packager import register_packager
from cerbero.config import Distro
register_packager(Distro.OS_X, Packager)
- register_packager(Distro.IOS, IOSFrameworkPackage)
-
+ register_packager(Distro.IOS, Packager)