Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | # OE Build Environment Setup Script |
| 4 | # |
| 5 | # Copyright (C) 2006-2011 Linux Foundation |
| 6 | # |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7 | # SPDX-License-Identifier: GPL-2.0-or-later |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8 | # |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9 | |
| 10 | # |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 11 | # Normally this is called as '. ./oe-init-build-env <builddir>' |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12 | # |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 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. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 16 | # |
| 17 | if [ -n "$BASH_SOURCE" ]; then |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 18 | THIS_SCRIPT=$BASH_SOURCE |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 19 | elif [ -n "$ZSH_NAME" ]; then |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 20 | THIS_SCRIPT=$0 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 21 | else |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 22 | THIS_SCRIPT="$(pwd)/oe-init-build-env" |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 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 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 28 | fi |
| 29 | if [ -n "$BBSERVER" ]; then |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 30 | unset BBSERVER |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 31 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 32 | |
| 33 | if [ -z "$ZSH_NAME" ] && [ "$0" = "$THIS_SCRIPT" ]; then |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 34 | echo "Error: This script needs to be sourced. Please run as '. $THIS_SCRIPT'" >&2 |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 35 | exit 1 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 36 | fi |
| 37 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 38 | if [ -z "$OEROOT" ]; then |
| 39 | OEROOT=$(dirname "$THIS_SCRIPT") |
| 40 | OEROOT=$(readlink -f "$OEROOT") |
| 41 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 42 | unset THIS_SCRIPT |
| 43 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 44 | export OEROOT |
Patrick Williams | de0582f | 2022-04-08 10:23:27 -0500 | [diff] [blame] | 45 | . "$OEROOT"/scripts/oe-buildenv-internal && |
| 46 | TEMPLATECONF="$TEMPLATECONF" "$OEROOT"/scripts/oe-setup-builddir || { |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 47 | unset OEROOT |
| 48 | return 1 |
| 49 | } |
| 50 | unset OEROOT |
| 51 | |
| 52 | [ -z "$BUILDDIR" ] || cd "$BUILDDIR" |
| 53 | |