forked from agentgateway/agentgateway
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
148 lines (123 loc) · 4.71 KB
/
Copy pathMakefile
File metadata and controls
148 lines (123 loc) · 4.71 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
136
137
138
139
140
141
142
143
144
145
146
147
148
# Image configuration
DOCKER_REGISTRY ?= ghcr.io
DOCKER_REPO ?= agentgateway
IMAGE_NAME ?= agentgateway
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || jj log -r @ -T 'commit_id.shortest(12)' --no-graph 2>/dev/null || echo unknown)
GIT_REVISION ?= $(shell git rev-parse HEAD 2>/dev/null || jj log -r @ -T 'commit_id' --no-graph 2>/dev/null || echo unknown)
IMAGE_TAG ?= $(VERSION)
IMAGE_FULL_NAME ?= $(DOCKER_REGISTRY)/$(DOCKER_REPO)/$(IMAGE_NAME):$(IMAGE_TAG)
DOCKER_BUILDER ?= docker
DOCKER_BUILD_ARGS ?= --build-arg VERSION=$(VERSION) --build-arg GIT_REVISION=$(GIT_REVISION)
DOCKERFILE_S390X ?= Dockerfile.s390x
export PATH := ./tools:$(PATH)
# docker
.PHONY: docker
docker:
ifeq ($(OS),Windows_NT)
$(DOCKER_BUILDER) build $(DOCKER_BUILD_ARGS) -f Dockerfile.windows -t $(IMAGE_FULL_NAME) .
else
$(DOCKER_BUILDER) build $(DOCKER_BUILD_ARGS) -t $(IMAGE_FULL_NAME) . --progress=plain
endif
.PHONY: docker-ci
docker-ci:
ifeq ($(OS),Windows_NT)
$(DOCKER_BUILDER) build $(DOCKER_BUILD_ARGS) --build-arg PROFILE=ci -f Dockerfile.windows -t $(IMAGE_FULL_NAME) .
else
$(DOCKER_BUILDER) build $(DOCKER_BUILD_ARGS) --build-arg PROFILE=ci -t $(IMAGE_FULL_NAME) . --progress=plain
endif
.PHONY: docker-musl
docker-musl:
$(DOCKER_BUILDER) build $(DOCKER_BUILD_ARGS) -t $(IMAGE_FULL_NAME)-musl --build-arg=BUILDER=musl . --progress=plain
# Build the s390x image from the standalone example Dockerfile.
# NOTE: s390x is NOT an officially supported build architecture; this builds the
# unsupported $(DOCKERFILE_S390X) reference and must be run natively on s390x.
.PHONY: docker-s390x
docker-s390x:
$(DOCKER_BUILDER) build $(DOCKER_BUILD_ARGS) -f $(DOCKERFILE_S390X) -t $(IMAGE_FULL_NAME)-s390x . --progress=plain
CARGO_BUILD_ARGS ?=
# The web UI is embedded into the binary via the `ui` cargo feature, which
# compiles the built assets from ui/dist into the binary at build time. Those
# assets are generated by the Node/pnpm build and are not checked in, so a plain
# `cargo build --features ui` on a fresh checkout fails.
#
# `make build` rebuilds the UI before embedding it. Set UI=0 to build without the
# embedded UI and skip the Node/pnpm build, which is useful for fast iteration on
# the proxy itself (no Node toolchain required).
UI ?= 1
ifeq ($(UI),0)
UI_PREREQ :=
UI_FEATURE :=
else
UI_PREREQ := ui
UI_FEATURE := --features ui
endif
# `corepack pnpm` needs no `corepack enable`, so this works on a fresh checkout.
.PHONY: ui
ui:
cd ui && corepack pnpm install --frozen-lockfile && corepack pnpm build
# build
.PHONY: build
build: $(UI_PREREQ)
cargo build --release $(UI_FEATURE) $(CARGO_BUILD_ARGS)
.PHONY: build-target
build-target: $(UI_PREREQ)
cargo build $(UI_FEATURE) $(CARGO_BUILD_ARGS) --target $(TARGET) --profile $(PROFILE)
# Build with the SymCrypt provider instead of the default aws-lc-rs. --no-default-features
# also drops jemalloc/mimalloc, which the Linux allocator requires, so they are re-added.
.PHONY: build-symcrypt
build-symcrypt: $(UI_PREREQ)
cargo build --release --no-default-features --features jemalloc,mimalloc,crypto-symcrypt $(UI_FEATURE) $(CARGO_BUILD_ARGS)
# lint
.PHONY: lint
lint:
cargo fmt --check -- --config imports_granularity=Module,group_imports=StdExternalCrate,normalize_comments=true
cargo clippy --all-targets
.PHONY: clippy
fix-clippy:
cargo clippy --fix --allow-staged --allow-dirty --allow-no-vcs
.PHONY: format
format:
cargo fmt -- --config imports_granularity=Module,group_imports=StdExternalCrate,normalize_comments=true
.PHONY: fix-lint
fix-lint:
$(MAKE) fix-clippy
$(MAKE) format
# test
.PHONY: test
test:
# Unlike --all-targets, these selectors honor test = false on binaries while
# still covering library/integration tests, examples, and benchmarks.
cargo test --tests --benches --examples $(if $(TIMINGS),--timings)
.PHONY: test-release
test-release:
cargo test --profile quick-release --tests --benches --examples $(if $(TIMINGS),--timings)
.PHONY: check-default-members
check-default-members:
@cargo metadata --no-deps --format-version 1 | jq -e -f tools/check-default-members.jq >/dev/null
# clean
.PHONY: clean
clean:
cargo clean
objects := $(wildcard examples/*/config.json)
.PHONY: check-clean-repo
check-clean-repo:
@tools/check_clean_repo.sh
.PHONY: gen
gen: generate-apis generate-schema format
@:
.PHONY: generate-schema
generate-schema:
@cargo xtask schema
# Code generation for xds apis
.PHONY: generate-apis
generate-apis:
@PATH="./common/tools:$(PATH)" buf generate --path crates/protos/proto/resource.proto --path crates/protos/proto/ext_mcp.proto
.PHONY: run-validation-deps
run-validation-deps:
@tools/manage-validation-deps.sh start
.PHONY: stop-validation-deps
stop-validation-deps:
@tools/manage-validation-deps.sh stop
.PHONY: validate
validate:
@tools/validate-configs.sh