oe-run-native 1.6 KB

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