blob: 2fdb19565a0a208295290ac97dd0077f12a4ba3e [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#
Brad Bishopc342db32019-05-15 21:57:59 -04007# SPDX-License-Identifier: GPL-2.0-or-later
Patrick Williamsc124f4f2015-09-15 14:41:29 -05008#
Patrick Williamsc124f4f2015-09-15 14:41:29 -05009
Brad Bishop6e60e8b2018-02-01 10:27:11 -050010if ! $(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 Bishopd7bf8c12018-02-25 22:55:05 -050016 echo 'used in oe-init-build-env to initialize oe build environment'
Brad Bishop6e60e8b2018-02-01 10:27:11 -050017 echo ''
18 exit 2
19fi
20
Patrick Williamsc124f4f2015-09-15 14:41:29 -050021# It is assumed OEROOT is already defined when this is called
22if [ -z "$OEROOT" ]; then
23 echo >&2 "Error: OEROOT is not defined!"
24 return 1
25fi
26
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050027if [ -z "$OE_SKIP_SDK_CHECK" ] && [ -n "$OECORE_SDK_VERSION" ]; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -050028 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
30fi
31
Patrick Williamsc0f7c042017-02-23 20:41:17 -060032# We potentially have code that doesn't parse correctly with older versions
33# of Python, and rather than fixing that and being eternally vigilant for
34# any other new feature use, just check the version here.
Andrew Geissler5082cc72023-09-11 08:41:39 -040035py_v38_check=$(python3 -c 'import sys; print(sys.version_info >= (3,8,0))')
36if [ "$py_v38_check" != "True" ]; then
37 echo >&2 "BitBake requires Python 3.8.0 or later as 'python3' (scripts/install-buildtools can be used if needed)"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050038 return 1
Patrick Williamsc124f4f2015-09-15 14:41:29 -050039fi
Andrew Geissler5082cc72023-09-11 08:41:39 -040040unset py_v38_check
Patrick Williamsc124f4f2015-09-15 14:41:29 -050041
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050042if [ -z "$BDIR" ]; then
43 if [ -z "$1" ]; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -050044 BDIR="build"
45 else
46 BDIR="$1"
47 if [ "$BDIR" = "/" ]; then
48 echo >&2 "Error: / is not supported as a build directory."
49 return 1
50 fi
51
52 # Remove any possible trailing slashes. This is used to work around
53 # buggy readlink in Ubuntu 10.04 that doesn't ignore trailing slashes
54 # and hence "readlink -f new_dir_to_be_created/" returns empty.
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050055 BDIR=$(echo $BDIR | sed -re 's|/+$||')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050056
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050057 BDIR=$(readlink -f "$BDIR")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050058 if [ -z "$BDIR" ]; then
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050059 PARENTDIR=$(dirname "$1")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050060 echo >&2 "Error: the directory $PARENTDIR does not exist?"
61 return 1
62 fi
63 fi
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050064 if [ -n "$2" ]; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -050065 BITBAKEDIR="$2"
66 fi
67fi
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050068if [ "${BDIR#/}" != "$BDIR" ]; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -050069 BUILDDIR="$BDIR"
70else
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050071 BUILDDIR="$(pwd)/$BDIR"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050072fi
73unset BDIR
74
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050075if [ -z "$BITBAKEDIR" ]; then
76 BITBAKEDIR="$OEROOT/bitbake$BBEXTRA"
Brad Bishop316dfdd2018-06-25 12:45:53 -040077 test -d "$BITBAKEDIR" || BITBAKEDIR="$OEROOT/../bitbake$BBEXTRA"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050078fi
79
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050080BITBAKEDIR=$(readlink -f "$BITBAKEDIR")
81BUILDDIR=$(readlink -f "$BUILDDIR")
Brad Bishopd7bf8c12018-02-25 22:55:05 -050082BBPATH=$BUILDDIR
83
84export BBPATH
Patrick Williamsc124f4f2015-09-15 14:41:29 -050085
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050086if [ ! -d "$BITBAKEDIR" ]; then
Patrick Williamsc0f7c042017-02-23 20:41:17 -060087 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 -050088 return 1
89fi
90
Andrew Geisslerc926e172021-05-07 16:11:35 -050091# Add BitBake's library to PYTHONPATH
92PYTHONPATH=$BITBAKEDIR/lib:$PYTHONPATH
93export PYTHONPATH
94
Patrick Williamse760df82023-05-26 11:10:49 -050095# Remove any paths added by sourcing this script before
96[ -n "$OE_ADDED_PATHS" ] && PATH=$(echo $PATH | sed -e "s#$OE_ADDED_PATHS##") ||
97 PATH=$(echo $PATH | sed -e "s#$OEROOT/scripts:$BITBAKEDIR/bin:##")
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050098
Patrick Williamse760df82023-05-26 11:10:49 -050099# Make sure our paths are at the beginning of $PATH
100OE_ADDED_PATHS="$OEROOT/scripts:$BITBAKEDIR/bin:"
101PATH="$OE_ADDED_PATHS$PATH"
102export OE_ADDED_PATHS
103
104# This is not needed anymore
105unset BITBAKEDIR
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500106
107# Used by the runqemu script
108export BUILDDIR
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500109
Andrew Geissler7e0e3c02022-02-25 20:34:39 +0000110BB_ENV_PASSTHROUGH_ADDITIONS_OE="MACHINE DISTRO TCMODE TCLIBC HTTP_PROXY http_proxy \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500111HTTPS_PROXY https_proxy FTP_PROXY ftp_proxy FTPS_PROXY ftps_proxy ALL_PROXY \
112all_proxy NO_PROXY no_proxy SSH_AGENT_PID SSH_AUTH_SOCK BB_SRCREV_POLICY \
113SDKMACHINE BB_NUMBER_THREADS BB_NO_NETWORK PARALLEL_MAKE GIT_PROXY_COMMAND \
Andrew Geissler82c905d2020-04-13 13:39:40 -0500114SOCKS5_PASSWD SOCKS5_USER SCREENDIR STAMPS_DIR BBPATH_EXTRA BB_SETSCENE_ENFORCE \
115BB_LOGCONFIG"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500116
Andrew Geissler7e0e3c02022-02-25 20:34:39 +0000117BB_ENV_PASSTHROUGH_ADDITIONS="$(echo $BB_ENV_PASSTHROUGH_ADDITIONS $BB_ENV_PASSTHROUGH_ADDITIONS_OE | tr ' ' '\n' | LC_ALL=C sort --unique | tr '\n' ' ')"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500118
Andrew Geissler7e0e3c02022-02-25 20:34:39 +0000119export BB_ENV_PASSTHROUGH_ADDITIONS