Merge test folder of test branch
[iotivity.git] / test / build / android / ca / junit / native_build.sh
1 #!/bin/bash
2
3 for i in `seq 1 $#`
4 do
5     eval arg=\$$i
6     arg=${arg// /+}
7     args+=$arg" "
8 done
9
10 arg_parts=(${args//=/ })
11 len=${#arg_parts[@]}
12
13 clean='1'
14 test='tc'
15 release_dir='debug'
16 android_ndk=${ANDROID_NDK}
17 stand_alone='1'
18 target_arch='armeabi'
19 iotivity_root=''
20 iotivity_test_root=''
21
22 i=0
23 while [ ${i} -lt ${len} ]; do
24     arg_parts[i]=${arg_parts[i],,}
25     let i=i+2
26 done
27
28 i=0
29 while [ $i -lt $len ]; do
30     if [[ "${arg_parts[i]}" = "clean" ]]; then
31         clean=${arg_parts[i+1]}
32     elif [[ "${arg_parts[i]}" = "iotivity_root" ]]; then
33         iotivity_root=${arg_parts[i+1]}
34     elif [[ "${arg_parts[i]}" = "iotivity_test_root" ]]; then
35         iotivity_test_root=${arg_parts[i+1]}
36     elif [[ "${arg_parts[i]}" = "test" ]]; then
37         test=${arg_parts[i+1]}
38     elif [[ "${arg_parts[i]}" = "target_arch" ]]; then
39         target_arch=${arg_parts[i+1]}
40     elif [[ "${arg_parts[i]}" = "release" ]]; then
41         release_dir=${arg_parts[i+1]}
42     elif [[ "${arg_parts[i]}" = "android_ndk" ]]; then
43         android_ndk=${arg_parts[i+1]}
44     elif [[ "${arg_parts[i]}" = "stand_alone" ]]; then
45         stand_alone=${arg_parts[i+1]}
46     fi
47     let i=i+2
48 done
49
50 current_path=`pwd`
51
52 if [[ "${stand_alone}" = "0" ]]; then
53     cd build/android/ca/junit
54 fi
55
56 if [[ "${android_ndk}" = "" ]]; then
57     echo 'ANDROID_NDK NOT DEFINED'
58     echo 'Script Exiting...'
59     exit 127
60 fi
61
62 ndk_file=${android_ndk}'/ndk-build'
63 if [ ! -f "${ndk_file}" ]; then
64     echo 'Invalid ANDROID_NDK. No ndk-build found in path: '${android_ndk}
65     echo 'Script Exiting...'
66     exit 127
67 fi
68
69 export RELEASE_DIR=${release_dir}
70 export IOTIVITY_TEST_ROOT=${iotivity_test_root}
71 export IOTIVITY_ROOT=${iotivity_root}
72 export IOTIVITY_TARGET_ARCH=${target_arch}
73 export CURRENT_PATH=${current_path}
74
75 dst_path=${IOTIVITY_TEST_ROOT}'/build/android/ca/junit/jni'
76 tc_path=${IOTIVITY_TEST_ROOT}'/src/tc/ca/junit/jni'
77 simulator_path=${IOTIVITY_TEST_ROOT}'/src/testapp/ca/android/casimulator/src/main/jni'
78
79 rm ${dst_path}/org_iotivity_CAJni.h
80 rm ${dst_path}/CAJni.c
81
82 if [[ "${test}" = "tc" ]]; then
83     cp ${tc_path}/org_iotivity_CAJni.h ${dst_path}/org_iotivity_CAJni.h
84     cp ${tc_path}/CAJni.c ${dst_path}/CAJni.c
85 fi
86
87 if [[ "${test}" = "simulator" ]]; then
88     cp ${simulator_path}/org_iotivity_CAJni.h ${dst_path}/org_iotivity_CAJni.h
89     cp ${simulator_path}/CAJni.c ${dst_path}/CAJni.c
90 fi
91
92 if [[ "${clean}" = "1" ]]; then
93     rm -rf libs
94     rm -rf obj
95 fi
96
97 ${android_ndk}/ndk-build
98
99 mkdir -p ${IOTIVITY_TEST_ROOT}/extlibs/android/ca/${target_arch}
100 cp -r ./libs/${target_arch}/* ${IOTIVITY_TEST_ROOT}/extlibs/android/ca/${target_arch}
101
102 cd ${current_path}