forked from GoogleCloudPlatform/scion
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
94 lines (78 loc) · 2.95 KB
/
Copy pathMakefile
File metadata and controls
94 lines (78 loc) · 2.95 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
# Scion Makefile
# Run 'make help' to see available targets.
BINARY := scion
BUILD_DIR := ./build
CONTAINER_DIR := ./.build/container
INSTALL_DIR := $(HOME)/.local/bin
MAIN_PKG := ./cmd/scion
LDFLAGS := $(shell ./hack/version.sh)
SCIONTOOL_LDFLAGS := $(shell ./hack/version.sh github.com/GoogleCloudPlatform/scion/cmd/sciontool/commands)
CONTAINER_OS := linux
CONTAINER_ARCH := $(shell if [ "$$(uname -m)" = "x86_64" ]; then echo amd64; else echo arm64; fi)
.DEFAULT_GOAL := help
.PHONY: all build install test test-fast vet lint web clean help container-sciontool container-scion container-binaries
## all: Build the web frontend, then compile the Go binary with embedded assets
all: web install
## build: Compile the scion binary into ./build/
build:
@echo "Building $(BINARY)..."
@mkdir -p $(BUILD_DIR)
@go build -buildvcs=false -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY) $(MAIN_PKG)
@echo "Binary: $(BUILD_DIR)/$(BINARY)"
## install: Build and install the binary to ~/.local/bin
install: build
@echo "Installing $(BINARY) to $(INSTALL_DIR)..."
@mkdir -p $(INSTALL_DIR)
@install $(BUILD_DIR)/$(BINARY) $(INSTALL_DIR)/$(BINARY)
@echo "Installed: $(INSTALL_DIR)/$(BINARY)"
## test: Run all tests
test:
@echo "Running tests..."
@go test ./...
## test-fast: Run tests without SQLite (lower memory usage)
test-fast:
@echo "Running tests (no SQLite)..."
@go test -tags no_sqlite ./...
## vet: Run go vet
vet:
@go vet ./...
## lint: Run go vet (no SQLite, memory-safe)
lint:
@go vet -tags no_sqlite ./...
## web: Build the web frontend
web:
@echo "Building web frontend..."
@cd web && npm install && npm run build
@echo "Web frontend built."
## container-sciontool: Cross-compile sciontool for Linux containers
container-sciontool:
@echo "Building sciontool for $(CONTAINER_OS)/$(CONTAINER_ARCH)..."
@mkdir -p $(CONTAINER_DIR)
@GOOS=$(CONTAINER_OS) GOARCH=$(CONTAINER_ARCH) CGO_ENABLED=0 \
go build -buildvcs=false -ldflags "$(SCIONTOOL_LDFLAGS)" \
-o $(CONTAINER_DIR)/sciontool ./cmd/sciontool
@echo "Built: $(CONTAINER_DIR)/sciontool"
## container-scion: Cross-compile scion CLI for Linux containers
container-scion:
@echo "Building scion for $(CONTAINER_OS)/$(CONTAINER_ARCH)..."
@mkdir -p $(CONTAINER_DIR)
@GOOS=$(CONTAINER_OS) GOARCH=$(CONTAINER_ARCH) CGO_ENABLED=0 \
go build -buildvcs=false -tags no_embed_web -ldflags "$(LDFLAGS)" \
-o $(CONTAINER_DIR)/scion ./cmd/scion
@echo "Built: $(CONTAINER_DIR)/scion"
## container-binaries: Build both scion and sciontool for Linux containers
container-binaries: container-sciontool container-scion
@echo ""
@echo "Dev binaries ready in $(CONTAINER_DIR)/"
@echo "Usage: export SCION_DEV_BINARIES=$(CONTAINER_DIR)"
## clean: Remove build artifacts
clean:
@echo "Cleaning..."
@rm -rf $(BUILD_DIR) .build
@rm -f $(BINARY)
@echo "Done."
## help: Show this help message
help:
@echo "Usage: make [target]"
@echo ""
@grep -E '^## ' $(MAKEFILE_LIST) | sed 's/^## / /' | column -t -s ':'