summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAkemi <der.richter@gmx.de>2018-10-27 17:27:01 +0200
committerJan Ekström <jeebjp@gmail.com>2018-10-28 15:48:37 +0200
commiteab30807fe6835996105c9afbad63cec0cbc6c5c (patch)
treefee31d2ac8063d8c6cbd0b67c83b8cba581deaba
parentba2dee38fbd33adcb5405e0726f5baaa75128ccc (diff)
downloadmpv-eab30807fe6835996105c9afbad63cec0cbc6c5c.tar.bz2
mpv-eab30807fe6835996105c9afbad63cec0cbc6c5c.tar.xz
build: use an argument list for the Swift build args
that way we don't need to quote or escape anything. Fixes #6220
-rw-r--r--waftools/detections/compiler_swift.py12
-rw-r--r--wscript3
-rw-r--r--wscript_build.py26
3 files changed, 26 insertions, 15 deletions
diff --git a/waftools/detections/compiler_swift.py b/waftools/detections/compiler_swift.py
index 3c130302be..d4ba162667 100644
--- a/waftools/detections/compiler_swift.py
+++ b/waftools/detections/compiler_swift.py
@@ -9,9 +9,11 @@ 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)
+ 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)
@@ -19,10 +21,10 @@ def __add_swift_flags(ctx):
# 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/wscript b/wscript
index 7bc1b1bfd8..984fa8d083 100644
--- a/wscript
+++ b/wscript
@@ -3,6 +3,7 @@
import sys, os, re
sys.path.insert(0, os.path.join(os.getcwd(), 'waftools'))
sys.path.insert(0, os.getcwd())
+from shlex import split
from waflib.Configure import conf
from waflib.Tools import c_preproc
from waflib import Utils
@@ -1053,7 +1054,7 @@ def configure(ctx):
ctx.options.enable_lua = True
if ctx.options.SWIFT_FLAGS:
- ctx.env.SWIFT_FLAGS += ' ' + ctx.options.SWIFT_FLAGS
+ ctx.env.SWIFT_FLAGS.extend(split(ctx.options.SWIFT_FLAGS))
ctx.parse_dependencies(standalone_features)
diff --git a/wscript_build.py b/wscript_build.py
index 35b16856ea..64560b863d 100644
--- a/wscript_build.py
+++ b/wscript_build.py
@@ -142,16 +142,24 @@ def build(ctx):
ctx(features = "ebml_definitions", target = "ebml_defs.c")
def swift(task):
- src = ' '.join([x.abspath() for x in task.inputs])
+ src = [x.abspath() for x in task.inputs]
bridge = ctx.path.find_node("osdep/macOS_swift_bridge.h").abspath()
tgt = task.outputs[0].abspath()
header = task.outputs[1].abspath()
module = task.outputs[2].abspath()
- cmd = ('%s %s -module-name macOS_swift -emit-module-path %s '
- '-import-objc-header %s -emit-objc-header-path %s -o %s %s '
- '-I. -I%s') % (ctx.env.SWIFT, ctx.env.SWIFT_FLAGS, module,
- bridge, header, tgt, src, ctx.srcnode.abspath())
+ cmd = [ ctx.env.SWIFT ]
+ cmd.extend(ctx.env.SWIFT_FLAGS)
+ cmd.extend([
+ "-module-name", "macOS_swift",
+ "-emit-module-path", module,
+ "-import-objc-header", bridge,
+ "-emit-objc-header-path", header,
+ "-o", tgt,
+ ])
+ cmd.extend(src)
+ cmd.extend([ "-I.", "-I%s" % ctx.srcnode.abspath() ])
+
return task.exec_command(cmd)
if ctx.dependency_satisfied('macos-cocoa-cb'):
@@ -166,15 +174,15 @@ def build(ctx):
ctx(
rule = swift,
source = ctx.filtered_sources(swift_source),
- target = ('osdep/macOS_swift.o '
- 'osdep/macOS_swift.h '
- 'osdep/macOS_swift.swiftmodule'),
+ target = [ "osdep/macOS_swift.o",
+ "osdep/macOS_swift.h",
+ "osdep/macOS_swift.swiftmodule" ],
before = 'c',
)
ctx.env.append_value('LINKFLAGS', [
'-Xlinker', '-add_ast_path',
- '-Xlinker', '%s' % ctx.path.find_or_declare("osdep/macOS_swift.swiftmodule").abspath()
+ '-Xlinker', ctx.path.find_or_declare("osdep/macOS_swift.swiftmodule").abspath()
])
if ctx.dependency_satisfied('cplayer'):