diff options
author | Thibault Saunier <thibault.saunier@collabora.com> | 2013-01-21 11:19:29 -0300 |
---|---|---|
committer | Andoni Morales Alastruey <ylatuya@gmail.com> | 2013-02-22 22:22:39 +0100 |
commit | 5dbecff03922ef0ee326e8a8dbc5dc1b313a1459 (patch) | |
tree | 3b0706e7888299dce607c233e8230beb7a1ce153 | |
parent | 8a153a3d8057a9c316e3b159b512f34efcbbffa8 (diff) |
Add support to iOS
-rw-r--r-- | cerbero/bootstrap/bootstraper.py | 3 | ||||
-rw-r--r-- | cerbero/bootstrap/ios.py | 38 | ||||
-rw-r--r-- | cerbero/build/filesprovider.py | 2 | ||||
-rw-r--r-- | cerbero/enums.py | 3 | ||||
-rw-r--r-- | config/cross-ios-arm7.cbc | 8 | ||||
-rw-r--r-- | config/cross-ios-x86.cbc | 8 | ||||
-rw-r--r-- | config/ios.config | 67 | ||||
-rw-r--r-- | recipes/bzip2.recipe | 9 | ||||
-rw-r--r-- | recipes/fribidi.recipe | 2 | ||||
-rw-r--r-- | recipes/glib.recipe | 27 | ||||
-rw-r--r-- | recipes/libffi.recipe | 5 | ||||
-rw-r--r-- | recipes/libogg.recipe | 4 | ||||
-rw-r--r-- | recipes/libvpx.recipe | 7 | ||||
-rw-r--r-- | recipes/libxml2.recipe | 2 | ||||
-rw-r--r-- | recipes/soundtouch.recipe | 2 | ||||
-rw-r--r-- | recipes/zlib.recipe | 7 |
16 files changed, 187 insertions, 7 deletions
diff --git a/cerbero/bootstrap/bootstraper.py b/cerbero/bootstrap/bootstraper.py index 01e7f22..4ed3af8 100644 --- a/cerbero/bootstrap/bootstraper.py +++ b/cerbero/bootstrap/bootstraper.py @@ -67,9 +67,10 @@ class Bootstraper (object): return bs -from cerbero.bootstrap import linux, windows, android, osx +from cerbero.bootstrap import linux, windows, android, osx, ios linux.register_all() windows.register_all() android.register_all() osx.register_all() +ios.register_all() diff --git a/cerbero/bootstrap/ios.py b/cerbero/bootstrap/ios.py new file mode 100644 index 0000000..d23705f --- /dev/null +++ b/cerbero/bootstrap/ios.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python +# +# ios.py +# +# Copyright (C) 2013 Thibault Saunier <thibaul.saunier@collabora.com> +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this program; if not, write to the +# Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. + +from cerbero.bootstrap import BootstraperBase +from cerbero.bootstrap.bootstraper import register_bootstraper +from cerbero.config import Distro + + +class IOSBootstraper (BootstraperBase): + def start(self): + # FIXME: enable it when buildbots are properly configured + return + + +def register_all(): + register_bootstraper(Distro.IOS, IOSBootstraper) diff --git a/cerbero/build/filesprovider.py b/cerbero/build/filesprovider.py index d13566a..362b2bc 100644 --- a/cerbero/build/filesprovider.py +++ b/cerbero/build/filesprovider.py @@ -43,6 +43,8 @@ class FilesProvider(object): Platform.ANDROID: {'bext': '', 'sext': '.so.*', 'sdir': 'lib', 'mext': '.so', 'smext': '.a', 'pext': '.so', 'srext': '.so'}, Platform.DARWIN: {'bext': '', 'sext': '.*.dylib', 'sdir': 'lib', + 'mext': '.so', 'smext': '.a', 'pext': '.so', 'srext': '.dylib'}, + Platform.IOS: {'bext': '', 'sext': '.*.dylib', 'sdir': 'lib', 'mext': '.so', 'smext': '.a', 'pext': '.so', 'srext': '.dylib'}} def __init__(self, config): diff --git a/cerbero/enums.py b/cerbero/enums.py index 0c5c21a..6c4e9a9 100644 --- a/cerbero/enums.py +++ b/cerbero/enums.py @@ -23,6 +23,7 @@ class Platform: WINDOWS = 'windows' DARWIN = 'darwin' ANDROID = 'android' + IOS = 'ios' class Architecture: @@ -42,6 +43,7 @@ class Distro: SUSE = 'suse' WINDOWS = 'windows' OS_X = 'osx' + IOS = 'ios' ANDROID = 'android' @@ -69,6 +71,7 @@ class DistroVersion: OS_X_LION = 'osx_lion' OS_X_SNOW_LEOPARD = 'osx_snow_leopard' OS_X_LEOPARD = 'osx_leopard' + IOS_6_0 = 'ios_6_0' ANDROID_GINGERBREAD = 'android_gingerbread' # API Level 9 ANDROID_ICE_CREAM_SANDWICH = 'android_ice_cream_sandwich' # API Level 14 ANDROID_JELLY_BEAN = 'android_jelly_bean' # API Level 16 diff --git a/config/cross-ios-arm7.cbc b/config/cross-ios-arm7.cbc new file mode 100644 index 0000000..93f1d76 --- /dev/null +++ b/config/cross-ios-arm7.cbc @@ -0,0 +1,8 @@ +from cerbero.config import Platform, Architecture, Distro, DistroVersion + +target_platform=Platform.IOS +target_arch=Architecture.ARMv7 +target_distro=Distro.IOS +target_distro_version=DistroVersion.IOS_6_0 +host='arm-apple-darwin' +platform='iPhoneOS' diff --git a/config/cross-ios-x86.cbc b/config/cross-ios-x86.cbc new file mode 100644 index 0000000..5b31f9b --- /dev/null +++ b/config/cross-ios-x86.cbc @@ -0,0 +1,8 @@ +from cerbero.config import Platform, Architecture, Distro, DistroVersion + +target_platform=Platform.IOS +target_arch=Architecture.X86 +target_distro=Distro.IOS +target_distro_version=DistroVersion.IOS_6_0 +host='i386-apple-darwin' +platform='iPhoneSimulator' diff --git a/config/ios.config b/config/ios.config new file mode 100644 index 0000000..754a376 --- /dev/null +++ b/config/ios.config @@ -0,0 +1,67 @@ +# This file contains the default configuration to compile for iPhoneOS +# platforms. It contains sensitive enviroment configuration that +# shouldn't be modified unless you know what you are doing. +# PLEASE, DO NOT EDIT THIS FILE + +import os +from cerbero.utils import shell +from cerbero.config import Architecture, DistroVersion + +# We don't want anything from macports detected in configure and +# used later. System libs are passed through the -isysroot option +allow_system_libs=False + +min_version='6.0' + +if target_distro_version == DistroVersion.IOS_6_0: + v = '6.0' + v1 = '60' +else: + raise FatalError("Distro version %s not supported" %(target_distro_version)) + +# For Xcode >= 4.3, the SDK is installed in a completely different path +# FIXME This has not been tested, we should check what is the iOS toolchain path +# for xcode 4.3 +sysroot = '/Developer/SDKs/%s%s.sdk' % (platform, v) +if not os.path.exists(sysroot): + iphone_platform = '/Applications/Xcode.app/Contents/Developer/Platforms/%s.platform/Developer' %platform + sysroot = os.path.join(iphone_platform, 'SDKs', '%s%s.sdk' %(platform, v)) + +ccache = use_ccache and 'ccache ' or '' +extra_cflags='' +if target_arch == Architecture.ARMv7: + str_arch = ' armv7' +elif target_arch == Architecture.ARM: + str_arch = ' armv6' +elif target_arch == Architecture.X86: + str_arch = ' i386 ' + extra_cflags='-D__IPHONE_OS_VERSION_MIN_REQUIRED=%s0000' %v1 +else: + raise FatalError("Arch not supported") + +# Toolchain environment +os.environ['CC']= os.path.join(iphone_platform, 'usr', 'bin', 'llvm-gcc-4.2') +os.environ['CFLAGS'] = '-arch %s -isysroot %s -miphoneos-version-min=%s %s' %(str_arch, sysroot, min_version, extra_cflags) +os.environ['LDFLAGS'] = '-arch %s -isysroot %s -Wl,-iphoneos_version_min,%s -Wl,-undefined,error -Wl,-headerpad_max_install_names' %(str_arch, sysroot, min_version) +os.environ['OBJC'] = os.environ['CC'] + +os.environ['CXX']= os.path.join(iphone_platform, 'usr', 'bin', 'llvm-g++-4.2') +os.environ['CPP']= os.path.join(iphone_platform, 'usr', 'bin', 'llvm-cpp-4.2') +os.environ['CXXPP']= os.environ['CPP'] +#os.environ['CPPFLAGS'] = '-arch armv7 -isysroot %s' %(sysroot) +os.environ['CXXFLAGS'] = os.environ['CFLAGS'] + + +if platform == "iPhoneOS": + simulator_headers = '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator%s.sdk/usr/include' % v + for missing_header in ["bzlib.h", "crt_externs.h"]: + missing_path = os.path.join(sysroot, "usr", "include", missing_header) + if not os.path.lexists(missing_path): + # FIXME This is not smart especially as we need to sudo + print "We need to create a syslink between %s and %s as they are missing in the device SDK" %(os.path.join(simulator_headers, missing_header), missing_path) + shell.call("sudo ln -s %s %s" %(os.path.join(simulator_headers, missing_header), missing_path)) + + +if use_ccache: + os.environ['CC'] += 'ccache gcc' + os.environ['CXX'] += 'ccache g++' diff --git a/recipes/bzip2.recipe b/recipes/bzip2.recipe index fe8bf83..b1ad933 100644 --- a/recipes/bzip2.recipe +++ b/recipes/bzip2.recipe @@ -14,7 +14,7 @@ class Recipe(recipe.Recipe): def prepare (self): self._remove_steps([BuildSteps.CONFIGURE]) extension = '' - if self.config.target_platform == Platform.DARWIN: + if self.config.target_platform in [Platform.DARWIN, Platform.IOS]: shared_makefile = 'Makefile-libbz2_dylib' elif self.config.target_platform == Platform.WINDOWS: shared_makefile = 'Makefile-libbz2_dll' @@ -35,3 +35,10 @@ class Recipe(recipe.Recipe): if os.path.exists (libbz2): os.remove (libbz2) os.symlink(os.path.join(libdir, 'libbz2.so.1.0.6'), libbz2) + elif self.config.target_platform == Platform.IOS: + # FIXME This is to workaround a build issue, trying to ld ti libbz2.so + try: + os.symlink(os.path.join (self.config.prefix, 'lib', 'libbz2.dylib'), + os.path.join (self.config.prefix, 'lib', 'libbz2.so')) + except OSError: + pass diff --git a/recipes/fribidi.recipe b/recipes/fribidi.recipe index f7deb2c..97539c7 100644 --- a/recipes/fribidi.recipe +++ b/recipes/fribidi.recipe @@ -12,3 +12,5 @@ class Recipe(recipe.Recipe): def prepare(self): if self.config.target_platform == Platform.ANDROID: self.autoreconf = True + elif self.config.target_platform == Platform.IOS: + self.autoreconf = True diff --git a/recipes/glib.recipe b/recipes/glib.recipe index 7d81115..4e7cead 100644 --- a/recipes/glib.recipe +++ b/recipes/glib.recipe @@ -22,6 +22,7 @@ class Recipe(recipe.Recipe): can_use_configure_cache = False platform_deps = {Platform.WINDOWS: ['libiconv', 'gettext'], Platform.DARWIN: ['libiconv', 'gettext'], + Platform.IOS: ['libiconv', 'gettext'], Platform.ANDROID: ['libiconv', 'gettext']} files_libs = [ @@ -31,6 +32,7 @@ class Recipe(recipe.Recipe): platform_files_schemas = { Platform.WINDOWS: ['share/glib-2.0/schemas'], Platform.DARWIN: ['share/glib-2.0/schemas'], + Platform.IOS: ['share/glib-2.0/schemas'], } #FIXME: Fill it when needed #files_gio = ['lib/gio/modules'] @@ -55,6 +57,7 @@ class Recipe(recipe.Recipe): Platform.WINDOWS: ['lib/pkgconfig/gio-windows-2.0.pc', 'include/gio-win32-2.0'], Platform.LINUX: ['lib/pkgconfig/gio-unix-2.0.pc', 'include/gio-unix-2.0'], Platform.DARWIN: ['lib/pkgconfig/gio-unix-2.0.pc', 'include/gio-unix-2.0'], + Platform.IOS: ['lib/pkgconfig/gio-unix-2.0.pc', 'include/gio-unix-2.0'], } files_lang = ['glib20'] @@ -77,13 +80,16 @@ class Recipe(recipe.Recipe): self.make = '%s private_LDFLAGS=""' % self.make elif self.config.target_platform == Platform.WINDOWS: self.configure_options = '--with-libiconv=gnu' - elif self.config.target_platform == Platform.DARWIN: + elif self.config.target_platform in [Platform.DARWIN, Platform.IOS]: arch = self.config.target_arch if arch == Architecture.X86: arch = 'i386' - self.files_devel.append( - os.path.join('lib', 'glib-2.0', 'include', arch, 'glibconfig.h')) + self.files_devel.append(os.path.join('lib', 'glib-2.0', 'include', arch, 'glibconfig.h')) self.config_sh = 'CFLAGS="$CFLAGS -DHAVE_STRNDUP" ./configure' + if self.config.target_platform == Platform.IOS: + self.autoreconf = True + # Disable mac OS X specifics + self.configure_options += ' --disable-carbon --enable-dtrace=no --disable-modular-tests --disable-cocoa' elif self.config.target_platform == Platform.LINUX: if self.config.target_distro == Distro.DEBIAN and self.config.target_distro_version in [DistroVersion.DEBIAN_SQUEEZE, DistroVersion.UBUNTU_LUCID, DistroVersion.UBUNTU_MAVERICK]: self.config_sh = 'CFLAGS="%s" ./configure' % self._gio_flags('/usr/lib/gio/modules/', None, True) @@ -114,6 +120,21 @@ class Recipe(recipe.Recipe): from cerbero.errors import FatalError raise FatalError(_("Add specific for other Linux distributions here")) + def configure(self): + if self.config.target_platform == Platform.IOS: + # Use a cache file specific to the GLib to make cross compilation possible + cache = os.path.join(self.build_dir, ".glib.configure.cache") + if not os.path.exists(cache): + writer = open(cache, 'w') + writer.write("glib_cv_stack_grows=no\n" + "glib_cv_uscore=yes\n" + "ac_cv_func_posix_getpwuid_r=yes\n" + "ac_cv_func_posix_getgrgid_r=yes\n" + "gt_cv_c_wchar_t=no") + writer.close() + self.configure_options += ' --cache-file=%s' % cache + super(recipe.Recipe, self).configure() + def post_install(self): import shutil if self.config.target_platform == Platform.WINDOWS: diff --git a/recipes/libffi.recipe b/recipes/libffi.recipe index f47d445..1a733be 100644 --- a/recipes/libffi.recipe +++ b/recipes/libffi.recipe @@ -11,13 +11,16 @@ class Recipe(recipe.Recipe): files_devel = ['lib/libffi-3.0.11', 'lib/pkgconfig/libffi.pc'] def prepare(self): - if self.config.target_platform == Platform.DARWIN: + if self.config.target_platform in [Platform.DARWIN, Platform.IOS]: + self.autoreconf = False if self.config.target_arch == Architecture.X86_64: dir = 'x86_64-apple-darwin*' elif self.config.target_arch == Architecture.X86: dir = 'i386-apple-darwin*' elif self.config.target_arch == Architecture.PPC: dir = 'powerpc-apple-darwin*' + elif self.config.target_arch == Architecture.ARMv7: + dir = 'arm-apple-darwin*' self.make = 'make -C %s' % dir self.make_install = 'make -C %s install' % dir diff --git a/recipes/libogg.recipe b/recipes/libogg.recipe index 3743783..c3de19f 100644 --- a/recipes/libogg.recipe +++ b/recipes/libogg.recipe @@ -8,3 +8,7 @@ class Recipe(recipe.Recipe): files_libs = ['libogg'] files_devel = ['include/ogg', 'lib/pkgconfig/ogg.pc'] + + def prepare(self): + if self.config.target_platform == Platform.IOS: + self.autoreconf = True diff --git a/recipes/libvpx.recipe b/recipes/libvpx.recipe index a06fede..66f3447 100644 --- a/recipes/libvpx.recipe +++ b/recipes/libvpx.recipe @@ -42,7 +42,12 @@ class Recipe(recipe.Recipe): platform = 'darwin10' if self.config.target_arch == Architecture.PPC: platform = 'darwin9' - + elif self.config.target_platform == Platform.IOS: + platform = 'darwin' + if self.config.target_arch == Architecture.ARM: + arch = 'armv6' + elif self.config.target_arch == Architecture.ARMv7: + arch = 'armv7' elif self.config.target_platform == Platform.WINDOWS: self.config_sh = 'LD=$CC ./configure' if self.config.target_arch == Architecture.X86_64: diff --git a/recipes/libxml2.recipe b/recipes/libxml2.recipe index cc1babf..3ef8bb8 100644 --- a/recipes/libxml2.recipe +++ b/recipes/libxml2.recipe @@ -20,3 +20,5 @@ class Recipe(recipe.Recipe): self.configure_options = '--without-threads' elif self.config.target_platform == Platform.ANDROID: self.configure_options = '--with-python=no' + elif self.config.target_platform == Platform.IOS: + self.configure_options = '--with-python=no' diff --git a/recipes/soundtouch.recipe b/recipes/soundtouch.recipe index 935db23..8df7b31 100644 --- a/recipes/soundtouch.recipe +++ b/recipes/soundtouch.recipe @@ -20,3 +20,5 @@ class Recipe(recipe.Recipe): self.configure_options += ' --enable-static ' if self.config.target_platform == Platform.ANDROID: self.configure_options += ' --with-gnustl ' + elif self.config.target_platform == Platform.IOS: + self.autoreconf = True diff --git a/recipes/zlib.recipe b/recipes/zlib.recipe index a418d27..24e61ec 100644 --- a/recipes/zlib.recipe +++ b/recipes/zlib.recipe @@ -28,3 +28,10 @@ class Recipe(recipe.Recipe): libtool_la = LibtoolLibrary('z', 1, 2, 7, self.config.libdir, self.config.target_platform) libtool_la.save() + # FIXME This is to workaround a build issue trying to ld to libz.so + if self.config.target_platform == Platform.IOS: + try: + os.symlink(os.path.join (self.config.prefix, 'lib', 'libz.dylib'), + os.path.join (self.config.prefix, 'lib', 'libz.so')) + except OSError: + pass |