blob: f32326db3a1fcc51dacab4a2297368839d310211 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001# Path utility functions for OE python scripts
2#
3# Copyright (C) 2012-2014 Intel Corporation
4# Copyright (C) 2011 Mentor Graphics Corporation
5#
6# SPDX-License-Identifier: GPL-2.0-only
7#
8
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