1eb8dc403SDave Cobbley# Path utility functions for OE python scripts 2eb8dc403SDave Cobbley# 3eb8dc403SDave Cobbley# Copyright (C) 2012-2014 Intel Corporation 4eb8dc403SDave Cobbley# Copyright (C) 2011 Mentor Graphics Corporation 5eb8dc403SDave Cobbley# 6*c342db35SBrad Bishop# SPDX-License-Identifier: GPL-2.0-only 7eb8dc403SDave Cobbley# 8eb8dc403SDave Cobbley 9eb8dc403SDave Cobbleyimport sys 10eb8dc403SDave Cobbleyimport os 11eb8dc403SDave Cobbleyimport os.path 12eb8dc403SDave Cobbley 13eb8dc403SDave Cobbleydef add_oe_lib_path(): 14eb8dc403SDave Cobbley basepath = os.path.abspath(os.path.dirname(__file__) + '/../..') 15eb8dc403SDave Cobbley newpath = basepath + '/meta/lib' 16eb8dc403SDave Cobbley sys.path.insert(0, newpath) 17eb8dc403SDave Cobbley 18eb8dc403SDave Cobbleydef add_bitbake_lib_path(): 19eb8dc403SDave Cobbley basepath = os.path.abspath(os.path.dirname(__file__) + '/../..') 20eb8dc403SDave Cobbley bitbakepath = None 21eb8dc403SDave Cobbley if os.path.exists(basepath + '/bitbake/lib/bb'): 22eb8dc403SDave Cobbley bitbakepath = basepath + '/bitbake' 23eb8dc403SDave Cobbley else: 24eb8dc403SDave Cobbley # look for bitbake/bin dir in PATH 25eb8dc403SDave Cobbley for pth in os.environ['PATH'].split(':'): 26eb8dc403SDave Cobbley if os.path.exists(os.path.join(pth, '../lib/bb')): 27eb8dc403SDave Cobbley bitbakepath = os.path.abspath(os.path.join(pth, '..')) 28eb8dc403SDave Cobbley break 29eb8dc403SDave Cobbley 30eb8dc403SDave Cobbley if bitbakepath: 31eb8dc403SDave Cobbley sys.path.insert(0, bitbakepath + '/lib') 32eb8dc403SDave Cobbley return bitbakepath 33