Merge "Broke out build script into variability.. Added support to build either in...
[contrib/iotivity.git] / auto_build.sh
1 #! /bin/bash
2
3 function clean()
4 {
5         echo "*********** Clean build *************"
6         scons -c
7         rm out -rf
8 }
9
10 function build()
11 {
12         echo "*********** Build for linux *************"
13         scons
14
15         # Note: for android, as oic-resource uses C++11 feature stoi and to_string,
16         # it requires gcc-4.9, currently only android-ndk-r10(for linux)
17         # and windows android-ndk-r10(64bit target version) support these features.
18
19         echo "*********** Build for android x86 *************"
20         scons BUILD_TARGET=Android CPU_ARCH=x86 ANDROID_HOME=$1 ANDROID_NDK=$2
21
22         echo "*********** Build for android armeabi *************"
23         scons BUILD_TARGET=Android CPU_ARCH=armeabi ANDROID_HOME=$1 ANDROID_NDK=$2
24
25         echo "*********** Build for android armeabi-v7a *************"
26         scons BUILD_TARGET=Android CPU_ARCH=armeabi-v7a ANDROID_HOME=$1 ANDROID_NDK=$2
27
28         echo "*********** Build for android armeabi-v7a-hard *************"
29         scons BUILD_TARGET=Android CPU_ARCH=armeabi-v7a-hard ANDROID_HOME=$1 ANDROID_NDK=$2
30
31         echo "*********** Build for arduino avr *************"
32         scons BUILD_TARGET=Arduino CPU_ARCH=avr ARDUINO_HOME=$3
33
34         echo "*********** Build for arduino arm *************"
35         scons BUILD_TARGET=Arduino CPU_ARCH=arm ARDUINO_HOME=$3
36
37         if [ $(uname -s) = "Darwin" ]
38         then
39                 echo "*********** Build for OSX i386 *************"
40                 scons BUILD_TARGET=Darwin CPU_ARCH=i386 SYS_VERSION=10.9
41
42                 echo "*********** Build for OSX x86_64 *************"
43                 scons BUILD_TARGET=Darwin CPU_ARCH=x86_64 SYS_VERSION=10.9
44
45                 echo "*********** Build for IOS i386 *************"
46                 scons BUILD_TARGET=IOS CPU_ARCH=i386 SYS_VERSION=7.0
47
48                 echo "*********** Build for IOS x86_64 *************"
49                 scons BUILD_TARGET=IOS CPU_ARCH=x86_64 SYS_VERSION=7.0
50
51                 echo "*********** Build for IOS armv7 *************"
52                 scons BUILD_TARGET=IOS CPU_ARCH=armv7 SYS_VERSION=7.0
53
54                 echo "*********** Build for IOS armv7s *************"
55                 scons BUILD_TARGET=IOS CPU_ARCH=armv7s SYS_VERSION=7.0
56
57                 echo "*********** Build for IOS arm64 *************"
58                 scons BUILD_TARGET=IOS CPU_ARCH=arm64 SYS_VERSION=7.0
59         fi
60 }
61
62 function  help()
63 {
64         echo "Usage:"
65         echo "  build:"
66         echo "     `basename $0` <path-to-android-sdk> <path-to-android-ndk> <path-to-arduino-home>"
67         echo "  clean:"
68         echo "     `basename $0` -c"
69 }
70
71 if [ $# -eq 1 ]
72 then
73         if [ $1 = '-c' ]
74         then
75                 clean
76                 exit 0
77         else
78                 help
79                 exit -1
80         fi
81 elif [ $# -ne 3 ]
82 then
83         help
84         exit -1
85 fi
86
87
88 build $1 $2 $3
89 echo "===================== done ====================="