| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | #!/bin/sh | 
|  | 2 |  | 
|  | 3 | # OE-Core Build Environment Setup Script | 
|  | 4 | # | 
|  | 5 | # Copyright (C) 2006-2011 Linux Foundation | 
|  | 6 | # | 
| Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame^] | 7 | # SPDX-License-Identifier: GPL-2.0-or-later | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8 | # | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9 |  | 
| Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 10 | if ! $(return >/dev/null 2>&1) ; then | 
|  | 11 | echo 'oe-buildenv-internal: error: this script must be sourced' | 
|  | 12 | echo '' | 
|  | 13 | echo 'Usage: . $OEROOT/scripts/oe-buildenv-internal &&' | 
|  | 14 | echo '' | 
|  | 15 | echo 'OpenEmbedded oe-buildenv-internal - an internal script that is' | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 16 | echo 'used in oe-init-build-env to initialize oe build environment' | 
| Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 17 | echo '' | 
|  | 18 | exit 2 | 
|  | 19 | fi | 
|  | 20 |  | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 21 | # It is assumed OEROOT is already defined when this is called | 
|  | 22 | if [ -z "$OEROOT" ]; then | 
|  | 23 | echo >&2 "Error: OEROOT is not defined!" | 
|  | 24 | return 1 | 
|  | 25 | fi | 
|  | 26 |  | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 27 | if [ -z "$OE_SKIP_SDK_CHECK" ] && [ -n "$OECORE_SDK_VERSION" ]; then | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 28 | 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." | 
|  | 29 | return 1 | 
|  | 30 | fi | 
|  | 31 |  | 
| Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 32 | py_v27_check=$(python2 -c 'import sys; print sys.version_info >= (2,7,3)') | 
| Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 33 | if [ "$py_v27_check" != "True" ]; then | 
|  | 34 | echo >&2 "OpenEmbedded requires 'python' to be python v2 (>= 2.7.3), not python v3." | 
|  | 35 | echo >&2 "Please upgrade your python v2." | 
|  | 36 | fi | 
|  | 37 | unset py_v27_check | 
|  | 38 |  | 
|  | 39 | # We potentially have code that doesn't parse correctly with older versions | 
|  | 40 | # of Python, and rather than fixing that and being eternally vigilant for | 
|  | 41 | # any other new feature use, just check the version here. | 
|  | 42 | py_v34_check=$(python3 -c 'import sys; print(sys.version_info >= (3,4,0))') | 
|  | 43 | if [ "$py_v34_check" != "True" ]; then | 
|  | 44 | echo >&2 "BitBake requires Python 3.4.0 or later as 'python3'" | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 45 | return 1 | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 46 | fi | 
| Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 47 | unset py_v34_check | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 48 |  | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 49 | if [ -z "$BDIR" ]; then | 
|  | 50 | if [ -z "$1" ]; then | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 51 | BDIR="build" | 
|  | 52 | else | 
|  | 53 | BDIR="$1" | 
|  | 54 | if [ "$BDIR" = "/" ]; then | 
|  | 55 | echo >&2 "Error: / is not supported as a build directory." | 
|  | 56 | return 1 | 
|  | 57 | fi | 
|  | 58 |  | 
|  | 59 | # Remove any possible trailing slashes. This is used to work around | 
|  | 60 | # buggy readlink in Ubuntu 10.04 that doesn't ignore trailing slashes | 
|  | 61 | # and hence "readlink -f new_dir_to_be_created/" returns empty. | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 62 | BDIR=$(echo $BDIR | sed -re 's|/+$||') | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 63 |  | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 64 | BDIR=$(readlink -f "$BDIR") | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 65 | if [ -z "$BDIR" ]; then | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 66 | PARENTDIR=$(dirname "$1") | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 67 | echo >&2 "Error: the directory $PARENTDIR does not exist?" | 
|  | 68 | return 1 | 
|  | 69 | fi | 
|  | 70 | fi | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 71 | if [ -n "$2" ]; then | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 72 | BITBAKEDIR="$2" | 
|  | 73 | fi | 
|  | 74 | fi | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 75 | if [ "${BDIR#/}" != "$BDIR" ]; then | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 76 | BUILDDIR="$BDIR" | 
|  | 77 | else | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 78 | BUILDDIR="$(pwd)/$BDIR" | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 79 | fi | 
|  | 80 | unset BDIR | 
|  | 81 |  | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 82 | if [ -z "$BITBAKEDIR" ]; then | 
|  | 83 | BITBAKEDIR="$OEROOT/bitbake$BBEXTRA" | 
| Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 84 | test -d "$BITBAKEDIR" || BITBAKEDIR="$OEROOT/../bitbake$BBEXTRA" | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 85 | fi | 
|  | 86 |  | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 87 | BITBAKEDIR=$(readlink -f "$BITBAKEDIR") | 
|  | 88 | BUILDDIR=$(readlink -f "$BUILDDIR") | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 89 | BBPATH=$BUILDDIR | 
|  | 90 |  | 
|  | 91 | export BBPATH | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 92 |  | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 93 | if [ ! -d "$BITBAKEDIR" ]; then | 
| Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 94 | 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" | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 95 | return 1 | 
|  | 96 | fi | 
|  | 97 |  | 
|  | 98 | # Make sure our paths are at the beginning of $PATH | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 99 | for newpath in "$BITBAKEDIR/bin" "$OEROOT/scripts"; do | 
|  | 100 | # Remove any existences of $newpath from $PATH | 
|  | 101 | PATH=$(echo $PATH | sed -re "s#(^|:)$newpath(:|$)#\2#g;s#^:##") | 
|  | 102 |  | 
|  | 103 | # Add $newpath to $PATH | 
|  | 104 | PATH="$newpath:$PATH" | 
|  | 105 | done | 
|  | 106 | unset BITBAKEDIR newpath | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 107 |  | 
|  | 108 | # Used by the runqemu script | 
|  | 109 | export BUILDDIR | 
|  | 110 | export PATH | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 111 |  | 
|  | 112 | BB_ENV_EXTRAWHITE_OE="MACHINE DISTRO TCMODE TCLIBC HTTP_PROXY http_proxy \ | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 113 | HTTPS_PROXY https_proxy FTP_PROXY ftp_proxy FTPS_PROXY ftps_proxy ALL_PROXY \ | 
|  | 114 | all_proxy NO_PROXY no_proxy SSH_AGENT_PID SSH_AUTH_SOCK BB_SRCREV_POLICY \ | 
|  | 115 | SDKMACHINE BB_NUMBER_THREADS BB_NO_NETWORK PARALLEL_MAKE GIT_PROXY_COMMAND \ | 
| Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 116 | SOCKS5_PASSWD SOCKS5_USER SCREENDIR STAMPS_DIR BBPATH_EXTRA BB_SETSCENE_ENFORCE" | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 117 |  | 
|  | 118 | BB_ENV_EXTRAWHITE="$(echo $BB_ENV_EXTRAWHITE $BB_ENV_EXTRAWHITE_OE | tr ' ' '\n' | LC_ALL=C sort --unique | tr '\n' ' ')" | 
|  | 119 |  | 
|  | 120 | export BB_ENV_EXTRAWHITE |