-
Notifications
You must be signed in to change notification settings - Fork 2
/
BashSrc
executable file
·262 lines (204 loc) · 7.66 KB
/
BashSrc
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
#!/bin/bash
#
# ToolBOS environment setup
#
# Copyright (c) Honda Research Institute Europe GmbH
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
#
# Note: This file needs to be sourced, not executed! For example:
# $ source ./BashSrc
#
#----------------------------------------------------------------------------
# Master Environment Setup
#----------------------------------------------------------------------------
# This fix creates trouble when re-sourcing ToolBOS as a dependency of other
# packages. In this case, regardless what TOOLBOSCORE_ROOT was being set to
# in gets reset to /hri/sit/builds/<build>/.../ToolBOSCore/5.1 :-/
#
## workaround for LD_LIBRARY_PATH being emptied for security reasons
## at "newgrp" command while all other variables survive
#if [[ ! -z ${TOOLBOSCORE_SOURCED} &&
# ! ${LD_LIBRARY_PATH} =~ "DevelopmentTools/ToolBOSCore/5.1" ]]
#then
# unset TOOLBOSCORE_SOURCED
#fi
#
if [[ -z ${TOOLBOSCORE_SOURCED+x} ]]
then
export TOOLBOSCORE_SOURCED=""
fi
if [[ -z ${VERBOSE+x} ]]
then
export VERBOSE=""
fi
# avoid multiple inclusion
if [[ ! "${TOOLBOSCORE_SOURCED}" =~ DevelopmentTools/ToolBOSCore/5.1 ]]
then
# auto-detect location of this BashSrc file
#
# The syntax ${BASH_SOURCE:-$0} allows the BashSrc to work
# correctly with Zsh, where BASH_SOURCE is not defined, but $0
# points to the name of the *sourced* file (this behaviour differs
# from Bash, where it would point to the Bash executable)
SCRIPT_PATH=$(dirname $(readlink -f ${BASH_SOURCE:-$0}))
# the full version string incl. patchlevel (if any), e.g. "2.0.1234"
TOOLBOS_VERSION=$(basename ${SCRIPT_PATH})
# cut off the patchlevel revision (if any), e.g. "2.0.1234" --> "2.0"
# because we don't want TOOLBOSCORE_ROOT to point to a particular patchlevel
if [[ -z ${TOOLBOSCORE_AUTO_VERSION+x} ]]
then
export TOOLBOSCORE_AUTO_VERSION=""
fi
export TOOLBOSCORE_SOURCED="DevelopmentTools/ToolBOSCore/5.1 ${TOOLBOSCORE_SOURCED}"
#------------------------------------------------------------------------
# Location of ToolBOS SDK
#------------------------------------------------------------------------
TOOLBOSCORE_ROOT_FULL=$(builtin cd ${SCRIPT_PATH}; pwd)
TOOLBOSCORE_ROOT=$(dirname ${TOOLBOSCORE_ROOT_FULL})/${TOOLBOS_VERSION}
export TOOLBOSCORE_ROOT
#------------------------------------------------------------------------
# Platform identifier / Build system
#------------------------------------------------------------------------
FILE=/etc/ToolBOS.conf
# if not predefined (forced) by user, attempt to read from /etc/ToolBOS.conf
if [[ -z "${MAKEFILE_PLATFORM+x}" ]]
then
if [[ -e ${FILE} ]]
then
MAKEFILE_PLATFORM=$(awk -F\' '/hostPlatform/ { print $2 }' ${FILE})
export MAKEFILE_PLATFORM
else
# also in etc/ToolBOS.conf and useFromHere.sh!
export MAKEFILE_PLATFORM=focal64
fi
fi
if [[ -z "${MAKEFILE_OS+x}" ]]
then
if [[ -e ${FILE} ]]
then
MAKEFILE_OS=$(awk -F\' '/hostOS/ { print $2 }' ${FILE})
export MAKEFILE_OS
else
MAKEFILE_OS=$(uname | tr "[:upper:]" "[:lower:]")
export MAKEFILE_OS
fi
fi
if [[ -z "${MAKEFILE_CPU+x}" ]]
then
if [[ -e ${FILE} ]]
then
MAKEFILE_CPU=$(awk -F\' '/hostArch/ { print $2 }' ${FILE})
export MAKEFILE_CPU
else
MAKEFILE_CPU=$(arch)
export MAKEFILE_CPU
if [[ "${MAKEFILE_CPU}" == "x86_64" ]]
then
export MAKEFILE_CPU=amd64
fi
fi
fi
if [[ -z "${MAKEFILE_CC+x}" ]]
then
if [[ -e ${FILE} ]]
then
MAKEFILE_CC=$(awk -F\' '/hostCompiler/ { print $2 }' ${FILE})
export MAKEFILE_CC
else
export MAKEFILE_CC=gcc
fi
fi
if [[ -z "${BST_BUILD_JOBS+x}" ]]
then
export BST_BUILD_JOBS=1
fi
#------------------------------------------------------------------------
# Paths settings
#------------------------------------------------------------------------
if [[ -z ${PYTHONPATH+x} ]]
then
export PYTHONPATH=""
fi
# set environment variables used by O.S. and/or 3rd party software
export PATH=${TOOLBOSCORE_ROOT}/bin:${PATH}
export PYTHONPATH=${TOOLBOSCORE_ROOT}/include:${PYTHONPATH}
#------------------------------------------------------------------------
# Convenience shell aliases
#------------------------------------------------------------------------
function bst {
BST.py "$@"
}
export -f bst
#------------------------------------------------------------------------
# Software Installation Tree (SIT)
#------------------------------------------------------------------------
# SIT identifier ("build name")
if [[ -z "${SIT_VERSION+x}" ]]
then
export SIT_VERSION=latest
fi
# SIT location (optional)
if [[ -z "${SIT+x}" ]]
then
# Fallback to default location if user did specify one,
# however leave $SIT unset if default path does not exist.
#
# Though the majority of tools need a $SIT location, there is
# enough functionality that works without.
SIT_DEFAULT_PATH=/hri/sit/${SIT_VERSION}
if [[ -d "${SIT_DEFAULT_PATH}" ]]
then
export SIT=/hri/sit/${SIT_VERSION}
fi
fi
# check if the user has got a local SIT sandbox ("Proxy directory")
#
# to entirely disable an existing proxy predefine SIT_PROXY=NONE
# ("NONE" [most probably] isn't a directory hence will be ignored)
if [[ -z "${SIT_PROXY+x}" ]]
then
SIT_PROXY="${HOME}/.HRI/sit/${SIT_VERSION}"
fi
if [[ -d "${SIT_PROXY}" ]]
then
export SIT=${SIT_PROXY}
fi
#------------------------------------------------------------------------
# Clean-up
#------------------------------------------------------------------------
unset FILE
unset SCRIPT_PATH
unset SIT_DEPENDENCIES
unset SIT_PROXY
unset SIT_VERSION
unset TOOLBOS_VERSION
unset TOOLBOSCORE_ROOT_FULL
fi
# EOF