scriptpath.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. # 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. import sys
  19. import os
  20. import os.path
  21. def add_oe_lib_path():
  22. basepath = os.path.abspath(os.path.dirname(__file__) + '/../..')
  23. newpath = basepath + '/meta/lib'
  24. sys.path.insert(0, newpath)
  25. def add_bitbake_lib_path():
  26. basepath = os.path.abspath(os.path.dirname(__file__) + '/../..')
  27. bitbakepath = None
  28. if os.path.exists(basepath + '/bitbake/lib/bb'):
  29. bitbakepath = basepath + '/bitbake'
  30. else:
  31. # look for bitbake/bin dir in PATH
  32. for pth in os.environ['PATH'].split(':'):
  33. if os.path.exists(os.path.join(pth, '../lib/bb')):
  34. bitbakepath = os.path.abspath(os.path.join(pth, '..'))
  35. break
  36. if bitbakepath:
  37. sys.path.insert(0, bitbakepath + '/lib')
  38. return bitbakepath