oe-init-build-env-memres 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 builddir <portnumber> <builddir>'
  21. #
  22. # This works in most shells (not dash), but not all of them pass arg1 when
  23. # being sourced. To workaround the shell limitation use "set arg1" prior
  24. # 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. OEROOT="`dirname $BASH_SOURCE`"
  35. elif [ -n "$ZSH_NAME" ]; then
  36. OEROOT="`dirname $0`"
  37. else
  38. OEROOT="`pwd`"
  39. fi
  40. if [ -n "$BBSERVER" ]; then
  41. unset BBSERVER
  42. fi
  43. THIS_SCRIPT=$OEROOT/oe-init-build-env-memres
  44. if [ -z "$ZSH_NAME" ] && [ "x$0" = "x$THIS_SCRIPT" ]; then
  45. echo "Error: This script needs to be sourced. Please run as '. $THIS_SCRIPT'"
  46. exit 1
  47. fi
  48. OEROOT=`readlink -f "$OEROOT"`
  49. export OEROOT
  50. . $OEROOT/scripts/oe-buildenv-internal && \
  51. $OEROOT/scripts/oe-setup-builddir && \
  52. [ -n "$BUILDDIR" ] && cd $BUILDDIR
  53. unset OEROOT
  54. unset BBPATH
  55. unset THIS_SCRIPT
  56. res=1
  57. if [ -e bitbake.lock ] && grep : bitbake.lock > /dev/null ; then
  58. BBSERVER=`cat bitbake.lock` bitbake --status-only
  59. res=$?
  60. fi
  61. if [ $res != 0 ] ; then
  62. bitbake --server-only -t xmlrpc -B localhost:$port
  63. fi
  64. if [ $port = -1 ] ; then
  65. export BBSERVER=localhost:-1
  66. echo "Bitbake server started on demand as needed, use bitbake -m to shut it down"
  67. else
  68. export BBSERVER=`cat bitbake.lock`
  69. if [ $res = 0 ] ; then
  70. echo "Using existing bitbake server at: $BBSERVER, use bitbake -m to shut it down"
  71. else
  72. echo "Bitbake server started at: $BBSERVER, use bitbake -m to shut it down"
  73. fi
  74. unset res
  75. fi