Update classes to use lib/oe

Adapt modifications from upstream to make Poky classes use lib/oe for the
common Python functionality.

Signed-off-by: Joshua Lock <josh@linux.intel.com>
This commit is contained in:
Joshua Lock
2010-05-05 16:17:07 +01:00
parent ac023d775b
commit e7fa3529f3
4 changed files with 74 additions and 605 deletions

View File

@@ -1,12 +1,42 @@
# like os.path.join but doesn't treat absolute RHS specially
# For compatibility
def base_path_join(a, *p):
path = a
for b in p:
if path == '' or path.endswith('/'):
path += b
else:
path += '/' + b
return path
return oe.path.join(a, *p)
def base_path_relative(src, dest):
return oe.path.relative(src, dest)
def base_path_out(path, d):
return oe.path.format_display(path, d)
def base_read_file(filename):
return oe.utils.read_file(filename)
def base_ifelse(condition, iftrue = True, iffalse = False):
return oe.utils.ifelse(condition, iftrue, iffalse)
def base_conditional(variable, checkvalue, truevalue, falsevalue, d):
return oe.utils.conditional(variable, checkvalue, truevalue, falsevalue, d)
def base_less_or_equal(variable, checkvalue, truevalue, falsevalue, d):
return oe.utils.less_or_equal(variable, checkvalue, truevalue, falsevalue, d)
def base_version_less_or_equal(variable, checkvalue, truevalue, falsevalue, d):
return oe.utils.version_less_or_equal(variable, checkvalue, truevalue, falsevalue, d)
def base_contains(variable, checkvalues, truevalue, falsevalue, d):
return oe.utils.contains(variable, checkvalues, truevalue, falsevalue, d)
def base_both_contain(variable1, variable2, checkvalue, d):
return oe.utils.both_contain(variable1, variable2, checkvalue, d)
def base_prune_suffix(var, suffixes, d):
return oe.utils.prune_suffix(var, suffixes, d)
def oe_filter(f, str, d):
return oe.utils.str_filter(f, str, d)
def oe_filter_out(f, str, d):
return oe.utils.str_filter_out(f, str, d)
# for MD5/SHA handling
def base_chk_load_parser(config_path):
@@ -80,67 +110,6 @@ def base_chk_file(parser, pn, pv, src_uri, localpath, data):
return True
def base_read_file(filename):
try:
f = file( filename, "r" )
except IOError, reason:
return "" # WARNING: can't raise an error now because of the new RDEPENDS handling. This is a bit ugly. :M:
else:
return f.read().strip()
return None
def base_conditional(variable, checkvalue, truevalue, falsevalue, d):
if bb.data.getVar(variable,d,1) == checkvalue:
return truevalue
else:
return falsevalue
def base_less_or_equal(variable, checkvalue, truevalue, falsevalue, d):
if float(bb.data.getVar(variable,d,1)) <= float(checkvalue):
return truevalue
else:
return falsevalue
def base_version_less_or_equal(variable, checkvalue, truevalue, falsevalue, d):
result = bb.vercmp(bb.data.getVar(variable,d,True), checkvalue)
if result <= 0:
return truevalue
else:
return falsevalue
def base_contains(variable, checkvalues, truevalue, falsevalue, d):
matches = 0
if type(checkvalues).__name__ == "str":
checkvalues = [checkvalues]
for value in checkvalues:
if bb.data.getVar(variable,d,1).find(value) != -1:
matches = matches + 1
if matches == len(checkvalues):
return truevalue
return falsevalue
def base_both_contain(variable1, variable2, checkvalue, d):
if bb.data.getVar(variable1,d,1).find(checkvalue) != -1 and bb.data.getVar(variable2,d,1).find(checkvalue) != -1:
return checkvalue
else:
return ""
def base_prune_suffix(var, suffixes, d):
# See if var ends with any of the suffixes listed and
# remove it if found
for suffix in suffixes:
if var.endswith(suffix):
return var.replace(suffix, "")
return var
def oe_filter(f, str, d):
from re import match
return " ".join(filter(lambda x: match(f, x, 0), str.split()))
def oe_filter_out(f, str, d):
from re import match
return " ".join(filter(lambda x: not match(f, x, 0), str.split()))
oe_soinstall() {
# Purpose: Install shared library file and
# create the necessary links