-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
61 lines (49 loc) · 1.8 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
# Public variables
DESTDIR ?=
PREFIX ?= /usr/local
OUTPUT_DIR ?= out
DST ?=
CONTAINER_PREFIX ?= ghcr.io/pojntfx/hydrapp-build-
CONTAINER_TAG ?= latest
# Private variables
obj = hydrapp hydrapp-example-vanillajs-rest hydrapp-example-vanillajs-forms hydrapp-example-react-panrpc
containers = apk deb dmg flatpak msi rpm binaries tests docs
all: $(addprefix build/,$(obj))
# Build
build: $(addprefix build/,$(obj))
$(addprefix build/,$(obj)):
ifdef DST
go build -o $(DST) ./$(subst build/,,$@)
else
go build -o $(OUTPUT_DIR)/$(subst build/,,$@) ./$(subst build/,,$@)
endif
# Build containers
build-containers: $(addprefix build-container/,$(containers))
$(addprefix build-container/,$(containers)):
docker build -t $(CONTAINER_PREFIX)$(subst build-container/,,$@):$(CONTAINER_TAG) ./hydrapp/pkg/builders/$(subst build-container/,,$@)/
# Install
install: $(addprefix install/,$(obj))
$(addprefix install/,$(obj)):
install -D -m 0755 $(OUTPUT_DIR)/$(subst install/,,$@) $(DESTDIR)$(PREFIX)/bin/$(basename $(subst install/,,$@))
# Uninstall
uninstall: $(addprefix uninstall/,$(obj))
$(addprefix uninstall/,$(obj)):
rm -f $(DESTDIR)$(PREFIX)/bin/$(basename $(subst uninstall/,,$@))
# Run
$(addprefix run/,$(obj)):
$(subst run/,,$@) $(ARGS)
# Test
test: $(addprefix test/,$(obj))
$(addprefix test/,$(obj)):
go test -timeout 3600s -parallel $(shell nproc) ./$(shell echo $(subst test/,,$@) | cut -d / -f1)/...
# Benchmark
benchmark: $(addprefix benchmark/,$(obj))
$(addprefix benchmark/,$(obj)):
go test -timeout 3600s -bench=./$(shell echo $(subst benchmark/,,$@) | cut -d / -f1)/... ./$(shell echo $(subst benchmark/,,$@) | cut -d / -f1)/...
# Clean
clean:
rm -rf out
# Dependencies
depend: $(addprefix depend/,$(obj))
$(addprefix depend/,$(obj)):
cd ./$(shell echo $(subst depend/,,$@) | cut -d / -f1) && go generate ./...