-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
77 lines (61 loc) · 2.14 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
# Detect OS
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
PLATFORM := darwin
else ifeq ($(UNAME_S),Linux)
PLATFORM := linux
else
$(error Unsupported platform: $(UNAME_S))
endif
SUDO_C := $(shell which sudo)
# Detect architecture
UNAME_M := $(shell uname -m)
ifeq ($(UNAME_M),arm64)
ARCH := arm64
else ifeq ($(UNAME_M),x86_64)
ARCH := amd64
else
$(error Unsupported architecture: $(UNAME_M))
endif
# Combine platform and architecture
TARGET := tdiscuss-$(PLATFORM)-$(ARCH)
# Bazel build command
BAZEL := bazelisk
BAZEL_BUILD_ARGS := build --config=silent --workspace_status_command="$${PWD}/status.sh"
BAZEL_RELEASE_ARGS := build --config=silent --stamp --workspace_status_command="$${PWD}/status.sh"
BAZEL_TEST_ARGS := test --config=silent --build_tests_only --test_output=errors
BAZEL_RUN_ARGS := run
# Change the hostname to anything you wish to use for testing
BAZEL_RUN_TRAILING_ARGS := -hostname discuss-dev -debug
.PHONY: all clean test run run-binary genhtml release coverage setup-db
all: check-go-versions test build
build:
@echo "Building for $(PLATFORM)-$(ARCH)"
$(BAZEL) $(BAZEL_BUILD_ARGS) //:$(TARGET)
test:
@echo "Testing all targets"
$(BAZEL) $(BAZEL_TEST_ARGS) //...
run:
@echo "Running for $(PLATFORM)-$(ARCH) from $(BAZEL)"
$(BAZEL) $(BAZEL_RUN_ARGS) //:$(TARGET) -- $(BAZEL_RUN_TRAILING_ARGS)
run-binary:
@echo "Running for $(PLATFORM)-$(ARCH) from $(shell $(BAZEL) info bazel-bin)"
$(shell $(BAZEL) info bazel-bin)/$(TARGET)_/$(TARGET) $(BAZEL_RUN_TRAILING_ARGS)
release:
@echo "Building release for $(PLATFORM)-$(ARCH)"
$(BAZEL) $(BAZEL_RELEASE_ARGS) //:$(TARGET)
coverage:
@echo "Generating coverage for //..."
$(BAZEL) coverage --combined_report=lcov //...
genhtml:
@echo "Generating HTML report for coverage"
@[ -d "$(shell pwd)/genhtml" ] && rm -rf "$(shell pwd)/genhtml" && echo "Removed previous genhtml/"
@genhtml --branch-coverage --output genhtml "$(shell $(BAZEL) info output_path)/_coverage/_coverage_report.dat" 2>&1>/dev/null
clean-db:
@dropdb -U discuss discuss
@createdb -U discuss discuss
@psql -U discuss discuss < sqlc/schema.sql
clean:
$(BAZEL) clean
check-go-versions:
@bash check-go-versions.sh