xref: /openbmc/openbmc/poky/oe-init-build-env (revision 319b8b92)
1#!/bin/sh
2
3# OE Build Environment Setup Script
4#
5# Copyright (C) 2006-2011 Linux Foundation
6#
7# SPDX-License-Identifier: GPL-2.0-or-later
8#
9
10#
11# Normally this is called as '. ./oe-init-build-env <builddir>'
12#
13# 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.
16#
17if [ -n "$BASH_SOURCE" ]; then
18    THIS_SCRIPT=$BASH_SOURCE
19elif [ -n "$ZSH_NAME" ]; then
20    THIS_SCRIPT=$0
21else
22    THIS_SCRIPT="$(pwd)/oe-init-build-env"
23    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
28fi
29if [ -n "$BBSERVER" ]; then
30    unset BBSERVER
31fi
32
33if [ -z "$ZSH_NAME" ] && [ "$0" = "$THIS_SCRIPT" ]; then
34    echo "Error: This script needs to be sourced. Please run as '. $THIS_SCRIPT'" >&2
35    exit 1
36fi
37
38if [ -z "$OEROOT" ]; then
39    OEROOT=$(dirname "$THIS_SCRIPT")
40    OEROOT=$(readlink -f "$OEROOT")
41fi
42unset THIS_SCRIPT
43
44export OEROOT
45. "$OEROOT"/scripts/oe-buildenv-internal &&
46    TEMPLATECONF="$TEMPLATECONF" "$OEROOT"/scripts/oe-setup-builddir || {
47    unset OEROOT
48    return 1
49}
50
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
56unset OEROOT
57
58[ -z "$BUILDDIR" ] || cd "$BUILDDIR"
59
60