Benjamin Walsh | fb61bd4 | 2016-03-01 10:41:00 -0500 | [diff] [blame] | 1 | # |
| 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 Nashif | e96eff6 | 2015-05-10 12:16:10 -0400 | [diff] [blame] | 16 | |
Yannis Damigos | 3e3e297 | 2016-03-01 12:31:29 +0200 | [diff] [blame] | 17 | # 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. |
d0u9 | 6cd1596 | 2016-03-18 20:50:21 +0800 | [diff] [blame] | 22 | # |
| 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 Damigos | 3e3e297 | 2016-03-01 12:31:29 +0200 | [diff] [blame] | 25 | if [ -n "$ZSH_VERSION" ]; then |
Yannis Damigos | ea3b5d3 | 2016-03-03 12:04:25 +0200 | [diff] [blame] | 26 | DIR="${(%):-%N}" |
Yannis Damigos | 3e3e297 | 2016-03-01 12:31:29 +0200 | [diff] [blame] | 27 | if [ $options[posixargzero] != "on" ]; then |
| 28 | setopt posixargzero |
| 29 | NAME=$(basename -- "$0") |
| 30 | setopt posixargzero |
| 31 | else |
| 32 | NAME=$(basename -- "$0") |
| 33 | fi |
| 34 | else |
Yannis Damigos | ea3b5d3 | 2016-03-03 12:04:25 +0200 | [diff] [blame] | 35 | DIR="${BASH_SOURCE[0]}" |
Yannis Damigos | 3e3e297 | 2016-03-01 12:31:29 +0200 | [diff] [blame] | 36 | NAME=$(basename -- "$0") |
| 37 | fi |
| 38 | |
| 39 | if [ "X$NAME" "==" "Xzephyr-env.sh" ]; then |
Anas Nashif | ac47c45 | 2015-06-19 21:21:48 -0400 | [diff] [blame] | 40 | echo "Source this file (do NOT execute it!) to set the Zephyr Kernel environment." |
Anas Nashif | e96eff6 | 2015-05-10 12:16:10 -0400 | [diff] [blame] | 41 | exit |
| 42 | fi |
| 43 | |
| 44 | # You can further customize your environment by creating a bash script called |
Anas Nashif | 8accfcf | 2015-06-05 22:42:27 -0400 | [diff] [blame] | 45 | # zephyr-env_install.bash in your home directory. It will be automatically |
Anas Nashif | e96eff6 | 2015-05-10 12:16:10 -0400 | [diff] [blame] | 46 | # run (if it exists) by this script. |
| 47 | |
Louise Mendoza | c1510f5 | 2015-12-08 20:49:00 -0600 | [diff] [blame] | 48 | uname | grep -q MINGW && MINGW_OPT="-W" |
| 49 | |
Anas Nashif | e96eff6 | 2015-05-10 12:16:10 -0400 | [diff] [blame] | 50 | # identify OS source tree root directory |
Yannis Damigos | ea3b5d3 | 2016-03-03 12:04:25 +0200 | [diff] [blame] | 51 | export ZEPHYR_BASE=$( builtin cd "$( dirname "$DIR" )" && pwd ${MINGW_OPT}) |
Anas Nashif | e96eff6 | 2015-05-10 12:16:10 -0400 | [diff] [blame] | 52 | |
Anas Nashif | b882377 | 2015-06-05 22:46:00 -0400 | [diff] [blame] | 53 | scripts_path=${ZEPHYR_BASE}/scripts |
Anas Nashif | e96eff6 | 2015-05-10 12:16:10 -0400 | [diff] [blame] | 54 | echo "${PATH}" | grep -q "${scripts_path}" |
Juan Manuel Cruz | 8dad8ee | 2016-02-11 13:12:00 -0600 | [diff] [blame] | 55 | [ $? != 0 ] && export PATH=${PATH}:${scripts_path} |
Anas Nashif | e96eff6 | 2015-05-10 12:16:10 -0400 | [diff] [blame] | 56 | unset scripts_path |
| 57 | |
| 58 | # enable custom environment settings |
Anas Nashif | 8accfcf | 2015-06-05 22:42:27 -0400 | [diff] [blame] | 59 | zephyr_answer_file=~/zephyr-env_install.bash |
Anas Nashif | 3096b54 | 2016-02-12 22:24:47 -0500 | [diff] [blame] | 60 | [ -f ${zephyr_answer_file} ] && { |
| 61 | echo "Warning: Please rename ~/zephyr-env_install.bash to ~/.zephyrrc"; |
| 62 | . ${zephyr_answer_file}; |
| 63 | } |
| 64 | unset zephyr_answer_file |
| 65 | zephyr_answer_file=~/.zephyrrc |
| 66 | [ -f ${zephyr_answer_file} ] && . ${zephyr_answer_file}; |
Anas Nashif | 8accfcf | 2015-06-05 22:42:27 -0400 | [diff] [blame] | 67 | unset zephyr_answer_file |