diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2014-04-22 12:07:35 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-06-25 13:51:45 +0100 |
commit | 2b4e1506f054fded57dd361c347bdb25ddd9e245 (patch) | |
tree | 3572b1196bac1686df976507e0081e76de9dd2e7 /scripts/lib/scriptpath.py | |
parent | 3c7b5ec1cae6186a64e0be2c05b64b05add08c97 (diff) | |
download | poky-2b4e1506f054fded57dd361c347bdb25ddd9e245.tar.gz |
scripts: consolidate code to find bitbake path
Several of these scripts were using duplicated code (and slightly
different methods) to find the path to bitbake and add its lib
subdirectory to the Python import path. Add some common code to do this
and change the scripts to use it.
Fixes [YOCTO #5076].
(From OE-Core rev: 0b5e94e168819134dcda0433c8ae893df4ab13ce)
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/scriptpath.py')
-rw-r--r-- | scripts/lib/scriptpath.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/scripts/lib/scriptpath.py b/scripts/lib/scriptpath.py new file mode 100644 index 0000000000..d00317e18d --- /dev/null +++ b/scripts/lib/scriptpath.py | |||
@@ -0,0 +1,42 @@ | |||
1 | # Path utility functions for OE python scripts | ||
2 | # | ||
3 | # Copyright (C) 2012-2014 Intel Corporation | ||
4 | # Copyright (C) 2011 Mentor Graphics Corporation | ||
5 | # | ||
6 | # This program is free software; you can redistribute it and/or modify | ||
7 | # it under the terms of the GNU General Public License version 2 as | ||
8 | # published by the Free Software Foundation. | ||
9 | # | ||
10 | # This program is distributed in the hope that it will be useful, | ||
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | # GNU General Public License for more details. | ||
14 | # | ||
15 | # You should have received a copy of the GNU General Public License along | ||
16 | # with this program; if not, write to the Free Software Foundation, Inc., | ||
17 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
18 | |||
19 | import sys | ||
20 | import os | ||
21 | import os.path | ||
22 | |||
23 | def add_oe_lib_path(): | ||
24 | basepath = os.path.abspath(os.path.dirname(__file__) + '/../..') | ||
25 | newpath = basepath + '/meta/lib' | ||
26 | sys.path.insert(0, newpath) | ||
27 | |||
28 | def add_bitbake_lib_path(): | ||
29 | basepath = os.path.abspath(os.path.dirname(__file__) + '/../..') | ||
30 | bitbakepath = None | ||
31 | if os.path.exists(basepath + '/bitbake/lib/bb'): | ||
32 | bitbakepath = basepath + '/bitbake' | ||
33 | else: | ||
34 | # look for bitbake/bin dir in PATH | ||
35 | for pth in os.environ['PATH'].split(':'): | ||
36 | if os.path.exists(os.path.join(pth, '../lib/bb')): | ||
37 | bitbakepath = os.path.abspath(os.path.join(pth, '..')) | ||
38 | break | ||
39 | |||
40 | if bitbakepath: | ||
41 | sys.path.insert(0, bitbakepath + '/lib') | ||
42 | return bitbakepath | ||