blob: f32326db3a1fcc51dacab4a2297368839d310211 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001# Path utility functions for OE python scripts
2#
3# Copyright (C) 2012-2014 Intel Corporation
4# Copyright (C) 2011 Mentor Graphics Corporation
5#
Brad Bishopc342db32019-05-15 21:57:59 -04006# SPDX-License-Identifier: GPL-2.0-only
Patrick Williamsc124f4f2015-09-15 14:41:29 -05007#
Patrick Williamsc124f4f2015-09-15 14:41:29 -05008
9import sys
10import os
11import os.path
12
13def 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
18def 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