-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.sh
executable file
·120 lines (98 loc) · 2.71 KB
/
config.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
#! /bin/bash
usage()
{
cat <<EOF
usage: $0 <build_system>
Where <build_system> is catkin or rosbuild
EOF
}
CATKIN="catkin"
ROSBUILD="rosbuild"
#
# Verify that all required utility commands exist
hash rm 2>&- || { echo >&2 "rm not installed. Aborting."; exit 1; }
hash find 2>&- || { echo >&2 "ls not installed. Aborting."; exit 1; }
hash cp 2>&- || { echo >&2 "ls not installed. Aborting."; exit 1; }
#
# Verify command line arguments
if [ $# -ne 1 ] ; then
usage
exit 3
fi
#
# Get the root directory where the script is located
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
#
# Check to make sure a build_config directory exists in our root directory
if [ ! -d "$ROOT/build_config" ] ; then
echo " Unable to locate $ROOT/build_config. Please check the Multisense Driver Installation"
exit 1
fi
#
# Function which deletes all the unwanted files from the ROS source tree
cleanup()
{
FILES="$( cd $ROOT/build_config/$1/ && find . -type f -name "*_")"
for f in $FILES
do
FILE=$ROOT/$f
#
# Check to make sure the file exists in our ROS directory
if [ -f "${FILE%?}" ] ; then
rm -r "${FILE%?}"
fi
done
}
#
# Function which copies all the files from the build_config directory
# To the ROS source tree
copy()
{
FILES="$( cd $ROOT/build_config/$1/ && find . -type f -name "*_")"
for f in $FILES
do
FILE=$ROOT/$f
cp $ROOT/build_config/$1/$f "${FILE%?}"
done
}
#
# Function which checks for specific files associated with a ros distribution
# by looking for a .<rosdistro> extension. If a file matches the users
# current ROS distro make it the default file
preprocess()
{
#
# First copy the .default files to the main file
FILES="$( cd $ROOT/build_config/$1/ && find . -type f -name "*.default")"
for f in $FILES
do
STRIPPED_NAME="$( echo $f | rev | cut -c 9- |rev)"
cp $ROOT/build_config/$1/$f $ROOT/build_config/$1/$STRIPPED_NAME
done
#
# Next copy the .<rosdistro> files to the main file
FILES="$( cd $ROOT/build_config/$1/ && find . -type f -name "*.$ROS_DISTRO")"
for f in $FILES
do
LENGTH="$( echo .$ROS_DISTRO | wc -c)"
STRIPPED_NAME="$( echo $f | rev | cut -c $LENGTH- |rev)"
cp $ROOT/build_config/$1/$f $ROOT/build_config/$1/$STRIPPED_NAME
done
}
BUILDSYSTEM=$1
case $BUILDSYSTEM in
$CATKIN) cleanup $ROSBUILD
preprocess $CATKIN
copy $CATKIN
exit 0
;;
$ROSBUILD) cleanup $CATKIN
preprocess $ROSBUILD
copy $ROSBUILD
exit 0
;;
*) echo "Unknown option $1."
usage
exit 1
;;
esac