diff options
author | Andoni Morales Alastruey <ylatuya@gmail.com> | 2013-03-21 21:28:52 +0100 |
---|---|---|
committer | Andoni Morales Alastruey <ylatuya@gmail.com> | 2013-03-25 11:28:01 +0100 |
commit | 236f2cb53ef98374e8e1195db49763e8aa6d4747 (patch) | |
tree | 8cf23b8a1c4a6d9354266a14edbe88fe145746ba | |
parent | d33cb57c3a9de42423f750cfbdd584ce1c3503d8 (diff) |
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
-rw-r--r-- | cerbero/packages/osx/bundles.py | 1 | ||||
-rw-r--r-- | cerbero/packages/osx/packager.py | 147 | ||||
-rw-r--r-- | packages/gstreamer-core.package | 2 | ||||
-rw-r--r-- | packages/gstreamer-sdk/gstreamer-sdk.package | 6 | ||||
-rwxr-xr-x | packages/gstreamer-sdk/post_install_ios | 4 | ||||
-rw-r--r-- | recipes/gstreamer-ios-framework.recipe | 15 |
6 files changed, 92 insertions, 83 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) diff --git a/packages/gstreamer-core.package b/packages/gstreamer-core.package index abfed63..b4392db 100644 --- a/packages/gstreamer-core.package +++ b/packages/gstreamer-core.package @@ -25,6 +25,6 @@ class Package(package.Package): 'gst-plugins-good-static:plugins_core_devel', 'gst-plugins-bad-static:plugins_core_devel'] platform_files = { Platform.DARWIN: ['gstreamer-osx-framework'], - Platform.IOS: ['gstreamer-ios-framework'], + Platform.IOS: ['gstreamer-ios-templates'], Platform.ANDROID: ['gst-android'], } diff --git a/packages/gstreamer-sdk/gstreamer-sdk.package b/packages/gstreamer-sdk/gstreamer-sdk.package index 5257b63..8c15316 100644 --- a/packages/gstreamer-sdk/gstreamer-sdk.package +++ b/packages/gstreamer-sdk/gstreamer-sdk.package @@ -48,7 +48,9 @@ class SDKPackage(package.SDKPackage): install_dir = { Platform.WINDOWS: 'gstreamer-sdk', Platform.LINUX: '/opt/gst-sdk/', - Platform.DARWIN: '/Library/Frameworks/GStreamer.framework/'} + Platform.DARWIN: '/Library/Frameworks/GStreamer.framework/', + Platform.IOS: '/Library/Developer/GStreamer/iPhone.sdk'} + root_env_var = 'GSTREAMER_SDK_ROOT_%(arch)s' wix_upgrade_code = { PackageType.DEVEL: { @@ -70,3 +72,5 @@ class SDKPackage(package.SDKPackage): 'gtk+-2.0-python', 'snappy', 'gstreamer-dvd', 'gstreamer-tests'] self.packages = [ x for x in self.packages if x[0] not in p] + if self.config.target_platform == Platform.IOS: + self.resources_postinstall = 'post_install_ios' diff --git a/packages/gstreamer-sdk/post_install_ios b/packages/gstreamer-sdk/post_install_ios new file mode 100755 index 0000000..02c53af --- /dev/null +++ b/packages/gstreamer-sdk/post_install_ios @@ -0,0 +1,4 @@ +#!/bin/sh + +mkdir -p ~/Library/Developer/Xcode/Templates/ +cp -r ~/Library/Developer/GStreamer/iPhone.sdk/Templates/* ~/Library/Developer/Xcode/Templates/ diff --git a/recipes/gstreamer-ios-framework.recipe b/recipes/gstreamer-ios-framework.recipe deleted file mode 100644 index e584c16..0000000 --- a/recipes/gstreamer-ios-framework.recipe +++ /dev/null @@ -1,15 +0,0 @@ -# -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python - -from cerbero.ide.xcode.fwlib import StaticFrameworkLibrary - -class Recipe(recipe.Recipe): - name = 'gstreamer-ios-framework' - version = '0.1' - licenses = [License.LGPL] - stype = SourceType.CUSTOM - btype = BuildType.CUSTOM - deps = ['gstreamer-static', 'gst-plugins-base-static', - 'gst-plugins-good-static', 'gst-plugins-ugly-static', - 'gst-plugins-bad-static', 'gst-ffmpeg-static'] - - files_library = ['lib/GStreamer'] |