Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1 | #!/bin/bash |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 2 | # |
| 3 | # Copyright (c) 2016, Intel Corporation. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 4 | # |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 5 | # SPDX-License-Identifier: GPL-2.0-or-later |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 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 |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 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 provoides 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 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 31 | exit 1 |
| 32 | fi |
| 33 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 34 | shift |
| 35 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 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 |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 41 | . $SYSROOT_SETUP_SCRIPT $native_recipe |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 42 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 43 | OLD_PATH=$PATH |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 44 | |
| 45 | # look for a tool only in native sysroot |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 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/*-native -maxdepth 1 -type d -printf ":%p") |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 47 | tool_find=`/usr/bin/which $tool 2>/dev/null` |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 48 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 49 | if [ -n "$tool_find" ] ; then |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 50 | # add old path to allow usage of host tools |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 51 | PATH=$PATH:$OLD_PATH "$@" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 52 | else |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 53 | echo "Error: Unable to find '$tool' in $PATH" |
| 54 | echo "Error: Have you run 'bitbake $native_recipe -caddto_recipe_sysroot'?" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 55 | exit 1 |
| 56 | fi |