forked from Intermodalics/ros_android
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample_app.sh
executable file
·54 lines (41 loc) · 1.41 KB
/
sample_app.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
#!/bin/bash
my_loc="$(cd "$(dirname $0)" && pwd)"
source $my_loc/config.sh
source $my_loc/utils.sh
if [ $# != 2 ]; then # || [ $1 == '-h' ] || [ $1 == '--help' ]; then
echo "Usage: $0 app_name tf2_ndk_path"
echo " example: $0 rba_sample_app /path/to/tf2_ndk"
exit 1
fi
cmd_exists android || die 'could not find android executable in PATH'
[ "$ANDROID_NDK" = "" ] && die 'environment variable ANDROID_NDK not set'
rbndk=$(cd $2 && pwd)
lib_name=$1
package_name=com.ros.$(echo $1 | sed 's/_//g' | tr '[A-Z]' '[a-z]')
ndk_path=$ANDROID_NDK/ndk-build
module_path=$(dirname $rbndk)
tf2_ndk=$(basename $rbndk)
mkdir -p $lib_name/jni/src
mkdir -p $lib_name/jni/include
prefix=$(cd $lib_name && pwd)
android create project -n $lib_name -t 1 -p $prefix -k $package_name -a $lib_name
subst_list="lib_name package_name ndk_path module_path tf2_ndk"
for s in $subst_list; do
sedcmd="$sedcmd -e s,:{$s},\$$s,"
done
sedcmd="sed -e "$(eval echo $sedcmd)
subst() {
target=$(echo $1 | sed 's,.in$,,')
$sedcmd $my_loc/files/$3/$1 > $2/$target
}
files=$(cd $my_loc/files/$lib_name && find . -name \*.in)
for f in $files; do
subst $f $prefix $lib_name
done
rest=$(cd $my_loc/files/$lib_name && find . -type f | grep -v '.in$')
for f in $rest; do
cp $my_loc/files/$lib_name/$f $prefix/$f
done
# Copy app icon
mkdir -p $prefix/res/drawable
cp $my_loc/files/$lib_name/ic_launcher.png $prefix/res/drawable/ic_launcher.png