oe-init-build-env-memres 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #!/bin/sh
  2. # OE Build Environment Setup Script
  3. #
  4. # Copyright (C) 2006-2011 Linux Foundation
  5. #
  6. # This program is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation; either version 2 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program; if not, write to the Free Software
  18. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. #
  20. # Normally this is called as '. ./oe-init-build-env-memres <portnumber> <builddir>'
  21. #
  22. # This works in most shells (not dash), but not all of them pass the arguments
  23. # when being sourced. To workaround the shell limitation use "set <portnumber>
  24. # <builddir>" prior to sourcing this script.
  25. #
  26. if [ -z "$1" ]; then
  27. echo "No port specified, using dynamically selected port"
  28. port=-1
  29. else
  30. port=$1
  31. shift
  32. fi
  33. if [ -n "$BASH_SOURCE" ]; then
  34. THIS_SCRIPT=$BASH_SOURCE
  35. elif [ -n "$ZSH_NAME" ]; then
  36. THIS_SCRIPT=$0
  37. else
  38. THIS_SCRIPT="$(pwd)/oe-init-build-env"
  39. fi
  40. if [ -n "$BBSERVER" ]; then
  41. unset BBSERVER
  42. fi
  43. if [ -z "$ZSH_NAME" ] && [ "$0" = "$THIS_SCRIPT" ]; then
  44. echo "Error: This script needs to be sourced. Please run as '. $THIS_SCRIPT'"
  45. exit 1
  46. fi
  47. if [ -z "$OEROOT" ]; then
  48. OEROOT=$(dirname "$THIS_SCRIPT")
  49. OEROOT=$(readlink -f "$OEROOT")
  50. fi
  51. unset THIS_SCRIPT
  52. export OEROOT
  53. . $OEROOT/scripts/oe-buildenv-internal &&
  54. TEMPLATECONF="$TEMPLATECONF" $OEROOT/scripts/oe-setup-builddir || {
  55. unset OEROOT
  56. return 1
  57. }
  58. unset OEROOT
  59. [ -z "$BUILDDIR" ] || cd "$BUILDDIR"
  60. res=1
  61. if [ -e bitbake.lock ] && grep : bitbake.lock > /dev/null; then
  62. BBSERVER=$(cat bitbake.lock) bitbake --status-only
  63. res=$?
  64. fi
  65. if [ $res != 0 ]; then
  66. bitbake --server-only -t xmlrpc -B localhost:$port
  67. fi
  68. if [ $port = -1 ]; then
  69. export BBSERVER=localhost:-1
  70. echo "Bitbake server started on demand as needed, use bitbake -m to shut it down"
  71. else
  72. export BBSERVER=$(cat bitbake.lock)
  73. if [ $res = 0 ]; then
  74. echo "Using existing bitbake server at: $BBSERVER, use bitbake -m to shut it down"
  75. else
  76. echo "Bitbake server started at: $BBSERVER, use bitbake -m to shut it down"
  77. fi
  78. fi
  79. unset port res