mirror of
https://github.com/mpv-player/mpv
synced 2024-12-26 09:02:38 +00:00
*.py: cosmetic changes
This commit is contained in:
parent
c4440db744
commit
611c92ef1d
@ -276,7 +276,7 @@ class MatroskaElement(object):
|
||||
|
||||
def add_subelements(self, subelements):
|
||||
self.subelements = subelements
|
||||
self.subids = set(x[0].elid for x in subelements)
|
||||
self.subids = {x[0].elid for x in subelements}
|
||||
|
||||
elementd = {}
|
||||
elementlist = []
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from __future__ import print_function
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
@ -37,7 +37,7 @@ def copy_binary(binary_name):
|
||||
|
||||
def apply_plist_template(plist_file, version):
|
||||
for line in fileinput.input(plist_file, inplace=1):
|
||||
print (line.rstrip().replace('${VERSION}', version))
|
||||
print(line.rstrip().replace('${VERSION}', version))
|
||||
|
||||
def create_bundle_symlink(binary_name, symlink_name):
|
||||
os.symlink(os.path.basename(binary_name),
|
||||
|
@ -147,8 +147,8 @@ if hasval:
|
||||
ax[1] = win.addPlot()
|
||||
ax[1].setXLink(ax[0])
|
||||
for cur in ax:
|
||||
if cur is not None:
|
||||
cur.addLegend(offset = (-1, 1))
|
||||
if cur is not None:
|
||||
cur.addLegend(offset = (-1, 1))
|
||||
for e in G.sevents:
|
||||
cur = ax[1 if e.type == "value" else 0]
|
||||
if not cur in G.curveno:
|
||||
|
@ -135,7 +135,7 @@ def _check_pkg_config(_dyn_libs, _pkgc_args, *args, **kw_ext):
|
||||
|
||||
def check_headers(*headers, **kw_ext):
|
||||
def undef_others(ctx, headers, found):
|
||||
not_found_hs = set(headers) - set([found])
|
||||
not_found_hs = set(headers) - {found}
|
||||
for not_found_h in not_found_hs:
|
||||
ctx.undefine(inflector.define_key(not_found_h))
|
||||
|
||||
|
@ -44,7 +44,7 @@ def write_compilation_database(ctx):
|
||||
root = json.load(database_file)
|
||||
except IOError:
|
||||
root = []
|
||||
clang_db = dict((x['file'], x) for x in root)
|
||||
clang_db = {x['file']: x for x in root}
|
||||
for task in getattr(ctx, 'clang_compilation_database_tasks', []):
|
||||
try:
|
||||
cmd = task.last_cmd
|
||||
|
@ -220,5 +220,5 @@ def dependencies_use(ctx):
|
||||
BuildContext.filtered_sources = filtered_sources
|
||||
BuildContext.pick_first_matching_dep = pick_first_matching_dep
|
||||
BuildContext.dependencies_use = dependencies_use
|
||||
BuildContext.dependencies_includes = env_fetch(lambda x: "INCLUDES_{0}".format(x))
|
||||
BuildContext.dependencies_includes = env_fetch(lambda x: "INCLUDES_{0}".format(x))
|
||||
BuildContext.dependency_satisfied = dependency_satisfied
|
||||
|
@ -55,7 +55,7 @@ def __add_gcc_flags__(ctx):
|
||||
def __add_clang_flags__(ctx):
|
||||
ctx.env.CFLAGS += ["-Wno-logical-op-parentheses", "-fcolor-diagnostics",
|
||||
"-Wno-tautological-compare",
|
||||
"-Wno-tautological-constant-out-of-range-compare" ]
|
||||
"-Wno-tautological-constant-out-of-range-compare"]
|
||||
|
||||
def __add_mswin_flags__(ctx):
|
||||
ctx.env.CFLAGS += ['-D_WIN32_WINNT=0x0602', '-DUNICODE', '-DCOBJMACROS',
|
||||
|
@ -4,6 +4,7 @@ import os.path
|
||||
from waflib import Utils
|
||||
from distutils.version import StrictVersion
|
||||
|
||||
|
||||
def __run(cmd):
|
||||
try:
|
||||
output = Utils.subprocess.check_output(cmd, stderr=Utils.subprocess.STDOUT, universal_newlines=True)
|
||||
@ -11,6 +12,7 @@ def __run(cmd):
|
||||
except Exception:
|
||||
return ""
|
||||
|
||||
|
||||
def __add_swift_flags(ctx):
|
||||
ctx.env.SWIFT_FLAGS = [
|
||||
"-frontend", "-c", "-sdk", ctx.env.MACOS_SDK,
|
||||
@ -23,7 +25,7 @@ def __add_swift_flags(ctx):
|
||||
|
||||
# prevent possible breakages with future swift versions
|
||||
if StrictVersion(ctx.env.SWIFT_VERSION) >= StrictVersion("6.0"):
|
||||
ctx.env.SWIFT_FLAGS.extend([ "-swift-version", "5" ])
|
||||
ctx.env.SWIFT_FLAGS.extend(["-swift-version", "5"])
|
||||
|
||||
if ctx.is_debug_build():
|
||||
ctx.env.SWIFT_FLAGS.append("-g")
|
||||
@ -31,16 +33,18 @@ def __add_swift_flags(ctx):
|
||||
if ctx.is_optimization():
|
||||
ctx.env.SWIFT_FLAGS.append("-O")
|
||||
|
||||
|
||||
def __add_static_swift_library_linking_flags(ctx, swift_library):
|
||||
ctx.env.append_value('LINKFLAGS', [
|
||||
'-L%s' % swift_library,
|
||||
'-Xlinker', '-force_load_swift_libs', '-lc++',
|
||||
])
|
||||
|
||||
def __add_dynamic_swift_library_linking_flags(ctx, swift_library):
|
||||
ctx.env.append_value('LINKFLAGS', [ '-L%s' % swift_library ])
|
||||
|
||||
#ABI compatibility
|
||||
def __add_dynamic_swift_library_linking_flags(ctx, swift_library):
|
||||
ctx.env.append_value('LINKFLAGS', ['-L%s' % swift_library])
|
||||
|
||||
# ABI compatibility
|
||||
if StrictVersion(ctx.env.SWIFT_VERSION) >= StrictVersion("5.0"):
|
||||
ctx.env.append_value('LINKFLAGS', [
|
||||
'-Xlinker', '-rpath', '-Xlinker', '/usr/lib/swift',
|
||||
@ -51,15 +55,16 @@ def __add_dynamic_swift_library_linking_flags(ctx, swift_library):
|
||||
'-Xlinker', '-rpath', '-Xlinker', swift_library,
|
||||
])
|
||||
|
||||
|
||||
def __find_swift_library(ctx):
|
||||
swift_libraries = {}
|
||||
#look for set lib paths in passed environment variables
|
||||
# look for set lib paths in passed environment variables
|
||||
if 'SWIFT_LIB_DYNAMIC' in ctx.environ:
|
||||
swift_libraries['SWIFT_LIB_DYNAMIC'] = ctx.environ['SWIFT_LIB_DYNAMIC']
|
||||
if 'SWIFT_LIB_STATIC' in ctx.environ:
|
||||
swift_libraries['SWIFT_LIB_STATIC'] = ctx.environ['SWIFT_LIB_STATIC']
|
||||
|
||||
#search for swift libs relative to the swift compiler executable
|
||||
# search for swift libs relative to the swift compiler executable
|
||||
swift_library_relative_paths = {
|
||||
'SWIFT_LIB_DYNAMIC': '../../lib/swift/macosx',
|
||||
'SWIFT_LIB_STATIC': '../../lib/swift_static/macosx'
|
||||
@ -72,7 +77,7 @@ def __find_swift_library(ctx):
|
||||
if swift_library is not None:
|
||||
swift_libraries[lib_type] = swift_library.abspath()
|
||||
|
||||
#fall back to xcode-select path
|
||||
# fall back to xcode-select path
|
||||
swift_library_paths = {
|
||||
'SWIFT_LIB_DYNAMIC': [
|
||||
'Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx',
|
||||
@ -95,7 +100,7 @@ def __find_swift_library(ctx):
|
||||
else:
|
||||
break
|
||||
|
||||
#check if library paths were found
|
||||
# check if library paths were found
|
||||
ctx.start_msg('Checking for dynamic Swift Library')
|
||||
if 'SWIFT_LIB_DYNAMIC' in swift_libraries:
|
||||
ctx.end_msg(swift_libraries['SWIFT_LIB_DYNAMIC'])
|
||||
@ -115,48 +120,49 @@ def __find_swift_library(ctx):
|
||||
else:
|
||||
__add_dynamic_swift_library_linking_flags(ctx, swift_libraries['SWIFT_LIB_DYNAMIC'])
|
||||
|
||||
|
||||
def __find_macos_sdk(ctx):
|
||||
ctx.start_msg('Checking for macOS SDK')
|
||||
sdk = None
|
||||
sdk_build_version = None
|
||||
sdk_version = None
|
||||
|
||||
#look for set macOS SDK paths and version in passed environment variables
|
||||
# look for set macOS SDK paths and version in passed environment variables
|
||||
if 'MACOS_SDK' in ctx.environ:
|
||||
sdk = ctx.environ['MACOS_SDK']
|
||||
if 'MACOS_SDK_VERSION' in ctx.environ:
|
||||
ctx.env.MACOS_SDK_VERSION = ctx.environ['MACOS_SDK_VERSION']
|
||||
|
||||
#find macOS SDK paths and version
|
||||
# find macOS SDK paths and version
|
||||
if not sdk:
|
||||
sdk = __run(['xcrun', '--sdk', 'macosx', '--show-sdk-path'])
|
||||
if not ctx.env.MACOS_SDK_VERSION:
|
||||
#show-sdk-build-version: is not available on older command line tools, but return a build version (eg 17A360)
|
||||
#show-sdk-version: is always available, but on older dev tools it's only the major version
|
||||
sdk_build_version = __run(['xcrun', '--sdk', 'macosx', '--show-sdk-build-version' ])
|
||||
sdk_version = __run(['xcrun', '--sdk', 'macosx', '--show-sdk-version' ])
|
||||
# show-sdk-build-version: is not available on older command line tools, but return a build version (eg 17A360)
|
||||
# show-sdk-version: is always available, but on older dev tools it's only the major version
|
||||
sdk_build_version = __run(['xcrun', '--sdk', 'macosx', '--show-sdk-build-version'])
|
||||
sdk_version = __run(['xcrun', '--sdk', 'macosx', '--show-sdk-version'])
|
||||
|
||||
if sdk:
|
||||
ctx.env.MACOS_SDK = sdk
|
||||
build_version = '10.10.0'
|
||||
|
||||
if not ctx.env.MACOS_SDK_VERSION:
|
||||
#convert build version to a version string
|
||||
#first 2 two digits are the major version, starting with 15 which is 10.11 (offset of 4)
|
||||
#1 char is the minor version, A => 0, B => 1 and ongoing
|
||||
#las digits are bugfix version, which are nor relevant for us
|
||||
#eg 16E185 => 10.12.4, 17A360 => 10.13, 18B71 => 10.14.1
|
||||
# convert build version to a version string
|
||||
# first 2 two digits are the major version, starting with 15 which is 10.11 (offset of 4)
|
||||
# 1 char is the minor version, A => 0, B => 1 and ongoing
|
||||
# las digits are bugfix version, which are nor relevant for us
|
||||
# eg 16E185 => 10.12.4, 17A360 => 10.13, 18B71 => 10.14.1
|
||||
if sdk_build_version and isinstance(sdk_build_version, str):
|
||||
verRe = re.compile("(\d+)(\D+)(\d+)")
|
||||
version_parts = verRe.search(sdk_build_version)
|
||||
major = int(version_parts.group(1))-4
|
||||
major = int(version_parts.group(1)) - 4
|
||||
minor = string.ascii_lowercase.index(version_parts.group(2).lower())
|
||||
build_version = '10.' + str(major) + '.' + str(minor)
|
||||
|
||||
if not isinstance(sdk_version, str):
|
||||
sdk_version = '10.10.0'
|
||||
|
||||
#pick the higher version, always pick sdk over build if newer
|
||||
# pick the higher version, always pick sdk over build if newer
|
||||
if StrictVersion(build_version) > StrictVersion(sdk_version):
|
||||
ctx.env.MACOS_SDK_VERSION = build_version
|
||||
else:
|
||||
@ -166,15 +172,16 @@ def __find_macos_sdk(ctx):
|
||||
else:
|
||||
ctx.end_msg(False)
|
||||
|
||||
|
||||
def __find_swift_compiler(ctx):
|
||||
ctx.start_msg('Checking for swift (Swift compiler)')
|
||||
swift = ''
|
||||
|
||||
#look for set swift paths in passed environment variables
|
||||
# look for set swift paths in passed environment variables
|
||||
if 'SWIFT' in ctx.environ:
|
||||
swift = ctx.environ['SWIFT']
|
||||
|
||||
#find swift executable
|
||||
# find swift executable
|
||||
if not swift:
|
||||
swift = __run(['xcrun', '-find', 'swift'])
|
||||
|
||||
@ -186,6 +193,7 @@ def __find_swift_compiler(ctx):
|
||||
else:
|
||||
ctx.end_msg(False)
|
||||
|
||||
|
||||
def configure(ctx):
|
||||
if ctx.env.DEST_OS == "darwin":
|
||||
__find_macos_sdk(ctx)
|
||||
|
@ -3,7 +3,7 @@ import optparse
|
||||
|
||||
class Feature(object):
|
||||
def __init__(self, group, feature):
|
||||
self.group = group
|
||||
self.group = group
|
||||
self.identifier, self.attributes = feature['name'], feature
|
||||
|
||||
def add_options(self):
|
||||
|
Loading…
Reference in New Issue
Block a user