blob: c8905524ff5d89fab26b19b931e1f7ca64340332 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001#!/bin/sh
2
3# OE-Core Build Environment Setup Script
4#
5# Copyright (C) 2006-2011 Linux Foundation
6#
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 2 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program; if not, write to the Free Software
19# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
Brad Bishop6e60e8b2018-02-01 10:27:11 -050021if ! $(return >/dev/null 2>&1) ; then
22 echo 'oe-buildenv-internal: error: this script must be sourced'
23 echo ''
24 echo 'Usage: . $OEROOT/scripts/oe-buildenv-internal &&'
25 echo ''
26 echo 'OpenEmbedded oe-buildenv-internal - an internal script that is'
27 echo 'used in oe-init-build-env and oe-init-build-env-memres to'
28 echo 'initialize oe build environment'
29 echo ''
30 exit 2
31fi
32
Patrick Williamsc124f4f2015-09-15 14:41:29 -050033# It is assumed OEROOT is already defined when this is called
34if [ -z "$OEROOT" ]; then
35 echo >&2 "Error: OEROOT is not defined!"
36 return 1
37fi
38
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050039if [ -z "$OE_SKIP_SDK_CHECK" ] && [ -n "$OECORE_SDK_VERSION" ]; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -050040 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."
41 return 1
42fi
43
Patrick Williamsc0f7c042017-02-23 20:41:17 -060044# Make sure we're not using python v3.x as 'python', we don't support it.
45py_v2_check=$(/usr/bin/env python --version 2>&1 | grep "Python 3")
46if [ -n "$py_v2_check" ]; then
47 echo >&2 "OpenEmbedded requires 'python' to be python v2 (>= 2.7.3), not python v3."
48 echo >&2 "Please set up python v2 as your default 'python' interpreter."
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050049 return 1
Patrick Williamsc124f4f2015-09-15 14:41:29 -050050fi
Patrick Williamsc0f7c042017-02-23 20:41:17 -060051unset py_v2_check
Patrick Williamsc124f4f2015-09-15 14:41:29 -050052
Patrick Williamsc0f7c042017-02-23 20:41:17 -060053py_v27_check=$(python -c 'import sys; print sys.version_info >= (2,7,3)')
54if [ "$py_v27_check" != "True" ]; then
55 echo >&2 "OpenEmbedded requires 'python' to be python v2 (>= 2.7.3), not python v3."
56 echo >&2 "Please upgrade your python v2."
57fi
58unset py_v27_check
59
60# We potentially have code that doesn't parse correctly with older versions
61# of Python, and rather than fixing that and being eternally vigilant for
62# any other new feature use, just check the version here.
63py_v34_check=$(python3 -c 'import sys; print(sys.version_info >= (3,4,0))')
64if [ "$py_v34_check" != "True" ]; then
65 echo >&2 "BitBake requires Python 3.4.0 or later as 'python3'"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050066 return 1
Patrick Williamsc124f4f2015-09-15 14:41:29 -050067fi
Patrick Williamsc0f7c042017-02-23 20:41:17 -060068unset py_v34_check
Patrick Williamsc124f4f2015-09-15 14:41:29 -050069
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050070if [ -z "$BDIR" ]; then
71 if [ -z "$1" ]; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -050072 BDIR="build"
73 else
74 BDIR="$1"
75 if [ "$BDIR" = "/" ]; then
76 echo >&2 "Error: / is not supported as a build directory."
77 return 1
78 fi
79
80 # Remove any possible trailing slashes. This is used to work around
81 # buggy readlink in Ubuntu 10.04 that doesn't ignore trailing slashes
82 # and hence "readlink -f new_dir_to_be_created/" returns empty.
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050083 BDIR=$(echo $BDIR | sed -re 's|/+$||')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050084
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050085 BDIR=$(readlink -f "$BDIR")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050086 if [ -z "$BDIR" ]; then
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050087 PARENTDIR=$(dirname "$1")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050088 echo >&2 "Error: the directory $PARENTDIR does not exist?"
89 return 1
90 fi
91 fi
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050092 if [ -n "$2" ]; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -050093 BITBAKEDIR="$2"
94 fi
95fi
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050096if [ "${BDIR#/}" != "$BDIR" ]; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -050097 BUILDDIR="$BDIR"
98else
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050099 BUILDDIR="$(pwd)/$BDIR"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500100fi
101unset BDIR
102
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500103if [ -z "$BITBAKEDIR" ]; then
104 BITBAKEDIR="$OEROOT/bitbake$BBEXTRA"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500105fi
106
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500107BITBAKEDIR=$(readlink -f "$BITBAKEDIR")
108BUILDDIR=$(readlink -f "$BUILDDIR")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500109
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500110if [ ! -d "$BITBAKEDIR" ]; then
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600111 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 Williamsc124f4f2015-09-15 14:41:29 -0500112 return 1
113fi
114
115# Make sure our paths are at the beginning of $PATH
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500116for newpath in "$BITBAKEDIR/bin" "$OEROOT/scripts"; do
117 # Remove any existences of $newpath from $PATH
118 PATH=$(echo $PATH | sed -re "s#(^|:)$newpath(:|$)#\2#g;s#^:##")
119
120 # Add $newpath to $PATH
121 PATH="$newpath:$PATH"
122done
123unset BITBAKEDIR newpath
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500124
125# Used by the runqemu script
126export BUILDDIR
127export PATH
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500128
129BB_ENV_EXTRAWHITE_OE="MACHINE DISTRO TCMODE TCLIBC HTTP_PROXY http_proxy \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500130HTTPS_PROXY https_proxy FTP_PROXY ftp_proxy FTPS_PROXY ftps_proxy ALL_PROXY \
131all_proxy NO_PROXY no_proxy SSH_AGENT_PID SSH_AUTH_SOCK BB_SRCREV_POLICY \
132SDKMACHINE BB_NUMBER_THREADS BB_NO_NETWORK PARALLEL_MAKE GIT_PROXY_COMMAND \
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600133SOCKS5_PASSWD SOCKS5_USER SCREENDIR STAMPS_DIR BBPATH_EXTRA BB_SETSCENE_ENFORCE"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500134
135BB_ENV_EXTRAWHITE="$(echo $BB_ENV_EXTRAWHITE $BB_ENV_EXTRAWHITE_OE | tr ' ' '\n' | LC_ALL=C sort --unique | tr '\n' ' ')"
136
137export BB_ENV_EXTRAWHITE