blob: 77f98a32b96a4b927b5cc7fc08caf4415d37081f [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'
Brad Bishopd7bf8c12018-02-25 22:55:05 -050027 echo 'used in oe-init-build-env to initialize oe build environment'
Brad Bishop6e60e8b2018-02-01 10:27:11 -050028 echo ''
29 exit 2
30fi
31
Patrick Williamsc124f4f2015-09-15 14:41:29 -050032# It is assumed OEROOT is already defined when this is called
33if [ -z "$OEROOT" ]; then
34 echo >&2 "Error: OEROOT is not defined!"
35 return 1
36fi
37
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050038if [ -z "$OE_SKIP_SDK_CHECK" ] && [ -n "$OECORE_SDK_VERSION" ]; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -050039 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."
40 return 1
41fi
42
Patrick Williamsc0f7c042017-02-23 20:41:17 -060043# Make sure we're not using python v3.x as 'python', we don't support it.
44py_v2_check=$(/usr/bin/env python --version 2>&1 | grep "Python 3")
45if [ -n "$py_v2_check" ]; then
46 echo >&2 "OpenEmbedded requires 'python' to be python v2 (>= 2.7.3), not python v3."
47 echo >&2 "Please set up python v2 as your default 'python' interpreter."
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050048 return 1
Patrick Williamsc124f4f2015-09-15 14:41:29 -050049fi
Patrick Williamsc0f7c042017-02-23 20:41:17 -060050unset py_v2_check
Patrick Williamsc124f4f2015-09-15 14:41:29 -050051
Patrick Williamsc0f7c042017-02-23 20:41:17 -060052py_v27_check=$(python -c 'import sys; print sys.version_info >= (2,7,3)')
53if [ "$py_v27_check" != "True" ]; then
54 echo >&2 "OpenEmbedded requires 'python' to be python v2 (>= 2.7.3), not python v3."
55 echo >&2 "Please upgrade your python v2."
56fi
57unset py_v27_check
58
59# We potentially have code that doesn't parse correctly with older versions
60# of Python, and rather than fixing that and being eternally vigilant for
61# any other new feature use, just check the version here.
62py_v34_check=$(python3 -c 'import sys; print(sys.version_info >= (3,4,0))')
63if [ "$py_v34_check" != "True" ]; then
64 echo >&2 "BitBake requires Python 3.4.0 or later as 'python3'"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050065 return 1
Patrick Williamsc124f4f2015-09-15 14:41:29 -050066fi
Patrick Williamsc0f7c042017-02-23 20:41:17 -060067unset py_v34_check
Patrick Williamsc124f4f2015-09-15 14:41:29 -050068
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050069if [ -z "$BDIR" ]; then
70 if [ -z "$1" ]; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -050071 BDIR="build"
72 else
73 BDIR="$1"
74 if [ "$BDIR" = "/" ]; then
75 echo >&2 "Error: / is not supported as a build directory."
76 return 1
77 fi
78
79 # Remove any possible trailing slashes. This is used to work around
80 # buggy readlink in Ubuntu 10.04 that doesn't ignore trailing slashes
81 # and hence "readlink -f new_dir_to_be_created/" returns empty.
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050082 BDIR=$(echo $BDIR | sed -re 's|/+$||')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050083
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050084 BDIR=$(readlink -f "$BDIR")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050085 if [ -z "$BDIR" ]; then
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050086 PARENTDIR=$(dirname "$1")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050087 echo >&2 "Error: the directory $PARENTDIR does not exist?"
88 return 1
89 fi
90 fi
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050091 if [ -n "$2" ]; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -050092 BITBAKEDIR="$2"
93 fi
94fi
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050095if [ "${BDIR#/}" != "$BDIR" ]; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -050096 BUILDDIR="$BDIR"
97else
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050098 BUILDDIR="$(pwd)/$BDIR"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050099fi
100unset BDIR
101
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500102if [ -z "$BITBAKEDIR" ]; then
103 BITBAKEDIR="$OEROOT/bitbake$BBEXTRA"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500104fi
105
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500106BITBAKEDIR=$(readlink -f "$BITBAKEDIR")
107BUILDDIR=$(readlink -f "$BUILDDIR")
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500108BBPATH=$BUILDDIR
109
110export BBPATH
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500111
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500112if [ ! -d "$BITBAKEDIR" ]; then
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600113 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 -0500114 return 1
115fi
116
117# Make sure our paths are at the beginning of $PATH
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500118for newpath in "$BITBAKEDIR/bin" "$OEROOT/scripts"; do
119 # Remove any existences of $newpath from $PATH
120 PATH=$(echo $PATH | sed -re "s#(^|:)$newpath(:|$)#\2#g;s#^:##")
121
122 # Add $newpath to $PATH
123 PATH="$newpath:$PATH"
124done
125unset BITBAKEDIR newpath
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500126
127# Used by the runqemu script
128export BUILDDIR
129export PATH
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500130
131BB_ENV_EXTRAWHITE_OE="MACHINE DISTRO TCMODE TCLIBC HTTP_PROXY http_proxy \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500132HTTPS_PROXY https_proxy FTP_PROXY ftp_proxy FTPS_PROXY ftps_proxy ALL_PROXY \
133all_proxy NO_PROXY no_proxy SSH_AGENT_PID SSH_AUTH_SOCK BB_SRCREV_POLICY \
134SDKMACHINE BB_NUMBER_THREADS BB_NO_NETWORK PARALLEL_MAKE GIT_PROXY_COMMAND \
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600135SOCKS5_PASSWD SOCKS5_USER SCREENDIR STAMPS_DIR BBPATH_EXTRA BB_SETSCENE_ENFORCE"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500136
137BB_ENV_EXTRAWHITE="$(echo $BB_ENV_EXTRAWHITE $BB_ENV_EXTRAWHITE_OE | tr ' ' '\n' | LC_ALL=C sort --unique | tr '\n' ' ')"
138
139export BB_ENV_EXTRAWHITE