Skip to content

Commit

Permalink
build: fix linking to dev SDK on macOS
Browse files Browse the repository at this point in the history
on macOS mpv was linked to the system SDK which didn't cause any
problems as long as the system SDK was the same as the dev SDK. though
it started to cause linking warnings when a new xcode version with the
SDK for the next macOS was installed. in the worst case it could also
cause linking errors. to fix this we explicitly set the SDK path to the
SDK that is used for building instead.
  • Loading branch information
Akemi authored and kevmitch committed Feb 12, 2018
1 parent abf2efb commit 235eb60
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion waftools/checks/custom.py
Expand Up @@ -92,6 +92,18 @@ def fn(ctx, dependency_identifier):
return ret
return fn(ctx, dependency_identifier)

def _run(cmd):
from waflib import Utils
try:
cmd = Utils.subprocess.Popen(cmd,
stdout=Utils.subprocess.PIPE,
stderr=Utils.subprocess.PIPE,
shell=True)
output = cmd.stdout.read().strip()
return output
except Exception:
return ""

def check_cocoa(ctx, dependency_identifier):
fn = check_cc(
fragment = load_fragment('cocoa.m'),
Expand All @@ -100,7 +112,15 @@ def check_cocoa(ctx, dependency_identifier):
includes = ctx.srcnode.abspath(),
linkflags = '-fobjc-arc')

return fn(ctx, dependency_identifier)
res = fn(ctx, dependency_identifier)
# on macOS we explicitly need to set the SDK path, otherwise it can lead to
# linking warnings or errors
if res:
ctx.env.append_value('LINKFLAGS', [
'-isysroot', '%s' % _run('xcrun --sdk macosx --show-sdk-path')
])

return res

def check_openal(ctx, dependency_identifier):
checks = [
Expand Down

0 comments on commit 235eb60

Please sign in to comment.