blob: 9aaa72c1f18581d7666811ea17a1b55102da6820 [file] [log] [blame]
Benjamin Walshfb61bd42016-03-01 10:41:00 -05001#
2# Copyright (c) 2015 Wind River Systems, Inc.
3#
David B. Kinderac74d8b2017-01-18 17:01:01 -08004# SPDX-License-Identifier: Apache-2.0
Benjamin Walshfb61bd42016-03-01 10:41:00 -05005#
Anas Nashife96eff62015-05-10 12:16:10 -04006
Yannis Damigos3e3e2972016-03-01 12:31:29 +02007# In zsh the value of $0 depends on the FUNCTION_ARGZERO option which is
8# set by default. FUNCTION_ARGZERO, when it is set, sets $0 temporarily
9# to the name of the function/script when executing a shell function or
10# sourcing a script. POSIX_ARGZERO option, when it is set, exposes the
11# original value of $0 in spite of the current FUNCTION_ARGZERO setting.
d0u96cd15962016-03-18 20:50:21 +080012#
13# Note: The version of zsh need to be 5.0.6 or above. Any versions below
14# 5.0.6 maybe encoutner errors when sourcing this script.
Christopher Métrailler46da7452019-05-17 11:24:11 +020015if [ -n "${ZSH_VERSION:-}" ]; then
Ulf Magnusson0194d042019-11-22 21:04:20 +010016 dir="${(%):-%N}"
Yannis Damigos3e3e2972016-03-01 12:31:29 +020017 if [ $options[posixargzero] != "on" ]; then
18 setopt posixargzero
Ulf Magnusson0194d042019-11-22 21:04:20 +010019 name=$(basename -- "$0")
Hosun Zhub479e912019-11-04 22:18:48 +080020 unsetopt posixargzero
Yannis Damigos3e3e2972016-03-01 12:31:29 +020021 else
Ulf Magnusson0194d042019-11-22 21:04:20 +010022 name=$(basename -- "$0")
Yannis Damigos3e3e2972016-03-01 12:31:29 +020023 fi
24else
Ulf Magnusson0194d042019-11-22 21:04:20 +010025 dir="${BASH_SOURCE[0]}"
26 name=$(basename -- "$0")
Yannis Damigos3e3e2972016-03-01 12:31:29 +020027fi
28
Ulf Magnusson0194d042019-11-22 21:04:20 +010029if [ "X$name" "==" "Xzephyr-env.sh" ]; then
Anas Nashifac47c452015-06-19 21:21:48 -040030 echo "Source this file (do NOT execute it!) to set the Zephyr Kernel environment."
Anas Nashife96eff62015-05-10 12:16:10 -040031 exit
32fi
33
34# You can further customize your environment by creating a bash script called
Marti Bolivare3a31262017-03-31 15:08:33 -040035# .zephyrrc in your home directory. It will be automatically
Anas Nashife96eff62015-05-10 12:16:10 -040036# run (if it exists) by this script.
37
Carles Cufi4e5757d2017-07-15 18:13:36 +020038if uname | grep -q "MINGW"; then
Marti Bolivar5f951202017-03-31 15:26:25 -040039 win_build=1
Ulf Magnusson0194d042019-11-22 21:04:20 +010040 pwd_opt="-W"
Marti Bolivar5f951202017-03-31 15:26:25 -040041else
42 win_build=0
Ulf Magnusson0194d042019-11-22 21:04:20 +010043 pwd_opt=""
Marti Bolivar5f951202017-03-31 15:26:25 -040044fi
Louise Mendozac1510f52015-12-08 20:49:00 -060045
Anas Nashife96eff62015-05-10 12:16:10 -040046# identify OS source tree root directory
Ulf Magnusson0194d042019-11-22 21:04:20 +010047export ZEPHYR_BASE=$( builtin cd "$( dirname "$dir" )" > /dev/null && pwd ${pwd_opt})
48unset pwd_opt
Anas Nashife96eff62015-05-10 12:16:10 -040049
Anas Nashifb8823772015-06-05 22:46:00 -040050scripts_path=${ZEPHYR_BASE}/scripts
Marti Bolivar5f951202017-03-31 15:26:25 -040051if [ "$win_build" -eq 1 ]; then
52 scripts_path=$(echo "/$scripts_path" | sed 's/\\/\//g' | sed 's/://')
53fi
54unset win_build
Inaky Perez-Gonzalez62ebe722017-01-06 12:27:39 -080055if ! echo "${PATH}" | grep -q "${scripts_path}"; then
56 export PATH=${scripts_path}:${PATH}
57fi
Anas Nashife96eff62015-05-10 12:16:10 -040058unset scripts_path
59
60# enable custom environment settings
Anas Nashif8accfcf2015-06-05 22:42:27 -040061zephyr_answer_file=~/zephyr-env_install.bash
Anas Nashif3096b542016-02-12 22:24:47 -050062[ -f ${zephyr_answer_file} ] && {
Ulf Magnusson0d8495c2019-11-22 21:04:45 +010063 echo "Warning: Please rename ~/zephyr-env_install.bash to ~/.zephyrrc"
64 . ${zephyr_answer_file}
Anas Nashif3096b542016-02-12 22:24:47 -050065}
66unset zephyr_answer_file
67zephyr_answer_file=~/.zephyrrc
Ulf Magnusson0d8495c2019-11-22 21:04:45 +010068[ -f ${zephyr_answer_file} ] && . ${zephyr_answer_file}
Anas Nashif8accfcf2015-06-05 22:42:27 -040069unset zephyr_answer_file