Mohamed Abukar | 2e78e42 | 2019-06-02 11:45:52 +0300 | [diff] [blame^] | 1 | # 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 | |
| 16 | ROOT_DIR:=. |
| 17 | BUILD_DIR:=$(ROOT_DIR)/build |
| 18 | |
| 19 | COVEROUT := $(BUILD_DIR)/cover.out |
| 20 | COVERHTML := $(BUILD_DIR)/cover.html |
| 21 | |
| 22 | GOOS=$(shell go env GOOS) |
| 23 | GOCMD=go |
| 24 | GOBUILD=$(GOCMD) build -a -installsuffix cgo |
| 25 | GOTEST=$(GOCMD) test -v -coverprofile $(COVEROUT) |
| 26 | |
| 27 | GOFILES := $(shell find $(ROOT_DIR) -name '*.go' -not -name '*_test.go') go.mod go.sum |
| 28 | GOFILES_NO_VENDOR := $(shell find $(ROOT_DIR) -path ./vendor -prune -o -name "*.go" -not -name '*_test.go' -print) |
| 29 | |
| 30 | APP:=$(BUILD_DIR)/xapp-sim |
| 31 | APPTST:=$(APP)_test |
| 32 | |
| 33 | .PHONY: FORCE |
| 34 | |
| 35 | .DEFAULT: build |
| 36 | |
| 37 | default: 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 | |
| 47 | build: $(APP) |
| 48 | |
| 49 | test: $(APPTST) |
| 50 | |
| 51 | fmt: $(GOFILES_NO_VENDOR) |
| 52 | gofmt -w -s $^ |
| 53 | @(RESULT="$$(gofmt -l $^)"; test -z "$${RESULT}" || (echo -e "gofmt failed:\n$${RESULT}" && false) ) |
| 54 | |
| 55 | clean: |
| 56 | @echo " > Cleaning build cache" |
| 57 | @-rm -rf $(APP) $(APPTST) 2> /dev/null |
| 58 | go clean 2> /dev/null |