forked from nerves-project/nerves_system_br
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nerves-env.sh
executable file
·57 lines (50 loc) · 2.02 KB
/
nerves-env.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
# Source this script to setup your environment to cross-compile
# and build Erlang apps for this Nerves build.
# If the script is called with the -get-nerves-root flag it just returns the
# Nerves system directory. This is so that other shells can execute the script
# without needing to implement the equivalent of $BASH_SOURCE for every shell.
for arg in $*
do
if [ $arg = "-get-nerves-root" ];
then
echo $(cd $(dirname ${BASH_SOURCE[0]}) && pwd)
exit 0
fi
done
if [ "$BASH_SOURCE" = "" ]; then
GET_NR_COMMAND="$0 $@ -get-nerves-root"
NERVES_SYSTEM=$(bash -c "$GET_NR_COMMAND")
else
# Mac note: Don't use "readlink -f" below since it doesn't work on BSD
NERVES_SYSTEM=$(cd $(dirname ${BASH_SOURCE[0]}) && pwd)
fi
# Detect if this script has been run directly rather than sourced, since
# that won't work.
if [[ "$SHELL" = "/bin/bash" ]]; then
if [ "$0" != "bash" -a "$0" != "-bash" -a "$0" != "/bin/bash" ]; then
echo ERROR: This scripted should be sourced from bash:
echo
echo source $BASH_SOURCE
echo
exit 1
fi
#elif [[ "$SHELL" = "/bin/zsh" ]]; then
# TODO: Figure out how to detect this error from other shells.
fi
source $NERVES_SYSTEM/scripts/nerves-env-helper.sh $NERVES_SYSTEM
if [ $? != 0 ]; then
echo "Shell environment NOT updated for Nerves!"
else
# Found it. Print out some useful information so that the user can
# easily figure out whether the wrong nerves installation was used.
NERVES_DEFCONFIG=$(grep BR2_DEFCONFIG= $NERVES_SYSTEM/buildroot/.config | sed -e 's/BR2_DEFCONFIG=".*\/\(.*\)"/\1/')
NERVES_VERSION=$(grep NERVES_VERSION:= $NERVES_SYSTEM/nerves.mk | sed -e 's/NERVES_VERSION\:=\(.*\)/\1/')
echo "Shell environment updated for Nerves"
echo
echo "Nerves version: $NERVES_VERSION"
echo "Nerves configuration: $NERVES_DEFCONFIG"
echo "Cross-compiler prefix: $(basename $CROSSCOMPILE)"
echo "Erlang version: $NERVES_TARGET_ERL_VER"
# echo "Elixir version: $NERVES_TARGET_ELIXIR_VER"
fi