Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | # Path utility functions for OE python scripts |
| 2 | # |
| 3 | # Copyright (C) 2012-2014 Intel Corporation |
| 4 | # Copyright (C) 2011 Mentor Graphics Corporation |
| 5 | # |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 6 | # SPDX-License-Identifier: GPL-2.0-only |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7 | # |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8 | |
| 9 | import sys |
| 10 | import os |
| 11 | import os.path |
| 12 | |
| 13 | def add_oe_lib_path(): |
| 14 | basepath = os.path.abspath(os.path.dirname(__file__) + '/../..') |
| 15 | newpath = basepath + '/meta/lib' |
| 16 | sys.path.insert(0, newpath) |
| 17 | |
| 18 | def add_bitbake_lib_path(): |
| 19 | basepath = os.path.abspath(os.path.dirname(__file__) + '/../..') |
| 20 | bitbakepath = None |
| 21 | if os.path.exists(basepath + '/bitbake/lib/bb'): |
| 22 | bitbakepath = basepath + '/bitbake' |
| 23 | else: |
| 24 | # look for bitbake/bin dir in PATH |
| 25 | for pth in os.environ['PATH'].split(':'): |
| 26 | if os.path.exists(os.path.join(pth, '../lib/bb')): |
| 27 | bitbakepath = os.path.abspath(os.path.join(pth, '..')) |
| 28 | break |
| 29 | |
| 30 | if bitbakepath: |
| 31 | sys.path.insert(0, bitbakepath + '/lib') |
| 32 | return bitbakepath |