|
| 1 | +# libre-graph-api local build entry points. |
| 2 | +# |
| 3 | +# `make` (or `make spec`) compiles the TypeSpec sources under spec/ into |
| 4 | +# api/openapi-spec/v1.0.yaml. Per-language client generation targets pull the |
| 5 | +# matching openapi-generator-cli image straight out of the woodpecker pipeline |
| 6 | +# file for that language, so renovatebot remains the single source of truth |
| 7 | +# for the generator version. |
| 8 | + |
| 9 | +SPEC := api/openapi-spec/v1.0.yaml |
| 10 | +SPEC_SOURCES := $(wildcard spec/*.tsp) spec/tspconfig.yaml spec/package.json spec/package-lock.json |
| 11 | +NODE_IMAGE := node:22-alpine |
| 12 | + |
| 13 | +# Extract `openapitools/openapi-generator-cli:<tag>@sha256:<digest>` from the |
| 14 | +# .woodpecker pipeline file for the given language. |
| 15 | +# $(call generator_image,go) |
| 16 | +# $(call generator_image,typescript-axios) |
| 17 | +generator_image = $(shell grep -oE "openapitools/openapi-generator-cli:[A-Za-z0-9._@:-]+" .woodpecker/build-$(1).yaml | head -n1) |
| 18 | + |
| 19 | +DOCKER_RUN = docker run --rm \ |
| 20 | + --user $(shell id -u):$(shell id -g) \ |
| 21 | + -v "$(CURDIR):/work" \ |
| 22 | + -w /work |
| 23 | + |
| 24 | +.PHONY: all spec go typescript-axios php cpp-qt-client clean help |
| 25 | + |
| 26 | +all: spec |
| 27 | + |
| 28 | +help: ## Show this help |
| 29 | + @echo "Common commands:" |
| 30 | + @echo "" |
| 31 | + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' |
| 32 | + |
| 33 | +spec: $(SPEC) ## Compile TypeSpec sources into api/openapi-spec/v1.0.yaml |
| 34 | + |
| 35 | +$(SPEC): $(SPEC_SOURCES) |
| 36 | + $(DOCKER_RUN) -e HOME=/tmp -e npm_config_cache=/tmp/.npm $(NODE_IMAGE) sh scripts/compile-spec.sh |
| 37 | + |
| 38 | +go: $(SPEC) ## Generate the Go client into build/clients/go |
| 39 | + $(DOCKER_RUN) -e OUTPUT_DIR=build/clients/go $(call generator_image,go) sh scripts/generate-go.sh |
| 40 | + |
| 41 | +typescript-axios: $(SPEC) ## Generate the TypeScript-Axios client into build/clients/typescript-axios |
| 42 | + $(DOCKER_RUN) -e OUTPUT_DIR=build/clients/typescript-axios $(call generator_image,typescript-axios) sh scripts/generate-typescript-axios.sh |
| 43 | + |
| 44 | +php: $(SPEC) ## Generate the PHP client into build/clients/php |
| 45 | + $(DOCKER_RUN) -e OUTPUT_DIR=build/clients/php $(call generator_image,php) sh scripts/generate-php.sh |
| 46 | + |
| 47 | +cpp-qt-client: $(SPEC) ## Generate the C++/Qt client into build/clients/cpp-qt-client |
| 48 | + $(DOCKER_RUN) -e OUTPUT_DIR=build/clients/cpp-qt-client $(call generator_image,cpp-qt) sh scripts/generate-cpp-qt-client.sh |
| 49 | + |
| 50 | +clean: ## Remove build artefacts and the generated spec |
| 51 | + rm -rf build/ spec/build/ $(SPEC) |
0 commit comments