oe-find-native-sysroot 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #!/bin/bash
  2. #
  3. # Find a native sysroot to use - either from an in-tree OE build or
  4. # from a toolchain installation. It then ensures the variable
  5. # $OECORE_NATIVE_SYSROOT is set to the sysroot's base directory, and sets
  6. # $PSEUDO to the path of the pseudo binary.
  7. #
  8. # This script is intended to be run within other scripts by source'ing
  9. # it, e.g:
  10. #
  11. # SYSROOT_SETUP_SCRIPT=`which oe-find-native-sysroot`
  12. # . $SYSROOT_SETUP_SCRIPT
  13. #
  14. # This script will terminate execution of your calling program unless
  15. # you set a variable $SKIP_STRICT_SYSROOT_CHECK to a non-empty string
  16. # beforehand.
  17. #
  18. # Copyright (c) 2010 Linux Foundation
  19. #
  20. # This program is free software; you can redistribute it and/or modify
  21. # it under the terms of the GNU General Public License version 2 as
  22. # published by the Free Software Foundation.
  23. #
  24. # This program is distributed in the hope that it will be useful,
  25. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  26. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  27. # GNU General Public License for more details.
  28. #
  29. # You should have received a copy of the GNU General Public License along
  30. # with this program; if not, write to the Free Software Foundation, Inc.,
  31. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  32. if [ "x$OECORE_NATIVE_SYSROOT" = "x" ]; then
  33. BITBAKE=`which bitbake 2> /dev/null`
  34. if [ "x$BITBAKE" != "x" ]; then
  35. if [ "$UID" = "0" ]; then
  36. # Root cannot run bitbake unless sanity checking is disabled
  37. if [ ! -d "./conf" ]; then
  38. echo "Error: root cannot run bitbake by default, and I cannot find a ./conf directory to be able to disable sanity checking"
  39. exit 1
  40. fi
  41. touch conf/sanity.conf
  42. OECORE_NATIVE_SYSROOT=`bitbake -e | grep ^STAGING_DIR_NATIVE | cut -d '"' -f2`
  43. rm -f conf/sanity.conf
  44. else
  45. OECORE_NATIVE_SYSROOT=`bitbake -e | grep ^STAGING_DIR_NATIVE | cut -d '"' -f2`
  46. fi
  47. else
  48. echo "Error: Unable to locate bitbake command."
  49. echo "Did you forget to source the build environment setup script?"
  50. if [ -z "$SKIP_STRICT_SYSROOT_CHECK" ]; then
  51. exit 1
  52. fi
  53. fi
  54. fi
  55. if [ "x$OECORE_NATIVE_SYSROOT" = "x" ]; then
  56. # This indicates that there was an error running bitbake -e that
  57. # the user needs to be informed of
  58. echo "There was an error running bitbake to determine STAGING_DIR_NATIVE"
  59. echo "Here is the output from bitbake -e"
  60. bitbake -e
  61. exit 1
  62. fi
  63. # Set up pseudo command
  64. if [ ! -e "$OECORE_NATIVE_SYSROOT/usr/bin/pseudo" ]; then
  65. echo "Error: Unable to find pseudo binary in $OECORE_NATIVE_SYSROOT/usr/bin/"
  66. if [ "x$OECORE_DISTRO_VERSION" = "x" ]; then
  67. echo "Have you run 'bitbake meta-ide-support'?"
  68. else
  69. echo "This shouldn't happen - something is wrong with your toolchain installation"
  70. fi
  71. if [ -z "$SKIP_STRICT_SYSROOT_CHECK" ]; then
  72. exit 1
  73. fi
  74. fi
  75. PSEUDO="$OECORE_NATIVE_SYSROOT/usr/bin/pseudo"