2019-03-21 00:23:14 -04:00
|
|
|
isCatkinPackage() {
|
2019-04-06 22:17:28 -04:00
|
|
|
[ -f "$1/.catkin" ]
|
2019-03-21 00:23:14 -04:00
|
|
|
}
|
|
|
|
|
2019-04-07 15:55:30 -04:00
|
|
|
# Load catkin environment hooks. This mimics the behavior of _setup_util.py.
|
2019-04-06 22:17:28 -04:00
|
|
|
|
2019-04-07 15:55:30 -04:00
|
|
|
declare -gA _catkinPackagesSeen
|
|
|
|
declare -gA _catkinGenericEnvHooks
|
|
|
|
declare -gA _catkinSpecificEnvHooks
|
|
|
|
|
|
|
|
_findCatkinEnvHooks() {
|
2019-04-06 22:17:28 -04:00
|
|
|
local pkg="$1"
|
2019-04-07 15:55:30 -04:00
|
|
|
local pkgEnvHookDir="$pkg/etc/catkin/profile.d"
|
|
|
|
# Deduplicate the packages
|
2019-12-01 21:52:35 -05:00
|
|
|
if [ -z "${_catkinPackagesSeen["$pkg"]:-}" ] && isCatkinPackage "$pkg" && [ -d "$pkgEnvHookDir" ]; then
|
2019-04-07 15:55:30 -04:00
|
|
|
while IFS= read -rd '' hook; do
|
2019-04-07 20:53:35 -04:00
|
|
|
case "$hook" in
|
|
|
|
*.sh) _catkinGenericEnvHooks["$(basename "$hook")"]="$hook" ;; #" (buggy syntax highlighting)
|
|
|
|
*) _catkinSpecificEnvHooks["$(basename "$hook")"]="$hook" ;; #"
|
|
|
|
esac
|
|
|
|
done < <(find "$pkgEnvHookDir" \( -name "*.sh" -o -name "*.$CATKIN_SHELL" \) -print0)
|
2019-03-21 00:23:14 -04:00
|
|
|
fi
|
2019-04-07 15:55:30 -04:00
|
|
|
_catkinPackagesSeen["$pkg"]=1
|
|
|
|
}
|
|
|
|
addEnvHooks "$hostOffset" _findCatkinEnvHooks
|
|
|
|
|
|
|
|
_runCatkinEnvHook() {
|
|
|
|
[ -n "$1" ] || return 0
|
|
|
|
# Causes hooks to look in the wrong place
|
|
|
|
unset CATKIN_ENV_HOOK_WORKSPACE
|
|
|
|
# Some hooks fail in stripped down bash during builds
|
|
|
|
source "$1" || true
|
|
|
|
}
|
|
|
|
|
|
|
|
_runCatkinEnvHooksArray() {
|
|
|
|
# Run hooks in sorted order of their file names
|
|
|
|
# This would fail if a filename contained EOT
|
|
|
|
while IFS= read -rd '' hook; do
|
|
|
|
_runCatkinEnvHook "$hook"
|
|
|
|
done < <(printf "%s\0" "$@" | \
|
|
|
|
# Replace final / with EOT, separating the file name
|
|
|
|
sed -z 's|\(.*\)/|\1'$'\4''|' | \
|
|
|
|
# Sort on second EOT separated field (file name)
|
|
|
|
LC_ALL=C sort -zt$'\4' -k2 | \
|
|
|
|
# Substitute / back in for EOT
|
|
|
|
sed -z 's|'$'\4''|/|')
|
|
|
|
}
|
|
|
|
|
|
|
|
_runCatkinEnvHooks() {
|
|
|
|
_runCatkinEnvHooksArray "${_catkinGenericEnvHooks[@]}"
|
|
|
|
_runCatkinEnvHooksArray "${_catkinSpecificEnvHooks[@]}"
|
2019-03-21 00:23:14 -04:00
|
|
|
}
|
2019-04-07 15:55:30 -04:00
|
|
|
postHooks+=(_runCatkinEnvHooks)
|
2019-03-21 00:23:14 -04:00
|
|
|
|
2019-04-06 01:46:54 -04:00
|
|
|
_catkinPostPatchHook() {
|
2019-04-07 15:55:30 -04:00
|
|
|
while IFS= read -rd '' cfg; do
|
2019-04-06 22:17:28 -04:00
|
|
|
patchShebangs "$cfg"
|
2019-04-07 15:55:30 -04:00
|
|
|
done < <(find . -name '*.cfg' -executable -print0)
|
2019-04-06 01:46:54 -04:00
|
|
|
}
|
|
|
|
postPatchHooks+=(_catkinPostPatchHook)
|
|
|
|
|
2019-03-21 00:23:14 -04:00
|
|
|
_catkinPreConfigureHook() {
|
2019-04-06 01:46:54 -04:00
|
|
|
cmakeFlags+=" -DCATKIN_ENABLE_TESTING=${doCheck:-OFF}"
|
2019-03-21 00:23:14 -04:00
|
|
|
}
|
|
|
|
preConfigureHooks+=(_catkinPreConfigureHook)
|
|
|
|
|
2019-04-06 01:46:54 -04:00
|
|
|
_catkinPostInstallHook() {
|
|
|
|
pushd $out
|
|
|
|
rm -f *setup.*sh
|
|
|
|
rm -f _setup_util.py env.sh .rosinstall
|
|
|
|
popd
|
|
|
|
}
|
|
|
|
postInstallHooks+=(_catkinPostInstallHook)
|
|
|
|
|
2019-04-06 22:17:28 -04:00
|
|
|
export CATKIN_SHELL=bash
|