oe-buildenv-internal 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. #!/bin/sh
  2. # OE-Core Build Environment Setup Script
  3. #
  4. # Copyright (C) 2006-2011 Linux Foundation
  5. #
  6. # SPDX-License-Identifier: GPL-2.0-or-later
  7. #
  8. if ! $(return >/dev/null 2>&1) ; then
  9. echo 'oe-buildenv-internal: error: this script must be sourced'
  10. echo ''
  11. echo 'Usage: . $OEROOT/scripts/oe-buildenv-internal &&'
  12. echo ''
  13. echo 'OpenEmbedded oe-buildenv-internal - an internal script that is'
  14. echo 'used in oe-init-build-env to initialize oe build environment'
  15. echo ''
  16. exit 2
  17. fi
  18. # It is assumed OEROOT is already defined when this is called
  19. if [ -z "$OEROOT" ]; then
  20. echo >&2 "Error: OEROOT is not defined!"
  21. return 1
  22. fi
  23. if [ -z "$OE_SKIP_SDK_CHECK" ] && [ -n "$OECORE_SDK_VERSION" ]; then
  24. echo >&2 "Error: The OE SDK/ADT was detected as already being present in this shell environment. Please use a clean shell when sourcing this environment script."
  25. return 1
  26. fi
  27. # We potentially have code that doesn't parse correctly with older versions
  28. # of Python, and rather than fixing that and being eternally vigilant for
  29. # any other new feature use, just check the version here.
  30. py_v35_check=$(python3 -c 'import sys; print(sys.version_info >= (3,5,0))')
  31. if [ "$py_v35_check" != "True" ]; then
  32. echo >&2 "BitBake requires Python 3.5.0 or later as 'python3 (scripts/install-buildtools can be used if needed)'"
  33. return 1
  34. fi
  35. unset py_v35_check
  36. if [ -z "$BDIR" ]; then
  37. if [ -z "$1" ]; then
  38. BDIR="build"
  39. else
  40. BDIR="$1"
  41. if [ "$BDIR" = "/" ]; then
  42. echo >&2 "Error: / is not supported as a build directory."
  43. return 1
  44. fi
  45. # Remove any possible trailing slashes. This is used to work around
  46. # buggy readlink in Ubuntu 10.04 that doesn't ignore trailing slashes
  47. # and hence "readlink -f new_dir_to_be_created/" returns empty.
  48. BDIR=$(echo $BDIR | sed -re 's|/+$||')
  49. BDIR=$(readlink -f "$BDIR")
  50. if [ -z "$BDIR" ]; then
  51. PARENTDIR=$(dirname "$1")
  52. echo >&2 "Error: the directory $PARENTDIR does not exist?"
  53. return 1
  54. fi
  55. fi
  56. if [ -n "$2" ]; then
  57. BITBAKEDIR="$2"
  58. fi
  59. fi
  60. if [ "${BDIR#/}" != "$BDIR" ]; then
  61. BUILDDIR="$BDIR"
  62. else
  63. BUILDDIR="$(pwd)/$BDIR"
  64. fi
  65. unset BDIR
  66. if [ -z "$BITBAKEDIR" ]; then
  67. BITBAKEDIR="$OEROOT/bitbake$BBEXTRA"
  68. test -d "$BITBAKEDIR" || BITBAKEDIR="$OEROOT/../bitbake$BBEXTRA"
  69. fi
  70. BITBAKEDIR=$(readlink -f "$BITBAKEDIR")
  71. BUILDDIR=$(readlink -f "$BUILDDIR")
  72. BBPATH=$BUILDDIR
  73. export BBPATH
  74. if [ ! -d "$BITBAKEDIR" ]; then
  75. echo >&2 "Error: The bitbake directory ($BITBAKEDIR) does not exist! Please ensure a copy of bitbake exists at this location or specify an alternative path on the command line"
  76. return 1
  77. fi
  78. # Make sure our paths are at the beginning of $PATH
  79. for newpath in "$BITBAKEDIR/bin" "$OEROOT/scripts"; do
  80. # Remove any existences of $newpath from $PATH
  81. PATH=$(echo $PATH | sed -re "s#(^|:)$newpath(:|$)#\2#g;s#^:##")
  82. # Add $newpath to $PATH
  83. PATH="$newpath:$PATH"
  84. done
  85. unset BITBAKEDIR newpath
  86. # Used by the runqemu script
  87. export BUILDDIR
  88. export PATH
  89. BB_ENV_EXTRAWHITE_OE="MACHINE DISTRO TCMODE TCLIBC HTTP_PROXY http_proxy \
  90. HTTPS_PROXY https_proxy FTP_PROXY ftp_proxy FTPS_PROXY ftps_proxy ALL_PROXY \
  91. all_proxy NO_PROXY no_proxy SSH_AGENT_PID SSH_AUTH_SOCK BB_SRCREV_POLICY \
  92. SDKMACHINE BB_NUMBER_THREADS BB_NO_NETWORK PARALLEL_MAKE GIT_PROXY_COMMAND \
  93. SOCKS5_PASSWD SOCKS5_USER SCREENDIR STAMPS_DIR BBPATH_EXTRA BB_SETSCENE_ENFORCE \
  94. BB_LOGCONFIG"
  95. BB_ENV_EXTRAWHITE="$(echo $BB_ENV_EXTRAWHITE $BB_ENV_EXTRAWHITE_OE | tr ' ' '\n' | LC_ALL=C sort --unique | tr '\n' ' ')"
  96. export BB_ENV_EXTRAWHITE