Merge branch 'master' into EDGE-299
[platform/core/system/edge-orchestration.git] / build.sh
1 #! /bin/bash
2
3 export BASE_DIR=$( cd "$(dirname "$0")" ; pwd )
4
5 BINARY_FILE="edge-orchestration"
6 SERVICE_DIR="/etc/systemd/system"
7 SERVICE_FILE="edge-orchestration.service"
8
9 BUILD_ALL=false
10
11 echo "*****************************"
12 echo " Target Binary arch is amd64 "
13 echo "*****************************"
14 export GOARCH=amd64
15 export GOPATH=$GOPATH:$BASE_DIR:$BASE_DIR/vendor
16
17 if [ "$1" = "all" ]; then
18     BUILD_ALL=true
19 fi
20
21
22 function install_prerequisite() {
23     go get github.com/axw/gocov/gocov
24     go get github.com/matm/gocov-html
25     go get github.com/Songmu/make2help/cmd/make2help
26 }
27
28 function build_clean() {
29     make clean
30 }
31
32 function build_binary() {
33     make build-binary
34 }
35
36 function build_object() {
37     make build-object
38 }
39
40 function build_test() {
41     make test
42 }
43
44 function lint_src_code() {
45     make lint
46 }
47
48 function register_service() {
49     echo ""
50     echo "-----------------------------------"
51     echo "  Create Service File [SuperUser]"
52     echo "-----------------------------------"
53
54     sudo systemctl stop $SERVICE_FILE
55     sudo cp $BASE_DIR/bin/$BINARY_FILE /usr/bin
56     sudo cp $BASE_DIR/packaging/$SERVICE_FILE $SERVICE_DIR
57     ls -al $SERVICE_DIR | grep $SERVICE_FILE
58
59     echo ""
60     echo "----------------------------------------"
61     echo "  Register Edge-Orchestration Service"
62     echo "----------------------------------------"
63
64     sudo systemctl daemon-reload
65     sudo systemctl restart $SERVICE_FILE
66     sudo systemctl status $SERVICE_FILE
67 }
68
69
70 if [ "$BUILD_ALL" = true ]
71 then
72     install_prerequisite
73     build_clean
74     build_test
75     build_object
76     build_binary
77     lint_src_code
78     register_service
79 else
80     build_clean
81     build_binary
82 fi
83