-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
135 lines (118 loc) · 4.17 KB
/
Makefile
File metadata and controls
135 lines (118 loc) · 4.17 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
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
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOMOD=$(GOCMD) mod
GOMOBILE=gomobile
GOLINT=golangci-lint
# Project paths
CLI_DIR=./cli
MOBILE_PKG=./mobile
BUILD_DIR=./build
BIN_DIR=./bin
CLI_OUTPUT=$(BIN_DIR)/gocircum-cli
# Default target runs the build for all artifacts
.PHONY: all
all: build-cli build-mobile
# Help target to display available commands
.PHONY: help
help:
@echo "Available commands:"
@echo " build Build the project"
@echo " clean Clean build artifacts"
@echo " deps Install dependencies"
@echo " help Show this help message"
@echo " install-deps Install required tools"
@echo " lint Lint the codebase with golangci-lint"
@echo " lint-mathrandom Check for insecure math/rand usage"
@echo " lint-dnsleaks Check for DNS leaks"
@echo " lint-all Run all linters (golangci-lint, mathrandom, and dnsleaks)"
@echo " tidy Tidy go.mod and go.sum files"
@echo " test Run tests"
@echo " test-race Run tests with race detector"
@echo " test-all Run all tests including integration tests"
@echo " coverage Generate test coverage report"
# Dependency installation
.PHONY: install-deps
install-deps:
@echo "Installing gomobile and golangci-lint..."
$(GOCMD) install golang.org/x/mobile/cmd/gomobile@latest
$(GOMOBILE) init
$(GOCMD) install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
# Build targets
.PHONY: build-cli
build-cli:
@echo "Building gocircum-cli..."
@mkdir -p $(BIN_DIR)
$(GOBUILD) -o $(CLI_OUTPUT) $(CLI_DIR)
.PHONY: build-mobile
build-mobile: android ios
@echo "Mobile libraries built successfully in $(BUILD_DIR)"
.PHONY: android
android:
@echo "Building Android library (.aar)..."
@mkdir -p $(BUILD_DIR)/android
$(GOMOBILE) bind -o $(BUILD_DIR)/android/gocircum.aar -target=android $(MOBILE_PKG)
.PHONY: ios
ios:
@echo "Building iOS framework (.xcframework)..."
@mkdir -p $(BUILD_DIR)/ios
$(GOMOBILE) bind -o $(BUILD_DIR)/ios/Gocircum.xcframework -target=ios $(MOBILE_PKG)
# Testing and linting
.PHONY: test
test:
@echo "Running tests for standard packages..."
$(eval PKGS_TO_TEST := $(shell go list ./... | grep -v /mobile))
@echo "Running tests on packages: $(PKGS_TO_TEST)"
$(GOTEST) -timeout 30s -v -count=1 $(PKGS_TO_TEST)
@echo "Running mobile bridge tests specifically..."
$(GOTEST) -timeout 10s -v -count=1 ./mobile/bridge
.PHONY: test-race
test-race:
@echo "Running tests with race detector..."
$(eval PKGS_TO_TEST := $(shell go list ./... | grep -v /mobile))
@echo "Running tests on packages: $(PKGS_TO_TEST)"
$(GOTEST) -timeout 60s -v -race -count=1 $(PKGS_TO_TEST)
@echo "Running mobile bridge tests specifically with race detector..."
$(GOTEST) -timeout 30s -v -race -count=1 ./mobile/bridge
.PHONY: lint
lint:
@echo "Linting code..."
@command -v $(GOLINT) >/dev/null 2>&1 || { echo >&2 "golangci-lint not found. Please run 'make install-deps'"; exit 1; }
$(GOLINT) run ./...
.PHONY: lint-mathrandom
lint-mathrandom:
@echo "Checking for insecure math/rand usage..."
@mkdir -p $(BIN_DIR)
@if [ ! -f "$(BIN_DIR)/mathrandom-linter" ]; then \
echo "Building mathrandom-linter..."; \
$(GOBUILD) -o $(BIN_DIR)/mathrandom-linter ./cmd/mathrandom-linter; \
fi
$(BIN_DIR)/mathrandom-linter -dir=. -exempt-file=./configs/mathrandom-exempt.json
.PHONY: lint-dnsleaks
lint-dnsleaks:
@echo "Checking for DNS leaks..."
@mkdir -p $(BIN_DIR)
@if [ ! -f "$(BIN_DIR)/dnsleaks-linter" ]; then \
echo "Building dnsleaks-linter..."; \
$(GOBUILD) -o $(BIN_DIR)/dnsleaks-linter ./cmd/dnsleaks-linter; \
fi
$(BIN_DIR)/dnsleaks-linter -dir=. -exempt-file=./configs/dnsleaks-exempt.json
.PHONY: lint-all
lint-all: lint lint-mathrandom lint-dnsleaks
@echo "All linting checks completed"
# Dependency management
.PHONY: tidy
tidy:
@echo "Tidying go modules..."
$(GOMOD) tidy
# Clean up
.PHONY: clean
clean:
@echo "Cleaning up build artifacts..."
rm -rf $(BIN_DIR) $(BUILD_DIR)
.PHONY: repomix
repomix:
@echo "Running repomix with ignore patterns..."
repomix --ignore '**/*mock**,**/*test*,**/*.json,**/*.js,**/*.md,**/*.svg,**/*.xml,./onepager/**,**/*.py,**/*.txt,**/docs,**/LICENSE'