oe-init-build-env 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/bin/sh
  2. # OE Build Environment Setup Script
  3. #
  4. # Copyright (C) 2006-2011 Linux Foundation
  5. #
  6. # SPDX-License-Identifier: GPL-2.0-or-later
  7. #
  8. #
  9. # Normally this is called as '. ./oe-init-build-env <builddir>'
  10. #
  11. # This works in most shells (not dash), but not all of them pass the arguments
  12. # when being sourced. To workaround the shell limitation use "set <builddir>"
  13. # prior to sourcing this script.
  14. #
  15. if [ -n "$BASH_SOURCE" ]; then
  16. THIS_SCRIPT=$BASH_SOURCE
  17. elif [ -n "$ZSH_NAME" ]; then
  18. THIS_SCRIPT=$0
  19. else
  20. THIS_SCRIPT="$(pwd)/oe-init-build-env"
  21. if [ ! -e "$THIS_SCRIPT" ]; then
  22. echo "Error: $THIS_SCRIPT doesn't exist!" >&2
  23. echo "Please run this script in oe-init-build-env's directory." >&2
  24. exit 1
  25. fi
  26. fi
  27. if [ -n "$BBSERVER" ]; then
  28. unset BBSERVER
  29. fi
  30. if [ -z "$ZSH_NAME" ] && [ "$0" = "$THIS_SCRIPT" ]; then
  31. echo "Error: This script needs to be sourced. Please run as '. $THIS_SCRIPT'" >&2
  32. exit 1
  33. fi
  34. if [ -z "$OEROOT" ]; then
  35. OEROOT=$(dirname "$THIS_SCRIPT")
  36. OEROOT=$(readlink -f "$OEROOT")
  37. fi
  38. unset THIS_SCRIPT
  39. export OEROOT
  40. . $OEROOT/scripts/oe-buildenv-internal &&
  41. TEMPLATECONF="$TEMPLATECONF" $OEROOT/scripts/oe-setup-builddir || {
  42. unset OEROOT
  43. return 1
  44. }
  45. unset OEROOT
  46. [ -z "$BUILDDIR" ] || cd "$BUILDDIR"