scriptpath.py 955 B

1234567891011121314151617181920212223242526272829303132
  1. # 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. import sys
  9. import os
  10. import os.path
  11. def add_oe_lib_path():
  12. basepath = os.path.abspath(os.path.dirname(__file__) + '/../..')
  13. newpath = basepath + '/meta/lib'
  14. sys.path.insert(0, newpath)
  15. def add_bitbake_lib_path():
  16. basepath = os.path.abspath(os.path.dirname(__file__) + '/../..')
  17. bitbakepath = None
  18. if os.path.exists(basepath + '/bitbake/lib/bb'):
  19. bitbakepath = basepath + '/bitbake'
  20. else:
  21. # look for bitbake/bin dir in PATH
  22. for pth in os.environ['PATH'].split(':'):
  23. if os.path.exists(os.path.join(pth, '../lib/bb')):
  24. bitbakepath = os.path.abspath(os.path.join(pth, '..'))
  25. break
  26. if bitbakepath:
  27. sys.path.insert(0, bitbakepath + '/lib')
  28. return bitbakepath