-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·129 lines (101 loc) · 3.59 KB
/
setup.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/bin/bash
if [ -z "$DEFAULT" ]; then DEFAULT="n" ; fi
DEFSTRING="[Y/n]"
if [ "$DEFAULT" = "n" ]; then
DEFSTRING="[y/N]"
fi
PROFILE_NAOTH_TOOLCHAIN_STRING="export NAOTH_TOOLCHAIN_PATH=$(pwd)"
PROFILE_NAOTH_TOOLCHAIN_CURRENT=$(cat ~/.profile | grep "export NAOTH_TOOLCHAIN_PATH=")
# prevent multiple env_var definitions
if [[ -z "${NAOTH_TOOLCHAIN_PATH}" ]]; then
NAOTH_TOOLCHAIN_PATH=`pwd`
echo -n "Do you want append NaoTH environment variables to ~/.profile? $DEFSTRING : "
read ANSWER
# set default answer
if [ -z "$ANSWER" ]; then
ANSWER=$DEFAULT
fi
if [ "$ANSWER" = "y" -o "$ANSWER" = "Y" ]
then
echo "------------------------"
echo "- extending ~/.profile -"
echo "------------------------"
# force new line
echo >> ~/.profile
#
echo "# NAOTH Toolchain" >> ~/.profile
echo "$PROFILE_NAOTH_TOOLCHAIN_STRING" >> ~/.profile
echo "[[ -f $NAOTH_TOOLCHAIN_PATH/.naoth.profile ]] && . $NAOTH_TOOLCHAIN_PATH/.naoth.profile" >> ~/.profile
fi
elif [[ "$PROFILE_NAOTH_TOOLCHAIN_STRING" != "$PROFILE_NAOTH_TOOLCHAIN_CURRENT" ]]; then
echo -e -n "NaoTH toolchain path in the ~/.profile is different to this path!\nDo you want to replace it? $DEFSTRING : "
read ANSWER
# set default answer
if [ -z "$ANSWER" ]; then
ANSWER=$DEFAULT
fi
if [ "$ANSWER" = "y" -o "$ANSWER" = "Y" ]
then
# replace toolchain path and using | as sed delimiter
sed -i "s|$PROFILE_NAOTH_TOOLCHAIN_CURRENT|$PROFILE_NAOTH_TOOLCHAIN_STRING|g" ~/.profile
fi
else
echo "NaoTH environment variables already defined."
fi
# load (new) profile
. ~/.profile
echo "-----------------------------------"
echo "- Generate projectconfig.user.lua -"
echo "-----------------------------------"
cat >projectconfig.user.lua <<EOL
-- special pathes which can be configured manualy.
-- If a path is set to 'nil' the default value is used.
-- for default values check projectconfig.lua
-- default: "../../Framework"
FRAMEWORK_PATH = nil
-- for native platform
-- default: "../../Extern"
EXTERN_PATH_NATIVE = "${EXTERN_PATH_NATIVE}"
-- path to the crosscompiler and libs
-- default: os.getenv("NAO_CTC")
NAO_CTC = "${NAO_CTC}"
-- or set both explicitely
-- default: NAO_CTC .. "/compiler"
COMPILER_PATH_NAO = nil
-- default: NAO_CTC .. "/extern"
EXTERN_PATH_NAO = nil
-- naoqi toolchain needed to compile the NaoSMAL
-- default: os.getenv("AL_DIR")
AL_DIR = nil
-- optional: manualy enable/disable colors
-- print_colors = true
if PLATFORM == "Nao" then
_OPTIONS["crosscompiler"] = "clang" -- set "gcc" for legacy compilation
end
function set_user_defined_paths()
-- add your additional include directories here
-- sysincludedirs { "my/nao/includes/path1" }
-- add your additional lib directories here
--syslibdirs { "my/nao/libs/path1" }
-- NOTE: this should be used only for project internal files
-- use this ONLY if you know what you are doing
--includedirs {}
--libdirs {}
end
EOL
echo "-----------------------------------"
echo "- compiling external dependencies -"
echo "-----------------------------------"
cd toolchain_native/extern/
# make executeable
chmod u+x install_linux.sh
./install_linux.sh
if [ $? -ne 0 ]; then
echo "---------------------------------------------------"
echo "- ./install_linux.sh did not finish successfully! -"
echo "---------------------------------------------------"
exit 1
fi
echo "-------------------------------------------------------------------------------------------"
echo "- If paths were appended to .profile a restart is needed in order for the changes to work -"
echo "-------------------------------------------------------------------------------------------"