lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright (c) 2016, Intel Corporation. |
| 4 | # |
| 5 | # SPDX-License-Identifier: GPL-2.0-or-later |
| 6 | # |
| 7 | |
| 8 | # |
| 9 | # This script is for running tools from native oe sysroot |
| 10 | # |
| 11 | |
| 12 | if [ $# -lt 1 -o "$1" = '--help' -o "$1" = '-h' ] ; then |
| 13 | echo 'oe-run-native: the following arguments are required: <native recipe> <native tool>' |
| 14 | echo 'Usage: oe-run-native native-recipe tool [parameters]' |
| 15 | echo '' |
| 16 | echo 'OpenEmbedded run-native - runs native tools' |
| 17 | echo '' |
| 18 | echo 'arguments:' |
| 19 | echo ' native-recipe The recipe which provides tool' |
| 20 | echo ' tool Native tool to run' |
| 21 | echo '' |
| 22 | exit 2 |
| 23 | fi |
| 24 | |
| 25 | native_recipe="$1" |
| 26 | tool="$2" |
| 27 | |
| 28 | if [ "${native_recipe%-native}" = "$native_recipe" ]; then |
| 29 | echo Error: $native_recipe is not a native recipe |
| 30 | echo Error: Use \"oe-run-native -h\" for help |
| 31 | exit 1 |
| 32 | fi |
| 33 | |
| 34 | shift |
| 35 | |
| 36 | SYSROOT_SETUP_SCRIPT=`which oe-find-native-sysroot 2> /dev/null` |
| 37 | if [ -z "$SYSROOT_SETUP_SCRIPT" ]; then |
| 38 | echo "Error: Unable to find oe-find-native-sysroot script" |
| 39 | exit 1 |
| 40 | fi |
| 41 | . $SYSROOT_SETUP_SCRIPT $native_recipe |
| 42 | |
| 43 | OLD_PATH=$PATH |
| 44 | |
| 45 | # look for a tool only in native sysroot |
| 46 | PATH=$OECORE_NATIVE_SYSROOT/usr/bin:$OECORE_NATIVE_SYSROOT/bin:$OECORE_NATIVE_SYSROOT/usr/sbin:$OECORE_NATIVE_SYSROOT/sbin$(find $OECORE_NATIVE_SYSROOT/usr/bin -maxdepth 1 -name "*-native" -type d -printf ":%p") |
| 47 | tool_find=`/usr/bin/which $tool 2>/dev/null` |
| 48 | |
| 49 | if [ -n "$tool_find" ] ; then |
| 50 | # add old path to allow usage of host tools |
| 51 | PATH=$PATH:$OLD_PATH "$@" |
| 52 | else |
| 53 | echo "Error: Unable to find '$tool' in $PATH" |
| 54 | echo "Error: Have you run 'bitbake $native_recipe -caddto_recipe_sysroot'?" |
| 55 | exit 1 |
| 56 | fi |