oe-init-build-env-memres 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 [ -z "$ZSH_NAME" ] && [ "x$0" = "x./oe-init-build-env" ]; then
  34. echo "Error: This script needs to be sourced. Please run as '. ./oe-init-build-env'"
  35. else
  36. if [ -n "$BASH_SOURCE" ]; then
  37. OEROOT="`dirname $BASH_SOURCE`"
  38. elif [ -n "$ZSH_NAME" ]; then
  39. OEROOT="`dirname $0`"
  40. else
  41. OEROOT="`pwd`"
  42. fi
  43. if [ -n "$BBSERVER" ]; then
  44. unset BBSERVER
  45. fi
  46. OEROOT=`readlink -f "$OEROOT"`
  47. export OEROOT
  48. . $OEROOT/scripts/oe-buildenv-internal && \
  49. $OEROOT/scripts/oe-setup-builddir && \
  50. [ -n "$BUILDDIR" ] && cd $BUILDDIR
  51. unset OEROOT
  52. unset BBPATH
  53. fi
  54. res=1
  55. if [ -e bitbake.lock ] && grep : bitbake.lock > /dev/null ; then
  56. BBSERVER=`cat bitbake.lock` bitbake --status-only
  57. res=$?
  58. fi
  59. if [ $port = -1 ] ; then
  60. export BBSERVER=localhost:-1
  61. echo "Bitbake server started on demand as needed, use bitbake -m to shut it down"
  62. else
  63. if [ $res != 0 ] ; then
  64. bitbake --server-only -t xmlrpc -B localhost:$port
  65. fi
  66. export BBSERVER=`cat bitbake.lock`
  67. if [ $res = 0 ] ; then
  68. echo "Using existing bitbake server at: $BBSERVER, use bitbake -m to shut it down"
  69. else
  70. echo "Bitbake server started at: $BBSERVER, use bitbake -m to shut it down"
  71. fi
  72. unset res
  73. fi