| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 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 |  | 
|  | 33 | if [ "x$OECORE_NATIVE_SYSROOT" = "x" ]; then | 
|  | 34 | BITBAKE=`which bitbake 2> /dev/null` | 
|  | 35 | if [ "x$BITBAKE" != "x" ]; then | 
|  | 36 | if [ "$UID" = "0" ]; then | 
|  | 37 | # Root cannot run bitbake unless sanity checking is disabled | 
|  | 38 | if [ ! -d "./conf" ]; then | 
|  | 39 | echo "Error: root cannot run bitbake by default, and I cannot find a ./conf directory to be able to disable sanity checking" | 
|  | 40 | exit 1 | 
|  | 41 | fi | 
|  | 42 | touch conf/sanity.conf | 
|  | 43 | OECORE_NATIVE_SYSROOT=`bitbake -e | grep ^STAGING_DIR_NATIVE | cut -d '"' -f2` | 
|  | 44 | rm -f conf/sanity.conf | 
|  | 45 | else | 
|  | 46 | OECORE_NATIVE_SYSROOT=`bitbake -e | grep ^STAGING_DIR_NATIVE | cut -d '"' -f2` | 
|  | 47 | fi | 
|  | 48 | else | 
|  | 49 | echo "Error: Unable to locate bitbake command." | 
|  | 50 | echo "Did you forget to source the build environment setup script?" | 
|  | 51 |  | 
|  | 52 | if [ -z "$SKIP_STRICT_SYSROOT_CHECK" ]; then | 
|  | 53 | exit 1 | 
|  | 54 | fi | 
|  | 55 | fi | 
|  | 56 | fi | 
|  | 57 |  | 
|  | 58 | if [ "x$OECORE_NATIVE_SYSROOT" = "x" ]; then | 
|  | 59 | # This indicates that there was an error running bitbake -e that | 
|  | 60 | # the user needs to be informed of | 
|  | 61 | echo "There was an error running bitbake to determine STAGING_DIR_NATIVE" | 
|  | 62 | echo "Here is the output from bitbake -e" | 
|  | 63 | bitbake -e | 
|  | 64 | exit 1 | 
|  | 65 | fi | 
|  | 66 |  | 
|  | 67 | # Set up pseudo command | 
|  | 68 | if [ ! -e "$OECORE_NATIVE_SYSROOT/usr/bin/pseudo" ]; then | 
|  | 69 | echo "Error: Unable to find pseudo binary in $OECORE_NATIVE_SYSROOT/usr/bin/" | 
|  | 70 |  | 
|  | 71 | if [ "x$OECORE_DISTRO_VERSION" = "x" ]; then | 
|  | 72 | echo "Have you run 'bitbake meta-ide-support'?" | 
|  | 73 | else | 
|  | 74 | echo "This shouldn't happen - something is wrong with your toolchain installation" | 
|  | 75 | fi | 
|  | 76 |  | 
|  | 77 | if [ -z "$SKIP_STRICT_SYSROOT_CHECK" ]; then | 
|  | 78 | exit 1 | 
|  | 79 | fi | 
|  | 80 | fi | 
|  | 81 | PSEUDO="$OECORE_NATIVE_SYSROOT/usr/bin/pseudo" |