1 # Copyright (c) 2019 AT&T Intellectual Property.
2 # Copyright (c) 2019 Nokia.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
16 BUILD_DIR=$(dir $(abspath $(lastword $(MAKEFILE_LIST))))
18 ROOT_DIR:=$(abspath $(BUILD_DIR)/..)
20 BUILD_PREFIX?="${USER}-"
23 XAPP_MGR_DOCKER:=${BUILD_PREFIX}appmgr
25 GOSRC := $(abspath $(BUILD_DIR)/../src)
26 GOFILES := $(GOSRC)/*.go
27 COVEROUT := $(abspath $(BUILD_DIR)/cover.out)
28 COVERHTML := $(abspath $(BUILD_DIR)/cover.html)
31 GOBUILD=$(GOCMD) build -a -installsuffix cgo
32 GORUN=$(GOCMD) run -a -installsuffix cgo
33 GOCLEAN=$(GOCMD) clean
34 GOTEST=$(GOCMD) test -v -coverprofile $(COVEROUT)
37 HELMVERSION:=v2.13.0-rc.1
39 #------------------------------------------------------------------------------
41 #-------------------------------------------------------------------- ----------
42 .PHONY: FORCE build deps run unit-test test-pkg test clean docker-base-build docker-base-clean docker-build docker-run docker-clean docker-test-build docker-test-run-unittest docker-test-run-sanity docker-test-run docker-test-clean
50 #------------------------------------------------------------------------------
52 #------------------------------------------------------------------------------
54 XAPP_MGR_DOCKER:=$(shell echo $(XAPP_MGR_DOCKER) | tr '[:upper:]' '[:lower:]')
56 #XAPP_MGR_DOCKER:=$(subst /,_,${XAPP_MGR_DOCKER})
58 #------------------------------------------------------------------------------
60 #------------------------------------------------------------------------------
62 $(BUILD_DIR)$(XAPP_MGR): deps ${wildcard $(GOFILES)}
63 GO_ENABLED=0 GOOS=linux $(GOBUILD) -o $(BUILD_DIR)$(XAPP_MGR) $(GOFILES)
65 build: $(BUILD_DIR)$(XAPP_MGR)
67 deps: ${wildcard $(GOFILES)}
68 cd $(GOSRC) && $(GOGET)
70 run: $(BUILD_DIR)$(XAPP_MGR)
71 $(BUILD_DIR)$(XAPP_MGR) -host-addr="localhost:8080" -helm-host="localhost:31807" -helm-chart="./"
74 cd $(GOSRC) && $(GOTEST)
75 go tool cover -html=$(COVEROUT) -o $(COVERHTML)
78 @echo " > Cleaning build cache"
79 @-rm -rf $(XAPP_MGR) 2> /dev/null
82 #------------------------------------------------------------------------------
84 #------------------------------------------------------------------------------
86 DCKR_BUILD_OPTS:=${DCKR_BUILD_OPTS} --network=host --build-arg HELMVERSION=${HELMVERSION}
88 DCKR_RUN_OPTS:=${DCKR_RUN_OPTS} --rm -i
89 DCKR_RUN_OPTS:=${DCKR_RUN_OPTS}$(shell test -t 0 && echo ' -t')
90 DCKR_RUN_OPTS:=${DCKR_RUN_OPTS}$(shell test -e /etc/localtime && echo ' -v /etc/localtime:/etc/localtime:ro')
91 DCKR_RUN_OPTS:=${DCKR_RUN_OPTS}$(shell test -e /var/run/docker.sock && echo ' -v /var/run/docker.sock:/var/run/docker.sock')
94 #------------------------------------------------------------------------------
96 #------------------------------------------------------------------------------
98 @echo $(XAPP_MGR_DOCKER)
101 docker build --target release ${DCKR_BUILD_OPTS} -t $(XAPP_MGR_DOCKER) -f Dockerfile ../.
104 docker run ${DCKR_RUN_OPTS} -v /opt/ric:/opt/ric -p 8080:8080 $(XAPP_MGR_DOCKER)
107 docker rmi $(XAPP_MGR_DOCKER)
110 #------------------------------------------------------------------------------
112 #------------------------------------------------------------------------------
115 docker build --target test_unit ${DCKR_BUILD_OPTS} -t ${XAPP_MGR_DOCKER}-test_unit -f Dockerfile ../.
116 docker build --target test_sanity ${DCKR_BUILD_OPTS} -t ${XAPP_MGR_DOCKER}-test_sanity -f Dockerfile ../.
118 docker-test-run-unit:
119 docker run ${DCKR_RUN_OPTS} ${XAPP_MGR_DOCKER}-test_unit
121 docker-test-run-sanity:
122 docker run ${DCKR_RUN_OPTS} ${XAPP_MGR_DOCKER}-test_sanity
124 docker-test-run: docker-test-run-sanity docker-test-run-unit
127 docker rmi -f ${XAPP_MGR_DOCKER}-test_unit
128 docker rmi -f ${XAPP_MGR_DOCKER}-test_sanity