blob: 82382f27078f6a7cd909f7c34be5fda85e37ce62 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001#!/bin/sh
2
3# OE 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
10#
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050011# Normally this is called as '. ./oe-init-build-env <builddir>'
Patrick Williamsc124f4f2015-09-15 14:41:29 -050012#
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050013# This works in most shells (not dash), but not all of them pass the arguments
14# when being sourced. To workaround the shell limitation use "set <builddir>"
15# prior to sourcing this script.
Patrick Williamsc124f4f2015-09-15 14:41:29 -050016#
17if [ -n "$BASH_SOURCE" ]; then
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050018 THIS_SCRIPT=$BASH_SOURCE
Patrick Williamsc124f4f2015-09-15 14:41:29 -050019elif [ -n "$ZSH_NAME" ]; then
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050020 THIS_SCRIPT=$0
Patrick Williamsc124f4f2015-09-15 14:41:29 -050021else
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050022 THIS_SCRIPT="$(pwd)/oe-init-build-env"
Brad Bishop19323692019-04-05 15:28:33 -040023 if [ ! -e "$THIS_SCRIPT" ]; then
24 echo "Error: $THIS_SCRIPT doesn't exist!" >&2
25 echo "Please run this script in oe-init-build-env's directory." >&2
26 exit 1
27 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -050028fi
29if [ -n "$BBSERVER" ]; then
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050030 unset BBSERVER
Patrick Williamsc124f4f2015-09-15 14:41:29 -050031fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -050032
33if [ -z "$ZSH_NAME" ] && [ "$0" = "$THIS_SCRIPT" ]; then
Brad Bishop19323692019-04-05 15:28:33 -040034 echo "Error: This script needs to be sourced. Please run as '. $THIS_SCRIPT'" >&2
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050035 exit 1
Patrick Williamsc124f4f2015-09-15 14:41:29 -050036fi
37
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050038if [ -z "$OEROOT" ]; then
39 OEROOT=$(dirname "$THIS_SCRIPT")
40 OEROOT=$(readlink -f "$OEROOT")
41fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -050042unset THIS_SCRIPT
43
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050044export OEROOT
Patrick Williamsde0582f2022-04-08 10:23:27 -050045. "$OEROOT"/scripts/oe-buildenv-internal &&
46 TEMPLATECONF="$TEMPLATECONF" "$OEROOT"/scripts/oe-setup-builddir || {
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050047 unset OEROOT
48 return 1
49}
Patrick Williams73bd93f2024-02-20 08:07:48 -060050
51# Generate an initial configuration for VSCode and the yocto-bitbake plugin.
52if command -v code > /dev/null && [ ! -d "$OEROOT/.vscode" ]; then
53 oe-setup-vscode "$OEROOT" "$BUILDDIR"
54fi
55
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050056unset OEROOT
57
58[ -z "$BUILDDIR" ] || cd "$BUILDDIR"
59