diff options
| author | Adrian Dudau <adrian.dudau@enea.com> | 2014-06-26 14:29:42 +0200 |
|---|---|---|
| committer | Adrian Dudau <adrian.dudau@enea.com> | 2014-06-26 14:29:42 +0200 |
| commit | 99ac0639fff61cbdcfe58668eb9b0083d624504f (patch) | |
| tree | f9142a48899bace9dda4f48c80e9a6f4b123c504 /classes | |
| download | meta-xilinx-99ac0639fff61cbdcfe58668eb9b0083d624504f.tar.gz | |
initial commit for Enea Linux 4.0
Migrated from the internal git server on the daisy-enea branch
Signed-off-by: Adrian Dudau <adrian.dudau@enea.com>
Diffstat (limited to 'classes')
| -rw-r--r-- | classes/xilinx-utils.bbclass | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/classes/xilinx-utils.bbclass b/classes/xilinx-utils.bbclass new file mode 100644 index 00000000..0d007b94 --- /dev/null +++ b/classes/xilinx-utils.bbclass | |||
| @@ -0,0 +1,58 @@ | |||
| 1 | # Utility functions for various Xilinx specific recipes | ||
| 2 | |||
| 3 | # Returns a ':' seperated list of expanded '${BBPATH}/$path' | ||
| 4 | def get_additional_bbpath_filespath(path, d): | ||
| 5 | board_extrapaths = [] | ||
| 6 | bbpath = d.getVar("BBPATH", True) or "" | ||
| 7 | for i in bbpath.split(":"): | ||
| 8 | board_extrapaths.append(os.path.join(i, path)) | ||
| 9 | if len(board_extrapaths): | ||
| 10 | return ":".join(board_extrapaths) + ":" | ||
| 11 | return "" | ||
| 12 | |||
| 13 | # Add a prefix or suffix to all paths in the list of paths | ||
| 14 | # e.g. add 'file://' to all paths | ||
| 15 | def paths_affix(paths, suffix = "", prefix = ""): | ||
| 16 | if paths: | ||
| 17 | files=set() | ||
| 18 | for path in paths.split(): | ||
| 19 | newpath = path | ||
| 20 | if suffix and len(suffix) != 0: | ||
| 21 | newpath = newpath + suffix | ||
| 22 | if prefix and len(prefix) != 0: | ||
| 23 | newpath = prefix + newpath | ||
| 24 | files.add(newpath) | ||
| 25 | if len(files) != 0: | ||
| 26 | return ' '.join(files) | ||
| 27 | return '' | ||
| 28 | |||
| 29 | # Expand all relative paths to absolute based on the WORKDIR location | ||
| 30 | def expand_workdir_paths(variable, d): | ||
| 31 | workdir = d.getVar("WORKDIR", True) | ||
| 32 | variable_value = d.getVar(variable, True) or '' | ||
| 33 | if variable_value: | ||
| 34 | files=set() | ||
| 35 | for path in variable_value.split(): | ||
| 36 | if workdir: | ||
| 37 | files.add(os.path.join(workdir, path)) | ||
| 38 | else: | ||
| 39 | files.add(path) | ||
| 40 | if len(files) != 0: | ||
| 41 | return ' '.join(files) | ||
| 42 | return '' | ||
| 43 | |||
| 44 | # Returns a space seperated list of all files which match the extension, joined | ||
| 45 | # with the dir path. | ||
| 46 | def expand_dir_basepaths_by_extension(variable, dir, extension, d): | ||
| 47 | variable_value = d.getVar(variable, True) or '' | ||
| 48 | if variable_value: | ||
| 49 | files=set() | ||
| 50 | for path in variable_value.split(): | ||
| 51 | if os.path.splitext(path)[1] == extension or extension == None: | ||
| 52 | if dir: | ||
| 53 | files.add(os.path.join(dir, os.path.basename(path))) | ||
| 54 | else: | ||
| 55 | files.add(os.path.basename(path)) | ||
| 56 | if len(files) != 0: | ||
| 57 | return ' '.join(files) | ||
| 58 | return '' | ||
