diff options
Diffstat (limited to 'waftools')
-rw-r--r-- | waftools/checks/custom.py | 30 | ||||
-rw-r--r-- | waftools/detections/compiler_swift.py | 19 | ||||
-rw-r--r-- | waftools/generators/sources.py | 1 | ||||
-rw-r--r-- | waftools/waf_customizations.py | 21 |
4 files changed, 46 insertions, 25 deletions
diff --git a/waftools/checks/custom.py b/waftools/checks/custom.py index 3f627250f7..8cc701f7f7 100644 --- a/waftools/checks/custom.py +++ b/waftools/checks/custom.py @@ -4,7 +4,7 @@ from waflib import Utils import os __all__ = ["check_pthreads", "check_iconv", "check_lua", - "check_cocoa", "check_openal", "check_wl_protocols"] + "check_cocoa", "check_wl_protocols", "check_swift"] pthreads_program = load_fragment('pthreads.c') @@ -85,7 +85,7 @@ def check_lua(ctx, dependency_identifier): def check_wl_protocols(ctx, dependency_identifier): def fn(ctx, dependency_identifier): - ret = check_pkg_config_datadir("wayland-protocols", ">= 1.14") + ret = check_pkg_config_datadir("wayland-protocols", ">= 1.15") ret = ret(ctx, dependency_identifier) if ret != None: ctx.env.WL_PROTO_DIR = ret.split()[0] @@ -97,18 +97,26 @@ def check_cocoa(ctx, dependency_identifier): fragment = load_fragment('cocoa.m'), compile_filename = 'test.m', framework_name = ['Cocoa', 'IOKit', 'OpenGL', 'QuartzCore'], - includes = ctx.srcnode.abspath(), + includes = [ctx.srcnode.abspath()], linkflags = '-fobjc-arc') - return fn(ctx, dependency_identifier) + res = fn(ctx, dependency_identifier) + if res and ctx.env.MACOS_SDK: + # on macOS we explicitly need to set the SDK path, otherwise it can lead + # to linking warnings or errors + ctx.env.append_value('LAST_LINKFLAGS', [ + '-isysroot', ctx.env.MACOS_SDK, + '-L/usr/lib', + '-L/usr/local/lib' + ]) -def check_openal(ctx, dependency_identifier): - checks = [ - check_pkg_config('openal', '>= 1.13'), - check_statement(['OpenAL/AL.h'], 'int i = AL_VERSION', framework='OpenAL') - ] + return res - for fn in checks: - if fn(ctx, dependency_identifier): +def check_swift(ctx, dependency_identifier): + if ctx.env.SWIFT_VERSION: + major = int(ctx.env.SWIFT_VERSION.split('.')[0]) + ctx.add_optional_message(dependency_identifier, + 'version found: ' + ctx.env.SWIFT_VERSION) + if major >= 3: return True return False diff --git a/waftools/detections/compiler_swift.py b/waftools/detections/compiler_swift.py index 9b0e06ed8a..d4ba162667 100644 --- a/waftools/detections/compiler_swift.py +++ b/waftools/detections/compiler_swift.py @@ -1,3 +1,4 @@ +import re from waflib import Utils def __run(cmd): @@ -8,18 +9,22 @@ def __run(cmd): return "" def __add_swift_flags(ctx): - ctx.env.SWIFT_FLAGS = ('-frontend -c -sdk %s -enable-objc-interop' - ' -emit-objc-header -parse-as-library' - ' -target x86_64-apple-macosx10.10') % (ctx.env.MACOS_SDK) - swift_version = __run([ctx.env.SWIFT, '-version']).split(' ')[3].split('.')[:2] - major, minor = [int(n) for n in swift_version] + ctx.env.SWIFT_FLAGS = [ + "-frontend", "-c", "-sdk", ctx.env.MACOS_SDK, + "-enable-objc-interop", "-emit-objc-header", "-parse-as-library", + "-target", "x86_64-apple-macosx10.10" + ] + + ver = re.compile("(?i)version\s?([\d.]+)") + ctx.env.SWIFT_VERSION = ver.search(__run([ctx.env.SWIFT, '-version'])).group(1) + major, minor = [int(n) for n in ctx.env.SWIFT_VERSION.split('.')[:2]] # the -swift-version parameter is only supported on swift 3.1 and newer if major >= 3 and minor >= 1 or major >= 4: - ctx.env.SWIFT_FLAGS += ' -swift-version 3' + ctx.env.SWIFT_FLAGS.extend([ "-swift-version", "3" ]) if ctx.is_optimization(): - ctx.env.SWIFT_FLAGS += ' -O' + ctx.env.SWIFT_FLAGS.append("-O") def __add_swift_library_linking_flags(ctx, swift_library): ctx.env.append_value('LINKFLAGS', [ diff --git a/waftools/generators/sources.py b/waftools/generators/sources.py index 5bde478a34..d94937c74a 100644 --- a/waftools/generators/sources.py +++ b/waftools/generators/sources.py @@ -94,6 +94,7 @@ def __wayland_protocol_header__(ctx, **kwargs): @TaskGen.feature('cshlib') @TaskGen.feature('cstlib') @TaskGen.feature('apply_link') +@TaskGen.after_method('do_the_symbol_stuff') def handle_add_object(tgen): if getattr(tgen, 'add_object', None): for input in Utils.to_list(tgen.add_object): diff --git a/waftools/waf_customizations.py b/waftools/waf_customizations.py index f264f9cb86..f0db04c614 100644 --- a/waftools/waf_customizations.py +++ b/waftools/waf_customizations.py @@ -28,18 +28,25 @@ def m_hook(self, node): """ return self.create_compiled_task('c', node) +def try_last_linkflags(cls): + try: + return cls.orig_run_str + ' ${LAST_LINKFLAGS}' + except AttributeError: + try: + return cls.hcode + ' ${LAST_LINKFLAGS}' + except TypeError: + return cls.hcode.decode('iso8859-1') + ' ${LAST_LINKFLAGS}' + def build(ctx): from waflib import Task cls = Task.classes['cprogram'] class cprogram(cls): - try: - run_str = cls.orig_run_str + ' ${LAST_LINKFLAGS}' - except AttributeError: - try: - run_str = cls.hcode + ' ${LAST_LINKFLAGS}' - except TypeError: - run_str = cls.hcode.decode('iso8859-1') + ' ${LAST_LINKFLAGS}' + run_str = try_last_linkflags(cls) + + cls = Task.classes['cshlib'] + class cshlib(cls): + run_str = try_last_linkflags(cls) cls = Task.classes['macplist'] class macplist(cls): |