Skip to content

Commit df3b7d4

Browse files
Separate makefile for protovalidate gencode
1 parent 4d5ddd6 commit df3b7d4

File tree

4 files changed

+54
-139
lines changed

4 files changed

+54
-139
lines changed

Makefile

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ ADD_LICENSE_HEADER := $(BIN)/license-header \
1717
--year-range "2023-2025"
1818
# This version should be kept in sync with the version in buf.yaml
1919
PROTOVALIDATE_VERSION ?= v1.0.0
20+
# This version should be kept in sync with the version in buf.yaml and the bufbuild-protovalidate-protocolbuffers version in uv.lock
21+
PROTOVALIDATE_TESTING_VERSION ?= v0.14.0
2022
# Version of the cel-spec that this implementation is conformant with
2123
CEL_SPEC_VERSION ?= v0.24.0
2224
TESTDATA_FILE := test/testdata/string_ext.textproto
@@ -34,14 +36,14 @@ clean: ## Delete intermediate build artifacts
3436
git clean -Xdf
3537

3638
.PHONY: generate
37-
generate: generate-protovalidate-pypi-package generate-protobuf-tests $(BIN)/license-header ## Regenerate code and license headers
39+
generate: generate-protobuf-tests $(BIN)/license-header ## Regenerate code and license headers
3840
$(ADD_LICENSE_HEADER)
3941

4042
.PHONY: generate-protobuf-tests
4143
generate-protobuf-tests: $(BIN)/buf ## Regenerate protobuf gencode used in unit tests
4244
rm -rf test/gen
4345
# generate protovalidate-testing into test/gen/buf/validate
44-
$(BIN)/buf generate buf.build/bufbuild/protovalidate-testing:$(PROTOVALIDATE_VERSION)
46+
$(BIN)/buf generate buf.build/bufbuild/protovalidate-testing:$(PROTOVALIDATE_TESTING_VERSION)
4547

4648
# generate cel-spec into test/gen/cel/expr
4749
$(BIN)/buf generate buf.build/google/cel-spec:$(CEL_SPEC_VERSION) --exclude-path cel/expr/conformance/proto2 --exclude-path cel/expr/conformance/proto3
@@ -51,16 +53,6 @@ generate-protobuf-tests: $(BIN)/buf ## Regenerate protobuf gencode used in unit
5153
# generate proto/tests/example/v1/validations.proto into test/gen/tests/example/v1
5254
$(BIN)/buf generate
5355

54-
.PHONY:
55-
generate-protovalidate-pypi-package: $(BIN)/buf ## Regenerate protobuf gencode for the bufbuild-protovalidate-protocolbuffers pypi package
56-
rm -rf bufbuild-protovalidate-protocolbuffers/buf/validate/proto5
57-
rm -rf bufbuild-protovalidate-protocolbuffers/buf/validate/proto6
58-
# generate gencode for both proto5 and proto6 for buf.build/bufbuild/protovalidate
59-
cd bufbuild-protovalidate-protocolbuffers && ../$(BIN)/buf generate buf.build/bufbuild/protovalidate:$(PROTOVALIDATE_VERSION)
60-
61-
# set the version of bufbuild-protovalidate-protocolbuffers to the used PROTOVALIDATE_VERSION
62-
sed -i .bak 's/^version = "[^"]*"/version = "$(PROTOVALIDATE_VERSION)"/' bufbuild-protovalidate-protocolbuffers/pyproject.toml && rm bufbuild-protovalidate-protocolbuffers/pyproject.toml.bak
63-
6456
.PHONY: format
6557
format: install $(BIN)/buf $(BIN)/license-header ## Format code
6658
$(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)