blob: bea5d696d7001653057b9cace3dcb0cf7d004e03 [file] [log] [blame]
Brad Bishop6e60e8b2018-02-01 10:27:11 -05001#!/bin/bash
Patrick Williamsc0f7c042017-02-23 20:41:17 -06002#
3# Copyright (c) 2016, Intel Corporation.
Patrick Williamsc0f7c042017-02-23 20:41:17 -06004#
Brad Bishopc342db32019-05-15 21:57:59 -04005# SPDX-License-Identifier: GPL-2.0-or-later
Patrick Williamsc0f7c042017-02-23 20:41:17 -06006#
7
8#
9# This script is for running tools from native oe sysroot
10#
11
12if [ $# -lt 1 -o "$1" = '--help' -o "$1" = '-h' ] ; then
Brad Bishop6e60e8b2018-02-01 10:27:11 -050013 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
23fi
24
25native_recipe="$1"
26tool="$2"
27
28if [ "${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 Williamsc0f7c042017-02-23 20:41:17 -060031 exit 1
32fi
33
Brad Bishop6e60e8b2018-02-01 10:27:11 -050034shift
35
Patrick Williamsc0f7c042017-02-23 20:41:17 -060036SYSROOT_SETUP_SCRIPT=`which oe-find-native-sysroot 2> /dev/null`
37if [ -z "$SYSROOT_SETUP_SCRIPT" ]; then
38 echo "Error: Unable to find oe-find-native-sysroot script"
39 exit 1
40fi
Brad Bishop6e60e8b2018-02-01 10:27:11 -050041. $SYSROOT_SETUP_SCRIPT $native_recipe
Patrick Williamsc0f7c042017-02-23 20:41:17 -060042
Brad Bishop6e60e8b2018-02-01 10:27:11 -050043OLD_PATH=$PATH
Patrick Williamsc0f7c042017-02-23 20:41:17 -060044
45# look for a tool only in native sysroot
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080046PATH=$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 Bishop6e60e8b2018-02-01 10:27:11 -050047tool_find=`/usr/bin/which $tool 2>/dev/null`
Patrick Williamsc0f7c042017-02-23 20:41:17 -060048
Brad Bishop6e60e8b2018-02-01 10:27:11 -050049if [ -n "$tool_find" ] ; then
Patrick Williamsc0f7c042017-02-23 20:41:17 -060050 # add old path to allow usage of host tools
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080051 PATH=$PATH:$OLD_PATH "$@"
Patrick Williamsc0f7c042017-02-23 20:41:17 -060052else
Brad Bishop6e60e8b2018-02-01 10:27:11 -050053 echo "Error: Unable to find '$tool' in $PATH"
54 echo "Error: Have you run 'bitbake $native_recipe -caddto_recipe_sysroot'?"
Patrick Williamsc0f7c042017-02-23 20:41:17 -060055 exit 1
56fi