-
Notifications
You must be signed in to change notification settings - Fork 14
/
Makefile
161 lines (120 loc) · 3.37 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
#
# Makefile: GraalVM Rules for Bazel
#
# Configuration
#
CI ?= no
DEBUG ?= no
RELEASE ?= no
VERBOSE ?= no
BZLMOD ?= no
COVERAGE ?= yes
TEST ?=
TARGETS ?= //graalvm/... //lib/...
DOCS ?= //docs/api:all
TESTS ?= //.aspect/... //tests/...
PWD ?= $(shell pwd)
ARGS ?=
CONFIGS ?=
# --------------------------------------------------------
CP ?= $(shell which cp)
MV ?= $(shell which mv)
RM ?= $(shell which rm)
GIT ?= $(shell which git)
PNPM ?= $(shell which pnpm)
CHMOD ?= $(shell which chmod)
BAZEL ?= $(shell which bazel)
MKDIR ?= $(shell which mkdir)
YAMLLINT ?= $(shell which yamllint)
# --------------------------------------------------------
_ARGS = $(ARGS)
_CONFIGS = $(CONFIGS)
_STARTUP =
ifeq ($(COVERAGE),yes)
TEST_TASK = coverage
else
TEST_TASK = test
endif
ifeq ($(VERBOSE),yes)
RULE =
else
RULE = @
endif
ifeq ($(BZLMOD),yes)
_CONFIGS += bzlmod
endif
ifeq ($(DEBUG),yes)
_CONFIGS += debug
else
ifeq ($(RELEASE),yes)
_CONFIGS += release
else
_CONFIGS += fastbuild
endif
endif
_ARGS += $(patsubst %,--config=%,$(_CONFIGS))
# --------------------------------------------------------
all: build test docs
# Targets: Build/Test
#
deps: node_modules
node_modules:
$(RULE)$(PNPM) install
build: deps ## Build all targets.
$(RULE)$(BAZEL) $(_STARTUP) build $(TARGETS) $(_ARGS)
test: unit-tests integration-tests ## Run all tests.
unit-tests:
$(RULE)$(BAZEL) $(_STARTUP) $(TEST_TASK) $(TESTS) $(_ARGS)
integration-tests:
$(RULE)for d in example/integration_tests/*; do ( bash $(PWD)/tools/scripts/run_test.sh "$$d"; ); done
integration-test: ## Run a single integration test at name `TEST=x`.
$(RULE)bash $(PWD)/tools/scripts/run_test.sh "example/integration_tests/$(TEST)";
@echo "Test done."
docs: ## Build docs.
@echo "Building docs..."
$(RULE)$(BAZEL) $(_STARTUP) build $(DOCS) \
&& $(CP) -fv bazel-bin/docs/api/*.md ./docs/api/ \
&& $(CHMOD) -R 755 docs/api/;
@echo "Docs rebuilt."
# Targets: Diagnosis
#
args: ## Show current build args.
@echo "Printing args:"
@echo "$(_ARGS)"
config: ## Show current build configuration.
@echo "Current configuration":
@echo "CI: $(CI)"
@echo "Bzlmod: $(BZLMOD)"
@echo "Debug: $(DEBUG)"
@echo "Release: $(RELEASE)"
@echo "Verbose: $(VERBOSE)"
@echo "Coverage: $(COVERAGE)"
@echo "Test task: $(TEST_TASK)"
@echo "Configs: $(CONFIGS)"
@echo "Targets: $(TARGETS)"
@echo "Tests: $(TESTS)"
@echo "Args:"
@echo "$(_ARGS)"
# Targets: Linting
#
lint: deps ## Run the lint checker.
$(RULE)$(PNPM) run lint:check
lint-format: deps ## Run the lint formatter.
$(RULE)$(PNPM) run lint:format
yamllint: deps ## Run yamllint.
$(RULE)$(YAMLLINT) -c .github/.yamllint.yml .bcr .github/workflows .bazelci -s
# Targets: Clean
#
clean: ## Clean built targets.
@echo "Cleaning targets..."
$(RULE)$(BAZEL) clean
distclean: clean ## Clean and expunge; drops all state and kills worker.
$(RULE)$(BAZEL) --expunge
reset: distclean ## Clean, expunge, and perform a hard Git reset (DANGEROUS).
$(RULE)$(GIT) reset --hard
forceclean: reset ## Clean, expunge, reset, and drop all ignored files (DANGEROUS).
$(RULE)$(GIT) clean -xdf
help: ## Show this help message.
$(info GraalVM Rules for Bazel:)
@grep -E '^[a-z1-9A-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: all build test docs clean distclean reset forceclean lint lint-format yamllint config args deps