-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·96 lines (86 loc) · 2.77 KB
/
build.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
DEMOROOT=$(pwd)
if [ -z "$IOTIVITY_ROOT" ]; then
IOTIVITY_VER="iotivity-1.0.1"
fi
IOTIVITY=$DEMOROOT/$IOTIVITY_VER
print_usage() {
echo "Usage:"
echo "build.sh [TARGET] [ARCH] [CORE]"
echo " "
echo "Without TARGET:"
echo "build whole iotivity project and ubuntu-demo for x86_64"
echo " "
echo "TARGET:"
echo "demo build ubuntu-demo folder only (need to build the whole iotivity project first)"
echo "demo-snappy copy binaries and libraries to snappy folder and build snap package"
echo " (need to build demo first)"
echo "clean clean iotivity built files"
echo " "
echo "ARCH:"
echo "x86_64"
echo "armeabi-v7a-hard"
echo " "
echo "CORE: build with CPU cores enabled (default: 4 cores)"
echo " "
}
if [ -z "$1" ]; then
TARGET="all"
elif [ "$1" == "all" ] || [ "$1" == "demo" ] || [ "$1" == "demo-snappy" ]; then
TARGET=$1
elif [ "$1" == "-h" ]; then
print_usage
exit 0
else
echo "Unknown target $2"
print_usage
exit 1
fi
if [ -z "$2" ] || [ "$2" == "x86_64" ] ; then
ARCH="x86_64"
MAGIC_BIN="x86_64-linux-gnu"
elif [ "$2" == "armeabi-v7a-hard" ]; then
ARCH=$2
MAGIC_BIN="arm-linux-gnueabihf"
else
echo "Unknown architecture $2"
print_usage
exit 1
fi
if [ -z "$3" ]; then
CORE=4
else
CORE=$3
fi
if [ -z "$4" ]; then
SNAPCRAFT="snapcraft"
else
SNAPCRAFT=$4
fi
if ! [ -L $IOTIVITY/ubuntu-demo ]; then
echo "Make symlink to ubuntu-demo"
cd $IOTIVITY && ln -s ../ubuntu-demo ubuntu-demo
fi
if [ "$TARGET" == "all" ]; then
cd $IOTIVITY && scons -j$CORE TARGET_ARCH=$ARCH TARGET_OS=linux
elif [ "$1" == "demo" ]; then
cd $IOTIVITY && scons -j$CORE TARGET_ARCH=$ARCH TARGET_OS=linux ubuntu-demo
elif [ "$1" == "demo-snappy" ]; then
if [ "$ARCH" == "x86_64" ]; then
cp -f $IOTIVITY/out/linux/$ARCH/release/*.so $DEMOROOT/snappy/nucdemo/lib/
cp -f $IOTIVITY/out/linux/$ARCH/release/ubuntu-demo/nucdemo $DEMOROOT/snappy/nucdemo/
cd $DEMOROOT/snappy/nucdemo && $SNAPCRAFT clean && $SNAPCRAFT
fi
cp -f $IOTIVITY/out/linux/$ARCH/release/*.so $DEMOROOT/snappy/demogateway/lib/$MAGIC_BIN/
cp -f $IOTIVITY/out/linux/$ARCH/release/ubuntu-demo/demogateway $DEMOROOT/snappy/demogateway/magic-bin/$MAGIC_BIN/
cd $DEMOROOT/snappy/demogateway && $SNAPCRAFT clean && $SNAPCRAFT
if [ "$ARCH" == "armeabi-v7a-hard" ]; then
cp -f $DEMOROOT/grovepi/grovepi-server.py $DEMOROOT/snappy/grovepi/
cp -rf $DEMOROOT/grovepi/pygrovepi $DEMOROOT/snappy/grovepi/
cd $DEMOROOT/snappy/grovepi && $SNAPCRAFT clean && $SNAPCRAFT
cp -f $IOTIVITY/out/linux/$ARCH/release/*.so $DEMOROOT/snappy/demoserver/lib/
cp -f $IOTIVITY/out/linux/$ARCH/release/ubuntu-demo/demoserver $DEMOROOT/snappy/demoserver/
cd $DEMOROOT/snappy/demoserver && $SNAPCRAFT clean && $SNAPCRAFT
fi
elif [ "$1" == "clean" ]; then
cd $IOTIVITY && scons -c TARGET_ARCH=$ARCH TARGET_OS=linux
fi