1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-25 16:33:02 +00:00

build: remove useless class

This commit is contained in:
Stefano Pigozzi 2015-07-26 15:00:47 +02:00
parent 616d1510a7
commit a3a453b69b
6 changed files with 37 additions and 48 deletions

View File

@ -1,4 +1,4 @@
from waftools.inflectors import DependencyInflector
from waftools import inflector
from waftools.checks.generic import *
from waflib import Utils
import os
@ -88,8 +88,7 @@ def check_oss_4front(ctx, dependency_identifier):
# avoid false positive from native sys/soundcard.h
if not oss_libdir:
defkey = DependencyInflector(dependency_identifier).define_key()
ctx.undefine(defkey)
ctx.undefine(inflector.define_key(dependency_identifier))
return False
soundcard_h = os.path.join(oss_libdir, "include/sys/soundcard.h")

View File

@ -1,5 +1,5 @@
import os
from inflectors import DependencyInflector
import inflector
from waflib.ConfigSet import ConfigSet
from waflib import Utils
@ -14,10 +14,10 @@ def even(n):
return n % 2 == 0
def __define_options__(dependency_identifier):
return DependencyInflector(dependency_identifier).define_dict()
return inflector.define_dict(dependency_identifier)
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.update(arg) for arg in args if arg]
return options_accu
@ -99,7 +99,7 @@ def check_pkg_config(*args, **kw_ext):
result = bool(ctx.check_cfg(**opts))
ConfigSet.append_unique = original_append_unique
defkey = DependencyInflector(dependency_identifier).define_key()
defkey = inflector.define_key(dependency_identifier)
if result:
ctx.define(defkey, 1)
else:
@ -113,8 +113,7 @@ def check_headers(*headers, **kw_ext):
def undef_others(ctx, headers, found):
not_found_hs = set(headers) - set([found])
for not_found_h in not_found_hs:
defkey = DependencyInflector(not_found_h).define_key()
ctx.undefine(defkey)
ctx.undefine(inflector.define_key(not_found_h))
def fn(ctx, dependency_identifier):
for header in headers:
@ -122,16 +121,14 @@ def check_headers(*headers, **kw_ext):
options = __merge_options__(dependency_identifier, defaults, kw_ext)
if ctx.check(**options):
undef_others(ctx, headers, header)
defkey = DependencyInflector(dependency_identifier).define_key()
ctx.define(defkey, 1)
ctx.define(inflector.define_key(dependency_identifier), 1)
return True
undef_others(ctx, headers, None)
return False
return fn
def check_true(ctx, dependency_identifier):
defkey = DependencyInflector(dependency_identifier).define_key()
ctx.define(defkey, 1)
ctx.define(inflector.define_key(dependency_identifier), 1)
return True
def check_ctx_vars(*variables):
@ -151,8 +148,7 @@ def check_ctx_vars(*variables):
return fn
def check_stub(ctx, dependency_identifier):
defkey = DependencyInflector(dependency_identifier).define_key()
ctx.undefine(defkey)
ctx.undefine(inflector.define_key(dependency_identifier))
return False
def compose_checks(*checks):

View File

@ -2,7 +2,7 @@ from waflib.Errors import ConfigurationError, WafError
from waflib.Configure import conf
from waflib.Build import BuildContext
from waflib.Logs import pprint
from inflectors import DependencyInflector
import inflector
class DependencyError(Exception):
pass
@ -43,8 +43,7 @@ class Dependency(object):
# No check was run, since the prerequisites of the dependency are
# not satisfied. Make sure the define is 'undefined' so that we
# get a `#define YYY 0` in `config.h`.
def_key = DependencyInflector(self.identifier).define_key()
self.ctx.undefine(def_key)
self.ctx.undefine(inflector.define_key(self.identifier))
self.fatal_if_needed()
return
@ -220,8 +219,7 @@ def env_fetch(tx):
return fn
def dependencies_use(ctx):
return [DependencyInflector(dep).storage_key() for \
dep in ctx.env.satisfied_deps]
return [inflector.storage_key(dep) for dep in ctx.env.satisfied_deps]
BuildContext.filtered_sources = filtered_sources
BuildContext.dependencies_use = dependencies_use

View File

@ -15,10 +15,10 @@ def __escape_c_string(s):
return s.replace("\"", "\\\"").replace("\n", "\\n")
def __get_features_string__(ctx):
from inflectors import DependencyInflector
import inflector
stuff = []
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":
stuff.append(dependency_identifier)
stuff.sort()

22
waftools/inflector.py Normal file
View 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)}

View File

@ -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()