# 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 import re from cerbero.utils import shell from cerbero.config import Architecture, DistroVersion from cerbero.errors import FatalError variants.override(['nopython', 'notestspackage']) # 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 ios_min_version = ios_min_version or '11.0' if target_distro_version == distro_version: target_distro_version = None if target_arch in [Architecture.X86, Architecture.X86_64]: ios_platform = 'iPhoneSimulator' else: ios_platform = 'iPhoneOS' iphone_platform = '/Applications/Xcode.app/Contents/Developer/Platforms/%s.platform/Developer' % ios_platform toolchain_path = '%s/usr/bin' % iphone_platform def sdk_location_to_version_array(location): match = re.fullmatch(ios_platform + r'(\d{1,2}\.\d).sdk', location) if not match: raise FatalError('Could not find SDK version from location: ', location) return [int(m.group(1)) for m in re.finditer(r'(\d+)', match.group(1))] def version_array_to_distro(version): return 'ios_' + '_'.join((str(v) for v in version)) def version_array_to_sdk_location(version): return os.path.join(iphone_platform, 'SDKs', ios_platform + '.'.join((str(v) for v in version)) + '.sdk') def find_ios_sdk_locations(): sdks = [sdk for sdk in os.listdir(os.path.join(iphone_platform, 'SDKs'))] sdks = [sdk for sdk in sdks if sdk.startswith(ios_platform) and sdk.endswith('.sdk') and sdk != ios_platform + '.sdk'] return sdks # Find the installed SDK best_version = [0, 0] _sdk_version = None for sdk in find_ios_sdk_locations(): version_arr = sdk_location_to_version_array(sdk) version = version_array_to_distro(version_arr) if target_distro_version is not None and target_distro_version is version: best_version = version_arr break else: if version_arr > best_version: best_version = version_arr _sdk_version = version if target_distro_version is not None and target_distro_version != _sdk_version: raise FatalError("The SDK for %s is not installed" % target_distro_version) elif _sdk_version is None: raise FatalError("The SDK for iOS could not be found in your system") else: target_distro_version = _sdk_version ret = shell.check_output(['xcodebuild', '-version']).strip() assert(ret.startswith('Xcode')) xcode_version = tuple(int(c) for c in ret.split()[1].split('.')) sysroot = version_array_to_sdk_location(best_version) ccache = use_ccache and 'ccache ' or '' extra_cflags = '' extra_ldflags = '-Wno-error=unused-command-line-argument' if target_arch == Architecture.ARM64: arch_cflags = ' -arch arm64 -pipe' host = 'aarch64-apple-darwin10' elif target_arch == Architecture.ARMv7S: arch_cflags = ' -arch armv7s -mcpu=cortex-a9 -pipe' host = 'arm-apple-darwin10' elif target_arch == Architecture.ARMv7: arch_cflags = ' -arch armv7 -mcpu=cortex-a8 -pipe' host = 'arm-apple-darwin10' elif target_arch == Architecture.ARM: arch_cflags = ' -arch armv6 -mcpu=arm1176jzf-s -pipe' host = 'arm-apple-darwin10' elif target_arch == Architecture.X86: arch_cflags = ' -arch i386 ' host = 'i386-apple-darwin10' elif target_arch == Architecture.X86_64: arch_cflags = ' -arch x86_64 ' host = 'x86_64-apple-darwin10' elif target_arch == Architecture.UNIVERSAL: arch_cflags='' else: raise FatalError("Arch %s not supported" % target_arch) includedir = os.path.join(prefix, 'include') if universal_archs: lib_dir = os.path.join(prefix, target_arch, 'lib') else: lib_dir = os.path.join(prefix, 'lib') # Toolchain environment env['CC']= 'clang' env['CXX']= 'clang++' extra_cflags += ' -Wno-error=format-nonliteral -Wno-error=implicit-function-declaration ' # Starting with XCode 14, clang emits code that makes all binaries incompatible # with older XCode versions. Disable that feature. extra_objcflags = '' if xcode_version >= (14, 0): extra_objcflags += ' -fno-objc-msgsend-selector-stubs ' env['PATH'] = '%s:%s' % (toolchain_path, env['PATH']) env['OBJC'] = env['CC'] env['OBJCXX'] = env['CXX'] env['CPP']= "%s -E" % env['CC'] env['CXXPP']= env['CPP'] env['STRIP'] = 'strip' env['LD']= 'ld' env['AR']= 'ar' env['NM']= 'nm' env['NMEDIT']= 'nmedit' env['RANLIB']= 'ranlib' env['CPPFLAGS'] = '{} -isysroot {} -isystem {} '.format(arch_cflags, sysroot, includedir) if ios_platform == 'iPhoneOS': env['CPPFLAGS'] += '-miphoneos-version-min={} '.format(ios_min_version) else: env['CPPFLAGS'] += '-mios-simulator-version-min={} '.format(ios_min_version) env['CFLAGS'] = env['CPPFLAGS'] env['LDFLAGS'] = env['CPPFLAGS'] + ' -L{} '.format(lib_dir) if ios_platform == 'iPhoneOS': env['CCASFLAGS'] = '-miphoneos-version-min={} '.format(ios_min_version) env['CFLAGS'] += extra_cflags env['LDFLAGS'] += extra_ldflags env['OBJCFLAGS'] = env['CFLAGS'] + extra_objcflags env['OBJLDFLAGS'] = env['LDFLAGS'] + extra_objcflags env['CXXFLAGS'] =' -stdlib=libc++ ' + env['CFLAGS'] env['OBJCXXFLAGS'] =' -stdlib=libc++ ' + env['CFLAGS'] env['AS']= 'as' if target_arch in [Architecture.X86, Architecture.X86_64]: env.pop('GAS', None) else: env['GAS']= '%s %s %s' % ('gas-preprocessor.pl', env['CC'], env['CFLAGS']) if use_ccache: env['CC'] = 'ccache %s' % env['CC'] env['CXX'] = 'ccache %s' % env['CXX'] # For GLib meson_properties['growing_stack'] = 'true' # For pixman env['ac_cv_tls'] = 'none' # Workaround for https://openradar.appspot.com/22671534 on 10.11. env['gl_cv_func_getcwd_abort_bug'] = 'no' moltenvk_prefix = os.path.join(home_dir, 'moltenvk')