-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
81 lines (70 loc) · 2.26 KB
/
Makefile
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
# *****************************************************************************
# Copyright(c) 2021 MASA Group
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
#
# *****************************************************************************
GENERATE = docker run --rm -v $(CURDIR):/pwd -v $(realpath ../models):/models -w /pwd masagroup/soft.generator.go -m /models/$(2) -o /pwd/$(1) -P /pwd/generator.properties $(3)
# os detection
ifeq (${OS},Windows_NT)
MKDIR = mkdir $(subst /,\,$(1)) > nul 2>&1 || (exit 0)
WHICH := where
DEVNULL := NUL
else
MKDIR = mkdir -p $(1)
WHICH := which
DEVNULL := /dev/null
endif
# detect go
ifneq ($(shell $(WHICH) go 2>$(DEVNULL)),)
GO := go
else
ifneq ($(shell $(WHICH) go.exe 2>$(DEVNULL)),)
GO := go.exe
else
$(error "go is not in your system PATH")
endif
endif
.PHONY: all
all: generate fmt lint build test
.PHONY: generate
generate:
@echo "[generate]"
@$(call GENERATE,,ecore.ecore,)
@$(call GENERATE,test,empty.ecore,)
@$(call GENERATE,test,library.ecore,)
@$(call GENERATE,test,tournament.ecore,)
@$(call GENERATE,,tournament.ecore, \
-p featureDelegation=Reflective \
-p module=github.com/masagroup/soft.go \
-p packages=github.com/masagroup/soft.go/test/tournament-reflective/tournament#github.com/masagroup/soft.go/test/tournament-reflective/internal/impls/impls#github.com/masagroup/soft.go/test/tournament-reflective/internal/mocks/mocks)
.PHONY: fmt
fmt:
@echo "[fmt]"
@$(GO) fmt ./...
.PHONY: lint
lint:
@echo "[lint]"
@docker run --rm -v $(CURDIR):/pwd -w /pwd golangci/golangci-lint:v1.62.2-alpine golangci-lint run --timeout=5m
.PHONY: build
build:
@echo "[build]"
@$(GO) build ./...
.PHONY: test
test:
@echo "[test]"
@$(GO) test -covermode=atomic ./...
.PHONY: coverage.console
coverage.console:
@echo "[coverage.console]"
@$(call MKDIR,coverage)
@$(GO) test -coverprofile coverage/coverage.out ./...
@$(GO) tool cover -func=coverage/coverage.out
.PHONY: coverage.html
coverage.html:
@echo "[coverage.html]"
@$(call MKDIR,coverage)
@$(GO) test -coverprofile coverage/coverage.out ./...
@$(GO) tool cover -html=coverage/coverage.out -o coverage/coverage.html