Skip to content

Commit 6850f97

Browse files
Separate makefile for protovalidate gencode
1 parent 5284582 commit 6850f97

File tree

4 files changed

+54
-141
lines changed

4 files changed

+54
-141
lines changed

Makefile

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ ADD_LICENSE_HEADER := $(BIN)/license-header \
1515
--license-type apache \
1616
--copyright-holder "Buf Technologies, Inc." \
1717
--year-range "2023-2025"
18-
# This version should be kept in sync with the version in buf.yaml
19-
PROTOVALIDATE_VERSION ?= v0.14.0
18+
# This version should be kept in sync with the version in buf.yaml and the bufbuild-protovalidate-protocolbuffers version in uv.lock
19+
PROTOVALIDATE_TESTING_VERSION ?= v0.14.0
2020
# Version of the cel-spec that this implementation is conformant with
2121
# This should be kept in sync with the version in test/test_format.py
2222
CEL_SPEC_VERSION ?= v0.24.0
@@ -35,14 +35,14 @@ clean: ## Delete intermediate build artifacts
3535
git clean -Xdf
3636

3737
.PHONY: generate
38-
generate: generate-protovalidate-pypi-package generate-protobuf-tests $(BIN)/license-header ## Regenerate code and license headers
38+
generate: generate-protobuf-tests $(BIN)/license-header ## Regenerate code and license headers
3939
$(ADD_LICENSE_HEADER)
4040

4141
.PHONY: generate-protobuf-tests
4242
generate-protobuf-tests: $(BIN)/buf ## Regenerate protobuf gencode used in unit tests
4343
rm -rf test/gen
4444
# generate protovalidate-testing into test/gen/buf/validate
45-
$(BIN)/buf generate buf.build/bufbuild/protovalidate-testing:$(PROTOVALIDATE_VERSION)
45+
$(BIN)/buf generate buf.build/bufbuild/protovalidate-testing:$(PROTOVALIDATE_TESTING_VERSION)
4646

4747
# generate cel-spec into test/gen/cel/expr
4848
$(BIN)/buf generate buf.build/google/cel-spec:$(CEL_SPEC_VERSION) --exclude-path cel/expr/conformance/proto2 --exclude-path cel/expr/conformance/proto3
@@ -52,16 +52,6 @@ generate-protobuf-tests: $(BIN)/buf ## Regenerate protobuf gencode used in unit
5252
# generate proto/tests/example/v1/validations.proto into test/gen/tests/example/v1
5353
$(BIN)/buf generate
5454

55-
.PHONY:
56-
generate-protovalidate-pypi-package: $(BIN)/buf ## Regenerate protobuf gencode for the bufbuild-protovalidate-protocolbuffers pypi package
57-
rm -rf bufbuild-protovalidate-protocolbuffers/buf/validate/proto5
58-
rm -rf bufbuild-protovalidate-protocolbuffers/buf/validate/proto6
59-
# generate gencode for both proto5 and proto6 for buf.build/bufbuild/protovalidate
60-
cd bufbuild-protovalidate-protocolbuffers && ../$(BIN)/buf generate buf.build/bufbuild/protovalidate:$(PROTOVALIDATE_VERSION)
61-
62-
# set the version of bufbuild-protovalidate-protocolbuffers to the used PROTOVALIDATE_VERSION
63-
sed -i .bak 's/^version = "[^"]*"/version = "$(PROTOVALIDATE_VERSION)"/' bufbuild-protovalidate-protocolbuffers/pyproject.toml && rm bufbuild-protovalidate-protocolbuffers/pyproject.toml.bak
64-
6555
.PHONY: format
6656
format: install $(BIN)/buf $(BIN)/license-header ## Format code
6757
$(ADD_LICENSE_HEADER)
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# See https://tech.davis-hansson.com/p/make/
2+
SHELL := bash
3+
.DELETE_ON_ERROR:
4+
.SHELLFLAGS := -eu -o pipefail -c
5+
.DEFAULT_GOAL := all
6+
MAKEFLAGS += --warn-undefined-variables
7+
MAKEFLAGS += --no-builtin-rules
8+
MAKEFLAGS += --no-print-directory
9+
BIN := .tmp/bin
10+
export PATH := $(BIN):$(PATH)
11+
export GOBIN := $(abspath $(BIN))
12+
CONFORMANCE_ARGS ?= --strict_message --expected_failures=test/conformance/nonconforming.yaml --timeout 10s
13+
ADD_LICENSE_HEADER := $(BIN)/license-header \
14+
--license-type apache \
15+
--copyright-holder "Buf Technologies, Inc." \
16+
--year-range "2023-2025"
17+
PROTOVALIDATE_VERSION ?= v0.14.0
18+
19+
.PHONY: help
20+
help: ## Describe useful make targets
21+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "%-15s %s\n", $$1, $$2}'
22+
23+
.PHONY: all
24+
all: build
25+
26+
.PHONY: generate
27+
generate: $(BIN)/buf $(BIN)/license-header ## Regenerate protobuf gencode for the bufbuild-protovalidate-protocolbuffers pypi package
28+
rm -rf buf/validate/proto5
29+
rm -rf buf/validate/proto6
30+
# generate gencode for both proto5 and proto6 for buf.build/bufbuild/protovalidate
31+
$(BIN)/buf generate buf.build/bufbuild/protovalidate:$(PROTOVALIDATE_VERSION)
32+
33+
# add license headers to the source files
34+
$(ADD_LICENSE_HEADER)
35+
36+
# set the version of bufbuild-protovalidate-protocolbuffers to the used PROTOVALIDATE_VERSION
37+
uv version $(PROTOVALIDATE_VERSION)
38+
39+
build: generate
40+
uv build
41+
42+
$(BIN):
43+
@mkdir -p $(BIN)
44+
45+
$(BIN)/buf: $(BIN) Makefile
46+
go install github.com/bufbuild/buf/cmd/buf@latest
47+
48+
$(BIN)/license-header: $(BIN) Makefile
49+
go install github.com/bufbuild/buf/private/pkg/licenseheader/cmd/license-header@latest

bufbuild-protovalidate-protocolbuffers/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "bufbuild-protovalidate-protocolbuffers"
3-
version = "v0.14.0"
3+
version = "0.14.0"
44
description = "Messages, enum types and stubs for buf.build/bufbuild/protovalidate for python."
55
readme = "README.md"
66
license = "Apache-2.0"

pyproject_old.toml

Lines changed: 0 additions & 126 deletions
This file was deleted.

0 commit comments

Comments
 (0)