blob: 0e75530e68f010454eb57e050a279bdb373dcba0 [file] [log] [blame]
Benjamin Walshfb61bd42016-03-01 10:41:00 -05001#
2# Copyright (c) 2015 Wind River Systems, Inc.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
Anas Nashife96eff62015-05-10 12:16:10 -040016
Yannis Damigos3e3e2972016-03-01 12:31:29 +020017# In zsh the value of $0 depends on the FUNCTION_ARGZERO option which is
18# set by default. FUNCTION_ARGZERO, when it is set, sets $0 temporarily
19# to the name of the function/script when executing a shell function or
20# sourcing a script. POSIX_ARGZERO option, when it is set, exposes the
21# original value of $0 in spite of the current FUNCTION_ARGZERO setting.
d0u96cd15962016-03-18 20:50:21 +080022#
23# Note: The version of zsh need to be 5.0.6 or above. Any versions below
24# 5.0.6 maybe encoutner errors when sourcing this script.
Yannis Damigos3e3e2972016-03-01 12:31:29 +020025if [ -n "$ZSH_VERSION" ]; then
Yannis Damigosea3b5d32016-03-03 12:04:25 +020026 DIR="${(%):-%N}"
Yannis Damigos3e3e2972016-03-01 12:31:29 +020027 if [ $options[posixargzero] != "on" ]; then
28 setopt posixargzero
29 NAME=$(basename -- "$0")
30 setopt posixargzero
31 else
32 NAME=$(basename -- "$0")
33 fi
34else
Yannis Damigosea3b5d32016-03-03 12:04:25 +020035 DIR="${BASH_SOURCE[0]}"
Yannis Damigos3e3e2972016-03-01 12:31:29 +020036 NAME=$(basename -- "$0")
37fi
38
39if [ "X$NAME" "==" "Xzephyr-env.sh" ]; then
Anas Nashifac47c452015-06-19 21:21:48 -040040 echo "Source this file (do NOT execute it!) to set the Zephyr Kernel environment."
Anas Nashife96eff62015-05-10 12:16:10 -040041 exit
42fi
43
44# You can further customize your environment by creating a bash script called
Anas Nashif8accfcf2015-06-05 22:42:27 -040045# zephyr-env_install.bash in your home directory. It will be automatically
Anas Nashife96eff62015-05-10 12:16:10 -040046# run (if it exists) by this script.
47
Louise Mendozac1510f52015-12-08 20:49:00 -060048uname | grep -q MINGW && MINGW_OPT="-W"
49
Anas Nashife96eff62015-05-10 12:16:10 -040050# identify OS source tree root directory
Yannis Damigosea3b5d32016-03-03 12:04:25 +020051export ZEPHYR_BASE=$( builtin cd "$( dirname "$DIR" )" && pwd ${MINGW_OPT})
Anas Nashife96eff62015-05-10 12:16:10 -040052
Anas Nashifb8823772015-06-05 22:46:00 -040053scripts_path=${ZEPHYR_BASE}/scripts
Anas Nashife96eff62015-05-10 12:16:10 -040054echo "${PATH}" | grep -q "${scripts_path}"
Juan Manuel Cruz8dad8ee2016-02-11 13:12:00 -060055[ $? != 0 ] && export PATH=${PATH}:${scripts_path}
Anas Nashife96eff62015-05-10 12:16:10 -040056unset scripts_path
57
58# enable custom environment settings
Anas Nashif8accfcf2015-06-05 22:42:27 -040059zephyr_answer_file=~/zephyr-env_install.bash
Anas Nashif3096b542016-02-12 22:24:47 -050060[ -f ${zephyr_answer_file} ] && {
61 echo "Warning: Please rename ~/zephyr-env_install.bash to ~/.zephyrrc";
62 . ${zephyr_answer_file};
63}
64unset zephyr_answer_file
65zephyr_answer_file=~/.zephyrrc
66[ -f ${zephyr_answer_file} ] && . ${zephyr_answer_file};
Anas Nashif8accfcf2015-06-05 22:42:27 -040067unset zephyr_answer_file