blob: d00317e18d9aa98b231e9285a1c7cac0c07fc9aa [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#
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
19import sys
20import os
21import os.path
22
23def 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
28def 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