blob: 4edffec2dcd06e7975482408f08741e94a7b21f7 [file] [log] [blame]
Mohamed Abukar2e78e422019-06-02 11:45:52 +03001# Copyright (c) 2019 AT&T Intellectual Property.
2# Copyright (c) 2019 Nokia.
3#
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
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
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.
15
16ROOT_DIR:=.
17BUILD_DIR:=$(ROOT_DIR)/build
18
19COVEROUT := $(BUILD_DIR)/cover.out
20COVERHTML := $(BUILD_DIR)/cover.html
21
22GOOS=$(shell go env GOOS)
23GOCMD=go
24GOBUILD=$(GOCMD) build -a -installsuffix cgo
25GOTEST=$(GOCMD) test -v -coverprofile $(COVEROUT)
26
27GOFILES := $(shell find $(ROOT_DIR) -name '*.go' -not -name '*_test.go') go.mod go.sum
28GOFILES_NO_VENDOR := $(shell find $(ROOT_DIR) -path ./vendor -prune -o -name "*.go" -not -name '*_test.go' -print)
29
30APP:=$(BUILD_DIR)/xapp-sim
31APPTST:=$(APP)_test
32
33.PHONY: FORCE
34
35.DEFAULT: build
36
37default: build
38
39$(APP): $(GOFILES)
40 GO111MODULE=on GO_ENABLED=0 GOOS=linux $(GOBUILD) -o $@ ./test/xapp
41
42$(APPTST): $(GOFILES)
43 GO111MODULE=on GO_ENABLED=0 GOOS=linux $(GOTEST) -c -o $@ ./pkg/xapp
44 RMR_SEED_RT=config/uta_rtg.rt $@ -f config/config-file.yaml -test.coverprofile $(COVEROUT)
45 go tool cover -html=$(COVEROUT) -o $(COVERHTML)
46
47build: $(APP)
48
49test: $(APPTST)
50
51fmt: $(GOFILES_NO_VENDOR)
52 gofmt -w -s $^
53 @(RESULT="$$(gofmt -l $^)"; test -z "$${RESULT}" || (echo -e "gofmt failed:\n$${RESULT}" && false) )
54
55clean:
56 @echo " > Cleaning build cache"
57 @-rm -rf $(APP) $(APPTST) 2> /dev/null
58 go clean 2> /dev/null