-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
53 lines (43 loc) · 2.17 KB
/
Makefile
File metadata and controls
53 lines (43 loc) · 2.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
IMAGE := janus
TAG := latest
# Use Python so this works on Unix and Windows (no sed dependency).
JANUS_VERSION := $(shell python -c "import tomllib; print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])")
ifeq ($(strip $(JANUS_VERSION)),)
$(error Could not read version from pyproject.toml)
endif
CLI_LDFLAGS := -ldflags="-s -w -X main.version=$(JANUS_VERSION)"
# Host OS from the Go toolchain — Windows needs .exe for PowerShell/cmd.
GOHOSTOS := $(shell go env GOOS)
ifeq ($(GOHOSTOS),windows)
CLI_OUT := ../../janus-cli.exe
else
CLI_OUT := ../../janus-cli
endif
.PHONY: build test shell clean help cli cli-all
help: ## Show this help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "}; {printf " %-12s %s\n", $$1, $$2}'
@echo ""
@echo "Build the CLI: make cli"
build: ## Build the Docker image
docker build -t $(IMAGE):$(TAG) .
test: build ## Run the test suite inside the container
docker run --rm --entrypoint sh \
-v $(CURDIR):/src:ro \
-w /src \
$(IMAGE):$(TAG) -c "pip install -q pytest && pytest Tests/"
shell: build ## Open a shell in the container
docker run --rm -it --entrypoint /bin/bash \
-v $(CURDIR)/out:/data/out \
-v $(CURDIR)/Config:/config:ro \
$(IMAGE):$(TAG)
clean: ## Remove all versioned output directories and loose output files
rm -rf out/op-* out/latest out/latest.txt out/*.json out/*.ndjson out/*.html
cli: ## Build the Go CLI binary for the current platform (janus-cli.exe on Windows)
cd cmd/janus-cli && go build $(CLI_LDFLAGS) -o $(CLI_OUT) .
cli-all: ## Cross-compile Go CLI for all platforms
cd cmd/janus-cli && GOOS=linux GOARCH=amd64 go build $(CLI_LDFLAGS) -o ../../dist/janus-cli-linux-amd64 .
cd cmd/janus-cli && GOOS=linux GOARCH=arm64 go build $(CLI_LDFLAGS) -o ../../dist/janus-cli-linux-arm64 .
cd cmd/janus-cli && GOOS=darwin GOARCH=amd64 go build $(CLI_LDFLAGS) -o ../../dist/janus-cli-darwin-amd64 .
cd cmd/janus-cli && GOOS=darwin GOARCH=arm64 go build $(CLI_LDFLAGS) -o ../../dist/janus-cli-darwin-arm64 .
cd cmd/janus-cli && GOOS=windows GOARCH=amd64 go build $(CLI_LDFLAGS) -o ../../dist/janus-cli-windows-amd64.exe .