mirror of
https://github.com/mpv-player/mpv
synced 2024-12-26 09:02:38 +00:00
build: remove useless class
This commit is contained in:
parent
616d1510a7
commit
a3a453b69b
@ -1,4 +1,4 @@
|
|||||||
from waftools.inflectors import DependencyInflector
|
from waftools import inflector
|
||||||
from waftools.checks.generic import *
|
from waftools.checks.generic import *
|
||||||
from waflib import Utils
|
from waflib import Utils
|
||||||
import os
|
import os
|
||||||
@ -88,8 +88,7 @@ def check_oss_4front(ctx, dependency_identifier):
|
|||||||
|
|
||||||
# avoid false positive from native sys/soundcard.h
|
# avoid false positive from native sys/soundcard.h
|
||||||
if not oss_libdir:
|
if not oss_libdir:
|
||||||
defkey = DependencyInflector(dependency_identifier).define_key()
|
ctx.undefine(inflector.define_key(dependency_identifier))
|
||||||
ctx.undefine(defkey)
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
soundcard_h = os.path.join(oss_libdir, "include/sys/soundcard.h")
|
soundcard_h = os.path.join(oss_libdir, "include/sys/soundcard.h")
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
from inflectors import DependencyInflector
|
import inflector
|
||||||
from waflib.ConfigSet import ConfigSet
|
from waflib.ConfigSet import ConfigSet
|
||||||
from waflib import Utils
|
from waflib import Utils
|
||||||
|
|
||||||
@ -14,10 +14,10 @@ def even(n):
|
|||||||
return n % 2 == 0
|
return n % 2 == 0
|
||||||
|
|
||||||
def __define_options__(dependency_identifier):
|
def __define_options__(dependency_identifier):
|
||||||
return DependencyInflector(dependency_identifier).define_dict()
|
return inflector.define_dict(dependency_identifier)
|
||||||
|
|
||||||
def __merge_options__(dependency_identifier, *args):
|
def __merge_options__(dependency_identifier, *args):
|
||||||
options_accu = DependencyInflector(dependency_identifier).storage_dict()
|
options_accu = inflector.storage_dict(dependency_identifier)
|
||||||
options_accu['mandatory'] = False
|
options_accu['mandatory'] = False
|
||||||
[options_accu.update(arg) for arg in args if arg]
|
[options_accu.update(arg) for arg in args if arg]
|
||||||
return options_accu
|
return options_accu
|
||||||
@ -99,7 +99,7 @@ def check_pkg_config(*args, **kw_ext):
|
|||||||
result = bool(ctx.check_cfg(**opts))
|
result = bool(ctx.check_cfg(**opts))
|
||||||
ConfigSet.append_unique = original_append_unique
|
ConfigSet.append_unique = original_append_unique
|
||||||
|
|
||||||
defkey = DependencyInflector(dependency_identifier).define_key()
|
defkey = inflector.define_key(dependency_identifier)
|
||||||
if result:
|
if result:
|
||||||
ctx.define(defkey, 1)
|
ctx.define(defkey, 1)
|
||||||
else:
|
else:
|
||||||
@ -113,8 +113,7 @@ def check_headers(*headers, **kw_ext):
|
|||||||
def undef_others(ctx, headers, found):
|
def undef_others(ctx, headers, found):
|
||||||
not_found_hs = set(headers) - set([found])
|
not_found_hs = set(headers) - set([found])
|
||||||
for not_found_h in not_found_hs:
|
for not_found_h in not_found_hs:
|
||||||
defkey = DependencyInflector(not_found_h).define_key()
|
ctx.undefine(inflector.define_key(not_found_h))
|
||||||
ctx.undefine(defkey)
|
|
||||||
|
|
||||||
def fn(ctx, dependency_identifier):
|
def fn(ctx, dependency_identifier):
|
||||||
for header in headers:
|
for header in headers:
|
||||||
@ -122,16 +121,14 @@ def check_headers(*headers, **kw_ext):
|
|||||||
options = __merge_options__(dependency_identifier, defaults, kw_ext)
|
options = __merge_options__(dependency_identifier, defaults, kw_ext)
|
||||||
if ctx.check(**options):
|
if ctx.check(**options):
|
||||||
undef_others(ctx, headers, header)
|
undef_others(ctx, headers, header)
|
||||||
defkey = DependencyInflector(dependency_identifier).define_key()
|
ctx.define(inflector.define_key(dependency_identifier), 1)
|
||||||
ctx.define(defkey, 1)
|
|
||||||
return True
|
return True
|
||||||
undef_others(ctx, headers, None)
|
undef_others(ctx, headers, None)
|
||||||
return False
|
return False
|
||||||
return fn
|
return fn
|
||||||
|
|
||||||
def check_true(ctx, dependency_identifier):
|
def check_true(ctx, dependency_identifier):
|
||||||
defkey = DependencyInflector(dependency_identifier).define_key()
|
ctx.define(inflector.define_key(dependency_identifier), 1)
|
||||||
ctx.define(defkey, 1)
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def check_ctx_vars(*variables):
|
def check_ctx_vars(*variables):
|
||||||
@ -151,8 +148,7 @@ def check_ctx_vars(*variables):
|
|||||||
return fn
|
return fn
|
||||||
|
|
||||||
def check_stub(ctx, dependency_identifier):
|
def check_stub(ctx, dependency_identifier):
|
||||||
defkey = DependencyInflector(dependency_identifier).define_key()
|
ctx.undefine(inflector.define_key(dependency_identifier))
|
||||||
ctx.undefine(defkey)
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def compose_checks(*checks):
|
def compose_checks(*checks):
|
||||||
|
@ -2,7 +2,7 @@ from waflib.Errors import ConfigurationError, WafError
|
|||||||
from waflib.Configure import conf
|
from waflib.Configure import conf
|
||||||
from waflib.Build import BuildContext
|
from waflib.Build import BuildContext
|
||||||
from waflib.Logs import pprint
|
from waflib.Logs import pprint
|
||||||
from inflectors import DependencyInflector
|
import inflector
|
||||||
|
|
||||||
class DependencyError(Exception):
|
class DependencyError(Exception):
|
||||||
pass
|
pass
|
||||||
@ -43,8 +43,7 @@ class Dependency(object):
|
|||||||
# No check was run, since the prerequisites of the dependency are
|
# No check was run, since the prerequisites of the dependency are
|
||||||
# not satisfied. Make sure the define is 'undefined' so that we
|
# not satisfied. Make sure the define is 'undefined' so that we
|
||||||
# get a `#define YYY 0` in `config.h`.
|
# get a `#define YYY 0` in `config.h`.
|
||||||
def_key = DependencyInflector(self.identifier).define_key()
|
self.ctx.undefine(inflector.define_key(self.identifier))
|
||||||
self.ctx.undefine(def_key)
|
|
||||||
self.fatal_if_needed()
|
self.fatal_if_needed()
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -220,8 +219,7 @@ def env_fetch(tx):
|
|||||||
return fn
|
return fn
|
||||||
|
|
||||||
def dependencies_use(ctx):
|
def dependencies_use(ctx):
|
||||||
return [DependencyInflector(dep).storage_key() for \
|
return [inflector.storage_key(dep) for dep in ctx.env.satisfied_deps]
|
||||||
dep in ctx.env.satisfied_deps]
|
|
||||||
|
|
||||||
BuildContext.filtered_sources = filtered_sources
|
BuildContext.filtered_sources = filtered_sources
|
||||||
BuildContext.dependencies_use = dependencies_use
|
BuildContext.dependencies_use = dependencies_use
|
||||||
|
@ -15,10 +15,10 @@ def __escape_c_string(s):
|
|||||||
return s.replace("\"", "\\\"").replace("\n", "\\n")
|
return s.replace("\"", "\\\"").replace("\n", "\\n")
|
||||||
|
|
||||||
def __get_features_string__(ctx):
|
def __get_features_string__(ctx):
|
||||||
from inflectors import DependencyInflector
|
import inflector
|
||||||
stuff = []
|
stuff = []
|
||||||
for dependency_identifier in ctx.satisfied_deps:
|
for dependency_identifier in ctx.satisfied_deps:
|
||||||
defkey = DependencyInflector(dependency_identifier).define_key()
|
defkey = inflector.define_key(dependency_identifier)
|
||||||
if ctx.is_defined(defkey) and ctx.get_define(defkey) == "1":
|
if ctx.is_defined(defkey) and ctx.get_define(defkey) == "1":
|
||||||
stuff.append(dependency_identifier)
|
stuff.append(dependency_identifier)
|
||||||
stuff.sort()
|
stuff.sort()
|
||||||
|
22
waftools/inflector.py
Normal file
22
waftools/inflector.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import re
|
||||||
|
|
||||||
|
def _underscore(word):
|
||||||
|
""" Converts a word "into_it_s_underscored_version"
|
||||||
|
Convert any "CamelCased" or "ordinary Word" into an
|
||||||
|
"underscored_word"."""
|
||||||
|
|
||||||
|
return re.sub('[^A-Z^a-z^0-9]+', '_', \
|
||||||
|
re.sub('([a-z\d])([A-Z])', '\\1_\\2', \
|
||||||
|
re.sub('([A-Z]+)([A-Z][a-z])', '\\1_\\2', re.sub('::', '/', word)))).lower()
|
||||||
|
|
||||||
|
def storage_key(dep):
|
||||||
|
return _underscore(dep)
|
||||||
|
|
||||||
|
def define_key(dep):
|
||||||
|
return ("have_" + storage_key(dep)).upper()
|
||||||
|
|
||||||
|
def define_dict(dep):
|
||||||
|
return {'define_name': define_key(dep)}
|
||||||
|
|
||||||
|
def storage_dict(dep):
|
||||||
|
return {'uselib_store': storage_key(dep)}
|
@ -1,26 +0,0 @@
|
|||||||
import re
|
|
||||||
|
|
||||||
class DependencyInflector(object):
|
|
||||||
def __init__(self, dependency):
|
|
||||||
self.dep = dependency
|
|
||||||
|
|
||||||
def storage_key(self):
|
|
||||||
return self.__underscore__(self.dep)
|
|
||||||
|
|
||||||
def define_key(self):
|
|
||||||
return ("have_" + self.storage_key()).upper()
|
|
||||||
|
|
||||||
def define_dict(self):
|
|
||||||
return {'define_name': self.define_key()}
|
|
||||||
|
|
||||||
def storage_dict(self):
|
|
||||||
return {'uselib_store': self.storage_key()}
|
|
||||||
|
|
||||||
def __underscore__(self, word):
|
|
||||||
""" Converts a word "into_it_s_underscored_version"
|
|
||||||
Convert any "CamelCased" or "ordinary Word" into an
|
|
||||||
"underscored_word"."""
|
|
||||||
|
|
||||||
return re.sub('[^A-Z^a-z^0-9]+', '_', \
|
|
||||||
re.sub('([a-z\d])([A-Z])', '\\1_\\2', \
|
|
||||||
re.sub('([A-Z]+)([A-Z][a-z])', '\\1_\\2', re.sub('::', '/', word)))).lower()
|
|
Loading…
Reference in New Issue
Block a user