forked from horizoncd/horizon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
162 lines (130 loc) · 4.52 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
# Copyright 2023 The Horizoncd Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
# define the default goal
#
# Build all by default, even if it's not first
.DEFAULT_GOAL := help
# ==============================================================================
# Build options
# TODO: It is recommended to refactor horizon cmd module with cobra and add version information. It should be placed in pkg directory
ROOT_PACKAGE=github.com/horizoncd/horizon
#VERSION_PACKAGE=github.com/horizoncd/horizon/pkg/version
# ==============================================================================
# Includes
include scripts/make-rules/common.mk # make sure include common.mk at the first include line
include scripts/make-rules/golang.mk
include scripts/make-rules/image.mk
#include scripts/make-rules/deploy.mk
include scripts/make-rules/copyright.mk
include scripts/make-rules/gen.mk
#include scripts/make-rules/release.mk
#include scripts/make-rules/swagger.mk
#include scripts/make-rules/dependencies.mk
include scripts/make-rules/tools.mk
# ==============================================================================
# Usage
define USAGE_OPTIONS
Options:
DEBUG Whether or not to generate debug symbols. Default is 0.
BINS Binaries to build. Default is all binaries under cmd.
This option is available when using: make {build}(.multiarch)
Example: make build BINS="app"
PLATFORMS Platform to build for. Default is linux_arm64 and linux_amd64.
This option is available when using: make {build}.multiarch
Example: make build.multiarch PLATFORMS="linux_arm64 linux_amd64"
V Set to 1 enable verbose build. Default is 0.
endef
export USAGE_OPTIONS
# ==============================================================================
# Targets
## all: Run all targets
.PHONY: all
all: tidy gen add-copyright format lint cover build
## build: Build the project for horizon
.PHONY: build
build:
@$(MAKE) go.build
## swagger: Build the swagger
.PHONY: swagger
swagger:
@$(MAKE) image.swagger
## swagger-run: Run a swagger server locally
.PHONY: swagger-run
swagger-run:
@$(MAKE) go.swagger-run
## core: Build the core
.PHONY: core
core:
@$(MAKE) image.core
## lint: Check syntax and styling of go sources.
.PHONY: lint
lint:
@$(MAKE) go.lint
## format: Gofmt (reformat) package sources (exclude vendor dir if existed).
.PHONY: format
format: tools.verify.golines tools.verify.goimports
@echo "===========> Formating codes"
@$(FIND) -type f -name '*.go' | $(XARGS) gofmt -s -w
@$(FIND) -type f -name '*.go' | $(XARGS) $(TOOLS_DIR)/goimports -w -local $(ROOT_PACKAGE)
@$(FIND) -type f -name '*.go' | $(XARGS) $(TOOLS_DIR)/golines -w --max-len=120 --reformat-tags --shorten-comments --ignore-generated .
@$(GO) mod edit -fmt
## gen: Generate all necessary files.
.PHONY: gen
gen:
@$(MAKE) gen.run
## verify-copyright: Verify the license headers for all files.
.PHONY: verify-license
verify-license:
@$(MAKE) copyright.verify
## add-license: Add copyright ensure source code files have license headers.
.PHONY: add-license
add-license:
@$(MAKE) copyright.add
## tools: Install dependent tools.
.PHONY: tools
tools:
@$(MAKE) tools.install
## test: Run unit test.
.PHONY: test
test:
@$(MAKE) go.test
## cover: Run unit test and get test coverage.
.PHONY: cover
cover:
@$(MAKE) go.test.cover
## imports: task to automatically handle import packages in Go files using goimports tool
.PHONY: imports
imports:
@$(MAKE) go.imports
## clean: Remove all files that are created by building.
.PHONY: clean
clean:
@$(MAKE) go.clean
## rmi: Clean the project and remove the docker images
.PHONY: rmi
rmi:
@$(MAKE) go.rmi
## tidy: tidy go.mod
.PHONY: tidy
tidy:
@$(GO) mod tidy
## help: Show this help info.
.PHONY: help
help: Makefile
$(call makehelp)
## help-all: Show all help details info.
.PHONY: help-all
help-all: go.help copyright.help tools.help image.help help
$(call makeallhelp)