mirror of
https://github.com/mpv-player/mpv
synced 2025-02-10 00:47:38 +00:00
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.
This commit is contained in:
parent
d0afd37709
commit
eb224a4a55
@ -2,7 +2,7 @@ from waflib import Utils
|
|||||||
|
|
||||||
def __run(cmd):
|
def __run(cmd):
|
||||||
try:
|
try:
|
||||||
output = Utils.subprocess.check_output(cmd, universal_newlines=True, shell=True)
|
output = Utils.subprocess.check_output(cmd, universal_newlines=True)
|
||||||
return output.strip()
|
return output.strip()
|
||||||
except Exception:
|
except Exception:
|
||||||
return ""
|
return ""
|
||||||
@ -10,7 +10,7 @@ def __run(cmd):
|
|||||||
def __add_swift_flags(ctx):
|
def __add_swift_flags(ctx):
|
||||||
ctx.env.SWIFT_FLAGS = ('-frontend -c -sdk %s -enable-objc-interop -emit-objc-header'
|
ctx.env.SWIFT_FLAGS = ('-frontend -c -sdk %s -enable-objc-interop -emit-objc-header'
|
||||||
' -emit-module -parse-as-library') % (ctx.env.MACOS_SDK)
|
' -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]
|
major, minor = [int(n) for n in swift_version]
|
||||||
|
|
||||||
# the -swift-version parameter is only supported on swift 3.1 and newer
|
# 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'
|
'usr/lib/swift_static/macosx'
|
||||||
]
|
]
|
||||||
dev_path = __run('xcode-select -p')[1:]
|
dev_path = __run('xcode-select -p')[1:]
|
||||||
|
dev_path = __run(['xcode-select', '-p'])[1:]
|
||||||
|
|
||||||
ctx.start_msg('Checking for Swift Library')
|
ctx.start_msg('Checking for Swift Library')
|
||||||
for path in swift_library_paths:
|
for path in swift_library_paths:
|
||||||
@ -44,7 +45,7 @@ def __find_swift_library(ctx):
|
|||||||
|
|
||||||
def __find_macos_sdk(ctx):
|
def __find_macos_sdk(ctx):
|
||||||
ctx.start_msg('Checking for macOS SDK')
|
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:
|
if sdk:
|
||||||
ctx.end_msg(sdk)
|
ctx.end_msg(sdk)
|
||||||
ctx.env.MACOS_SDK = sdk
|
ctx.env.MACOS_SDK = sdk
|
||||||
@ -53,7 +54,7 @@ def __find_macos_sdk(ctx):
|
|||||||
|
|
||||||
def __find_swift_compiler(ctx):
|
def __find_swift_compiler(ctx):
|
||||||
ctx.start_msg('Checking for swift (Swift compiler)')
|
ctx.start_msg('Checking for swift (Swift compiler)')
|
||||||
swift = __run('xcrun -find swift')
|
swift = __run(['xcrun', '-find', 'swift'])
|
||||||
if swift:
|
if swift:
|
||||||
ctx.end_msg(swift)
|
ctx.end_msg(swift)
|
||||||
ctx.env.SWIFT = swift
|
ctx.env.SWIFT = swift
|
||||||
|
Loading…
Reference in New Issue
Block a user