summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAkemi <der.richter@gmx.de>2018-02-14 00:08:23 +0100
committerKevin Mitchell <kevmitch@gmail.com>2018-02-13 20:31:09 -0800
commiteb224a4a5543bb8954dd84d57c9a6af3109097cb (patch)
treec2629de77e5c91b68c12b7299aba0ba664edb404
parentd0afd377096c1e6e2980ebf075a39d1aeb7e7c79 (diff)
downloadmpv-eb224a4a5543bb8954dd84d57c9a6af3109097cb.tar.bz2
mpv-eb224a4a5543bb8954dd84d57c9a6af3109097cb.tar.xz
build: remove shell usage from swift build scripts
for convenience reasons i used strings for subprocess commands instead of command lists, which made it mandatory to use a shell. for security reasons, among others, we removed the shell usage and converted the commands to actual command lists.
-rw-r--r--waftools/detections/compiler_swift.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/waftools/detections/compiler_swift.py b/waftools/detections/compiler_swift.py
index 01349e820d..81c71415f7 100644
--- a/waftools/detections/compiler_swift.py
+++ b/waftools/detections/compiler_swift.py
@@ -2,7 +2,7 @@ from waflib import Utils
def __run(cmd):
try:
- output = Utils.subprocess.check_output(cmd, universal_newlines=True, shell=True)
+ output = Utils.subprocess.check_output(cmd, universal_newlines=True)
return output.strip()
except Exception:
return ""
@@ -10,7 +10,7 @@ def __run(cmd):
def __add_swift_flags(ctx):
ctx.env.SWIFT_FLAGS = ('-frontend -c -sdk %s -enable-objc-interop -emit-objc-header'
' -emit-module -parse-as-library') % (ctx.env.MACOS_SDK)
- swift_version = __run(ctx.env.SWIFT + ' -version').split(' ')[3].split('.')[:2]
+ swift_version = __run([ctx.env.SWIFT, '-version']).split(' ')[3].split('.')[:2]
major, minor = [int(n) for n in swift_version]
# the -swift-version parameter is only supported on swift 3.1 and newer
@@ -32,6 +32,7 @@ def __find_swift_library(ctx):
'usr/lib/swift_static/macosx'
]
dev_path = __run('xcode-select -p')[1:]
+ dev_path = __run(['xcode-select', '-p'])[1:]
ctx.start_msg('Checking for Swift Library')
for path in swift_library_paths:
@@ -44,7 +45,7 @@ def __find_swift_library(ctx):
def __find_macos_sdk(ctx):
ctx.start_msg('Checking for macOS SDK')
- sdk = __run('xcrun --sdk macosx --show-sdk-path')
+ sdk = __run(['xcrun', '--sdk', 'macosx', '--show-sdk-path'])
if sdk:
ctx.end_msg(sdk)
ctx.env.MACOS_SDK = sdk
@@ -53,7 +54,7 @@ def __find_macos_sdk(ctx):
def __find_swift_compiler(ctx):
ctx.start_msg('Checking for swift (Swift compiler)')
- swift = __run('xcrun -find swift')
+ swift = __run(['xcrun', '-find', 'swift'])
if swift:
ctx.end_msg(swift)
ctx.env.SWIFT = swift