aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xconfigure9
-rw-r--r--script/mconfig.py30
2 files changed, 34 insertions, 5 deletions
diff --git a/configure b/configure
index 116faf0..2c5e06d 100755
--- a/configure
+++ b/configure
@@ -13,8 +13,8 @@ c.dsymutil.required()
settings.add_setting_option('imaon2', '--with-imaon2', 'path to imaon2 (optional)', '')
settings.add_setting_option('gen_dia', '--enable-recompile-dia', 'generate darwin-inject-asm.S', False, bool=True)
settings.add_setting_option('enable_tests', '--enable-tests', 'tests!', False, bool=True)
-settings.add_setting_option('enable_ios_bootstrap', '--enable-ios-bootstrap', 'default: true if you pass --xcode-sdk=iphone*',
- lambda: 'iphone' in str(settings.host_machine().toolchains()[0].sdk_opt.value),
+settings.add_setting_option('enable_ios_bootstrap', '--enable-ios-bootstrap', 'default: true if targeting iOS',
+ lambda: settings.host_machine().is_ios(),
bool=True)
settings.add_setting_option('enable_werror', '--enable-werror', '', False, bool=True)
@@ -44,6 +44,9 @@ for name, cflags in asm_archs:
mach_settings.ldflags = asm_ldflags + mach_settings.ldflags
mconfig.post_parse_args_will_need.append(f)
+def wrong_ios():
+ if settings.enable_ios_bootstrap and not settings.host_machine().is_ios():
+ raise mconfig.DependencyNotFoundException("iOS bootstrap requires iOS, but the target doesn't seem to be iOS - if you're compiling without Xcode, please specify --target=armv7-apple-darwin10 or something like that")
mconfig.parse_args()
####################################
@@ -58,7 +61,7 @@ if settings.enable_werror:
# XXX this is a mess and wrong
flags = ['-O3']
-if settings.host_machine().is_cross():
+if settings.host_machine().is_ios():
flags.append('-miphoneos-version-min=8.0')
for i in ('cflags', 'ldflags'):
settings.host[i] = flags + settings.host[i]
diff --git a/script/mconfig.py b/script/mconfig.py
index d94fed8..b78beaa 100644
--- a/script/mconfig.py
+++ b/script/mconfig.py
@@ -452,6 +452,8 @@ class Machine(object):
self.toolchains = memoize(self.toolchains)
self.c_tools = memoize(self.c_tools)
+ self.darwin_target_conditionals = memoize(self.darwin_target_conditionals)
+
self.flags_section = OptSection('Compiler/linker flags (%s):' % (self.name,))
self.tools_section = OptSection('Tool overrides (%s):' % (self.name,))
@@ -476,15 +478,29 @@ class Machine(object):
return (self.triple.os is not None and 'darwin' in self.triple.os) or \
(self.triple.triple == '' and os.path.exists('/System/Library/Frameworks'))
+ def is_ios(self): # memoized
+ if not self.is_darwin():
+ return False
+ tc = self.darwin_target_conditionals()
+ return tc['TARGET_OS_IOS'] or tc['TARGET_OS_SIMULATOR']
+
+ def is_macosx(self):
+ return self.is_darwin() and not self.is_ios()
+
# Get a list of appropriate toolchains.
def toolchains(self): # memoized
tcs = []
- if os.path.exists('/usr/bin/xcrun'):
- tcs.append(XcodeToolchain(self, self.settings))
+ if self.is_darwin() and os.path.exists('/usr/bin/xcrun'):
+ self.xcode_toolchain = XcodeToolchain(self, self.settings)
+ tcs.append(self.xcode_toolchain)
tcs.append(UnixToolchain(self, self.settings))
return tcs
#memoize
+ def darwin_target_conditionals(self):
+ return calc_darwin_target_conditionals(self.c_tools(), self.settings)
+
+ #memoize
def c_tools(self):
return CTools(self.settings, self, self.toolchains())
@@ -567,6 +583,15 @@ class UnixToolchain(object):
failure_notes.append('detected cross compilation, so searched for %s-%s' % (self.machine.triple.triple, tool.name))
return tool.locate_in_paths(prefix, self.settings.tool_search_paths)
+def calc_darwin_target_conditionals(ctools, settings):
+ fn = os.path.join(settings.out, '_calc_darwin_target_conditionals.c')
+ with open(fn, 'w') as fp:
+ fn.write('#include <TargetConditionals.h>\n')
+ so, se, st = run_command(ct.cc() + ['-E', '-dM', fn])
+ if st:
+ raise DependencyNotFoundException('darwin platform but no TargetConditionals.h?')
+ return {env: bool(val) for (env, val) in re.findall('^#define (TARGET_[^ ]*)\s+(0|1)\s*$', so, re.M)}
+
# Reads a binary or XML plist (on OS X)
def read_plist(gunk):
import plistlib
@@ -605,6 +630,7 @@ class XcodeToolchain(object):
if not self.sdk:
is_armish = tarch is not None and tarch.startswith('arm')
self.sdk = 'iphoneos' if is_armish else 'macosx'
+ self.is_ios = 'macos' not in self.sdk
# this is used for arch and also serves as a check
sdk_platform_path, _, code = run_command(['/usr/bin/xcrun', '--sdk', self.sdk, '--show-sdk-platform-path'])
if code == 127: