-
Notifications
You must be signed in to change notification settings - Fork 76
Expand file tree
/
Copy pathMakefile
More file actions
78 lines (61 loc) · 2.11 KB
/
Copy pathMakefile
File metadata and controls
78 lines (61 loc) · 2.11 KB
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
# Copyright IBM Corp All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
# -------------------------------------------------------------
# Run `make help` to find the supported targets
# Disable implicit rules
.SUFFIXES:
MAKEFLAGS += --no-builtin-rules
BUILD_DIR ?= bin
PKGNAME = github.com/hyperledger/fabric-x-common
PKGNAME2 = github.com/hyperledger/fabric-x/tools
GO_TAGS ?=
go_cmd ?= go
TOOLS_EXES = configtxgen configtxlator cryptogen fxconfig
pkgmap.configtxgen := $(PKGNAME2)/configtxgen
pkgmap.configtxlator := $(PKGNAME2)/configtxlator
pkgmap.cryptogen := $(PKGNAME2)/cryptogen
pkgmap.fxconfig := $(PKGNAME2)/fxconfig
.DEFAULT_GOAL := help
MAKEFLAGS += --jobs=16
.PHONY: help
# List all commands with documentation
help: ## List all commands with documentation
@echo "Available commands:"
@awk 'BEGIN {FS = ":.*?## "}; /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
.PHONY: tools
tools: $(TOOLS_EXES) ## Builds all tools
# Use gotestsum (same style as fabric-x-committer):
# - compact output format
# - does not rerun failed tests
TEST_METHOD = $(go_cmd) tool gotestsum --rerun-fails=0 --format dots --packages "$(1)" -- -v -timeout 30m $(2)
## Run generate
.PHONY: generate
generate: FORCE
go generate ./...
## Run all tests
.PHONY: test
test: FORCE
@echo "Running Go unit tests..."
cd tools && $(call TEST_METHOD,./...)
.PHONY: $(TOOLS_EXES)
$(TOOLS_EXES): %: $(BUILD_DIR)/% ## Builds a native binary
$(BUILD_DIR)/%: GO_LDFLAGS = $(METADATA_VAR:%=-X $(PKGNAME)/common/metadata.%)
$(BUILD_DIR)/%:
@echo "Building $@"
@mkdir -p $(@D)
@GOBIN=$(abspath $(@D)) go install -tags "$(GO_TAGS)" -ldflags "$(GO_LDFLAGS)" -buildvcs=false $(pkgmap.$(@F))
@touch $@
.PHONY: clean
clean: ## Cleans the build area
-@rm -rf $(BUILD_DIR)
# Run lint
# TODO: fix existing lint issues (to find them, remove --new-from-rev=origin/main option)
.PHONY: lint
lint: FORCE
@echo "Running Go Linters..."
cd tools && golangci-lint run --new-from-rev=origin/main --color=always --max-same-issues 0
@echo "Running License Header Linters..."
scripts/license-lint.sh
FORCE: