summaryrefslogtreecommitdiffstats
path: root/meta/classes/utils.bbclass
diff options
context:
space:
mode:
authorJoshua Lock <josh@linux.intel.com>2010-05-05 16:17:07 +0100
committerJoshua Lock <josh@linux.intel.com>2010-05-06 12:53:16 +0100
commite7fa3529f32f4037fe122699e0d7f3789a871834 (patch)
treed5a8d407a5b0ac84a6a69f5aaff76e114d563da6 /meta/classes/utils.bbclass
parentac023d775b651c9b1e28a7a725e72949fe54ad47 (diff)
downloadpoky-e7fa3529f32f4037fe122699e0d7f3789a871834.tar.gz
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>
Diffstat (limited to 'meta/classes/utils.bbclass')
-rw-r--r--meta/classes/utils.bbclass107
1 files changed, 38 insertions, 69 deletions
diff --git a/meta/classes/utils.bbclass b/meta/classes/utils.bbclass
index c2d323235b..f37b565da2 100644
--- a/meta/classes/utils.bbclass
+++ b/meta/classes/utils.bbclass
@@ -1,12 +1,42 @@
1# like os.path.join but doesn't treat absolute RHS specially 1# For compatibility
2def base_path_join(a, *p): 2def base_path_join(a, *p):
3 path = a 3 return oe.path.join(a, *p)
4 for b in p: 4
5 if path == '' or path.endswith('/'): 5def base_path_relative(src, dest):
6 path += b 6 return oe.path.relative(src, dest)
7 else: 7
8 path += '/' + b 8def base_path_out(path, d):
9 return path 9 return oe.path.format_display(path, d)
10
11def base_read_file(filename):
12 return oe.utils.read_file(filename)
13
14def base_ifelse(condition, iftrue = True, iffalse = False):
15 return oe.utils.ifelse(condition, iftrue, iffalse)
16
17def base_conditional(variable, checkvalue, truevalue, falsevalue, d):
18 return oe.utils.conditional(variable, checkvalue, truevalue, falsevalue, d)
19
20def base_less_or_equal(variable, checkvalue, truevalue, falsevalue, d):
21 return oe.utils.less_or_equal(variable, checkvalue, truevalue, falsevalue, d)
22
23def base_version_less_or_equal(variable, checkvalue, truevalue, falsevalue, d):
24 return oe.utils.version_less_or_equal(variable, checkvalue, truevalue, falsevalue, d)
25
26def base_contains(variable, checkvalues, truevalue, falsevalue, d):
27 return oe.utils.contains(variable, checkvalues, truevalue, falsevalue, d)
28
29def base_both_contain(variable1, variable2, checkvalue, d):
30 return oe.utils.both_contain(variable1, variable2, checkvalue, d)
31
32def base_prune_suffix(var, suffixes, d):
33 return oe.utils.prune_suffix(var, suffixes, d)
34
35def oe_filter(f, str, d):
36 return oe.utils.str_filter(f, str, d)
37
38def oe_filter_out(f, str, d):
39 return oe.utils.str_filter_out(f, str, d)
10 40
11# for MD5/SHA handling 41# for MD5/SHA handling
12def base_chk_load_parser(config_path): 42def base_chk_load_parser(config_path):
@@ -80,67 +110,6 @@ def base_chk_file(parser, pn, pv, src_uri, localpath, data):
80 110
81 return True 111 return True
82 112
83def base_read_file(filename):
84 try:
85 f = file( filename, "r" )
86 except IOError, reason:
87 return "" # WARNING: can't raise an error now because of the new RDEPENDS handling. This is a bit ugly. :M:
88 else:
89 return f.read().strip()
90 return None
91
92def base_conditional(variable, checkvalue, truevalue, falsevalue, d):
93 if bb.data.getVar(variable,d,1) == checkvalue:
94 return truevalue
95 else:
96 return falsevalue
97
98def base_less_or_equal(variable, checkvalue, truevalue, falsevalue, d):
99 if float(bb.data.getVar(variable,d,1)) <= float(checkvalue):
100 return truevalue
101 else:
102 return falsevalue
103
104def base_version_less_or_equal(variable, checkvalue, truevalue, falsevalue, d):
105 result = bb.vercmp(bb.data.getVar(variable,d,True), checkvalue)
106 if result <= 0:
107 return truevalue
108 else:
109 return falsevalue
110
111def base_contains(variable, checkvalues, truevalue, falsevalue, d):
112 matches = 0
113 if type(checkvalues).__name__ == "str":
114 checkvalues = [checkvalues]
115 for value in checkvalues:
116 if bb.data.getVar(variable,d,1).find(value) != -1:
117 matches = matches + 1
118 if matches == len(checkvalues):
119 return truevalue
120 return falsevalue
121
122def base_both_contain(variable1, variable2, checkvalue, d):
123 if bb.data.getVar(variable1,d,1).find(checkvalue) != -1 and bb.data.getVar(variable2,d,1).find(checkvalue) != -1:
124 return checkvalue
125 else:
126 return ""
127
128def base_prune_suffix(var, suffixes, d):
129 # See if var ends with any of the suffixes listed and
130 # remove it if found
131 for suffix in suffixes:
132 if var.endswith(suffix):
133 return var.replace(suffix, "")
134 return var
135
136def oe_filter(f, str, d):
137 from re import match
138 return " ".join(filter(lambda x: match(f, x, 0), str.split()))
139
140def oe_filter_out(f, str, d):
141 from re import match
142 return " ".join(filter(lambda x: not match(f, x, 0), str.split()))
143
144oe_soinstall() { 113oe_soinstall() {
145 # Purpose: Install shared library file and 114 # Purpose: Install shared library file and
146 # create the necessary links 115 # create the necessary links