1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Utility functions for various Xilinx specific recipes
# Returns a ':' seperated list of expanded '${BBPATH}/$path'
def get_additional_bbpath_filespath(path, d):
board_extrapaths = []
bbpath = d.getVar("BBPATH", True) or ""
for i in bbpath.split(":"):
board_extrapaths.append(os.path.join(i, path))
if len(board_extrapaths):
return ":".join(board_extrapaths) + ":"
return ""
# Add a prefix or suffix to all paths in the list of paths
# e.g. add 'file://' to all paths
def paths_affix(paths, suffix = "", prefix = ""):
if paths:
files=set()
for path in paths.split():
newpath = path
if suffix and len(suffix) != 0:
newpath = newpath + suffix
if prefix and len(prefix) != 0:
newpath = prefix + newpath
files.add(newpath)
if len(files) != 0:
return ' '.join(files)
return ''
# Expand all relative paths to absolute based on the WORKDIR location
def expand_workdir_paths(variable, d):
workdir = d.getVar("WORKDIR", True)
variable_value = d.getVar(variable, True) or ''
if variable_value:
files=set()
for path in variable_value.split():
if workdir:
files.add(os.path.join(workdir, path))
else:
files.add(path)
if len(files) != 0:
return ' '.join(files)
return ''
# Returns a space seperated list of all files which match the extension, joined
# with the dir path.
def expand_dir_basepaths_by_extension(variable, dir, extension, d):
variable_value = d.getVar(variable, True) or ''
if variable_value:
files=set()
for path in variable_value.split():
if os.path.splitext(path)[1] == extension or extension == None:
if dir:
files.add(os.path.join(dir, os.path.basename(path)))
else:
files.add(os.path.basename(path))
if len(files) != 0:
return ' '.join(files)
return ''