-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
162 lines (144 loc) · 5.1 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# -*- coding: utf-8 -*-
# File: ./Makefile
# Authors: Jan Chaloupka
# Jiří Kučera
# Created: N/A
# Project: Go Fedora Packaging Tooling
# Version: See VERSION.
# Brief: Makefile.
#
# Commands & tools:
GO_CMD := go
GO_ENV := $(GO_CMD) env
GO_BUILD := $(GO_CMD) build
GO_BUILD_FLAGS :=
GO_TEST := $(GO_CMD) test
GO_TEST_FLAGS :=
GLOG_FLAGS :=
ECHO := echo
PASS := true
RM := rm
RM_FLAGS := -f
# Params:
# - verbocity level:
ifeq (not$(V)set, notset)
V := 0
endif
V_AUX := $(V)
ifeq ($(V_AUX), 2)
GLOG_FLAGS += -stderrthreshold=INFO
V_AUX := 1
endif
ifeq ($(V_AUX), 1)
GO_BUILD_FLAGS += -v
GO_TEST_FLAGS += -v
V_AUX := 0
endif
# - logging:
ifeq (not$(L)set, notset)
WLOG :=
RMLOG := $(PASS)
else
WLOG := >>$(L) 2>&1
RMLOG := $(RM) $(RM_FLAGS) $(L)
endif
# Setup Go's environment:
# - if not set, get GOROOT from `go env GOROOT`:
ifeq (not$(GOROOT)set, notset)
GOROOT := $(shell $(GO_ENV) GOROOT)
endif
# - if not set, GOPATH will be the current working directory:
ifeq (not$(GOPATH)set, notset)
GOPATH := $(CURDIR)
endif
# GOPATH must be absolute
override GOPATH := $(abspath $(GOPATH))
export GOROOT
export GOPATH
# Locations:
PROJECT_ROOT := github.com/gofed/symbols-extractor
# Products:
define AddProduct =
$$(eval $$(call _AddProduct,$$(strip $(1)),$$(strip $(2))))
endef
define _AddProduct =
$(1) := $(2)
TRASH += $$($(1))
endef
$(eval $(call AddProduct, EXTRACT, extract ))
$(eval $(call AddProduct, SYMBOLTABLES, symboltables/* ))
.PHONY: all help goenv build test gen extract clean
all:
$(MAKE) build V=$(V) L=$(L)
help:
@$(ECHO) "Usage: $(MAKE) <target> [params]"
@$(ECHO) "where <target> is one of"
@$(ECHO) " help - print this screen"
@$(ECHO) " goenv - print the values of Go's environment variables"
@$(ECHO) " build - build this project (default)"
@$(ECHO) " test - run the testsuite on this project"
@$(ECHO) " gen - generate ./pkg/types/types.go"
@$(ECHO) " clean - remove built products"
@$(ECHO) ""
@$(ECHO) "[params] refers to a list of space separated parameters"
@$(ECHO) "of the form KEY=VALUE. The so far supported parameters are"
@$(ECHO) ""
@$(ECHO) " V=number - set the verbocity level; possible values"
@$(ECHO) " of verbocity level are:"
@$(ECHO) " 0 - be quite (default);"
@$(ECHO) " 1 - be verbose, no logging;"
@$(ECHO) " 2 - be verbose, log info messages."
@$(ECHO) " L=logfile - if logfile is given, stderr and stdout are"
@$(ECHO) " redirected to it;"
@$(ECHO) " GOROOT=path - set the Go's GOROOT; the default value is"
@$(ECHO) " taken from '$(GO_ENV) GOROOT';"
@$(ECHO) " GOPATH=path - set the Go's GOPATH; the default value is"
@$(ECHO) " the current working directory."
@$(ECHO) ""
goenv:
@$(RMLOG)
@$(GO_ENV) $(WLOG)
build:
$(RMLOG)
./prep.sh
$(GO_BUILD) $(GO_BUILD_FLAGS) -o extract $(PROJECT_ROOT)/cmd/extract $(WLOG)
$(GO_BUILD) $(GO_BUILD_FLAGS) -o checkapi $(PROJECT_ROOT)/cmd/checkapi $(WLOG)
$(GO_BUILD) $(GO_BUILD_FLAGS) -o golist $(PROJECT_ROOT)/cmd/golist $(WLOG)
test:
@ $(RMLOG)
# $(GO_TEST) $(GO_TEST_FLAGS) $(PROJECT_ROOT)/pkg/parser $(GLOG_FLAGS) \
# $(WLOG)
@ $(GO_TEST) $(GO_TEST_FLAGS) $(PROJECT_ROOT)/pkg/parser/file \
$(PROJECT_ROOT)/pkg/types \
$(PROJECT_ROOT)/pkg/parser/statement \
$(GLOG_FLAGS) $(WLOG)
integration:
@ $(GO_TEST) $(GO_TEST_FLAGS) $(PROJECT_ROOT)/tests/integration/contracts/binaryops \
$(PROJECT_ROOT)/tests/integration/contracts/composite_literals \
$(PROJECT_ROOT)/tests/integration/contracts/function_invocation \
$(PROJECT_ROOT)/tests/integration/contracts/function_literals \
$(PROJECT_ROOT)/tests/integration/contracts/general \
$(PROJECT_ROOT)/tests/integration/contracts/indexable \
$(PROJECT_ROOT)/tests/integration/contracts/pointers \
$(PROJECT_ROOT)/tests/integration/contracts/selectors \
$(PROJECT_ROOT)/tests/integration/contracts/type_casting \
$(PROJECT_ROOT)/tests/integration/contracts/unaryops \
$(PROJECT_ROOT)/tests/integration/contracts/multi_packages \
$(PROJECT_ROOT)/tests/integration/typepropagation/binaryops \
$(PROJECT_ROOT)/tests/integration/typepropagation/function_invocation \
$(PROJECT_ROOT)/tests/integration/typepropagation/composite_literals \
$(PROJECT_ROOT)/tests/integration/typepropagation/function_literals \
$(PROJECT_ROOT)/tests/integration/typepropagation/indexable \
$(PROJECT_ROOT)/tests/integration/typepropagation/pointers \
$(PROJECT_ROOT)/tests/integration/typepropagation/selectors \
$(PROJECT_ROOT)/tests/integration/typepropagation/type_casting \
$(PROJECT_ROOT)/tests/integration/typepropagation/unaryops \
$(PROJECT_ROOT)/tests/integration/typepropagation/general \
$(GLOG_FLAGS) $(WLOG)
# $(PROJECT_ROOT)/tests/integration/typepropagation/basic
gen:
./gentypes.sh
scan:
./extract --stdlib --symbol-table-dir generated --cgo-symbols-path cgo/cgo.yml
clean:
rm -rf extract checkapi generated