|
1 |
| -include default.mk |
| 1 | +schemas = $(shell find ../jsonschema -name "*.json") |
2 | 2 |
|
3 |
| -JSONSCHEMAS = $(shell find ../jsonschema -name "*.json") |
| 3 | +.DEFAULT_GOAL = help |
4 | 4 |
|
5 |
| -clean: clean-build |
| 5 | +help: ## Show this help |
| 6 | + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make <target>\n\nWhere <target> is one of:\n"} /^[$$()% a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) |
6 | 7 |
|
7 |
| -.codegen: $(JSONSCHEMAS) ../jsonschema/scripts/codegen.rb ../jsonschema/scripts/templates/php.php.erb build/messages.php |
| 8 | +generate: require build/messages.php ## Generate php code based on the schemas found in ../jsonschema and using the scripts in ../jsonschema/scripts for the generation |
8 | 9 |
|
9 |
| -post-release: update-gherkin-dependency |
| 10 | +require: ## Check requirements for the code generation (ruby, php, csplit, tail and php-cs-fixer are required) |
| 11 | + @ruby --version >/dev/null 2>&1 || (echo "ERROR: ruby is required."; exit 1) |
| 12 | + @php --version >/dev/null 2>&1 || (echo "ERROR: php is required."; exit 1) |
| 13 | + @csplit --version >/dev/null 2>&1 || (echo "ERROR: csplit is required."; exit 1) |
| 14 | + @tail --version >/dev/null 2>&1 || (echo "ERROR: tail is required."; exit 1) |
| 15 | + @vendor/bin/php-cs-fixer --version >/dev/null 2>&1 || (echo "ERROR: vendor/bin/php-cs-fixer is required ('composer install' should install it)."; exit 1) |
10 | 16 |
|
11 |
| -update-gherkin-dependency: |
12 |
| - php scripts/update-gherkin-dependency.php ../../gherkin/php/composer.json > gherkin-composer.json |
13 |
| - jq --indent 4 < gherkin-composer.json > ../../gherkin/php/composer.json |
14 |
| - rm gherkin-composer.json |
15 |
| -.PHONY: update-gherkin-dependency |
| 17 | +clean: ## Remove automatically generated files and related artifacts |
| 18 | + rm -rf build/messages.php |
| 19 | + rm -rf src-generated/* |
16 | 20 |
|
17 |
| -build/messages.php: |
| 21 | +build/messages.php: $(schemas) ../jsonschema/scripts/codegen.rb ../jsonschema/scripts/templates/php.php.erb ../jsonschema/scripts/templates/php.enum.php.erb |
18 | 22 | ruby ../jsonschema/scripts/codegen.rb Php ../jsonschema php.php.erb > build/messages.php
|
19 | 23 | ruby ../jsonschema/scripts/codegen.rb Php ../jsonschema php.enum.php.erb >> build/messages.php
|
20 | 24 | csplit --quiet --prefix=build/Generated --suffix-format=%02d.php.tmp --elide-empty-files build/messages.php /^.*[.]php$$/ {*}
|
21 | 25 | rm -rf src-generated/*
|
22 | 26 | for file in build/Generated**; do mkdir -p src-generated/$$(head -n 1 $$file | sed 's/[^/]*.php$$//'); done
|
23 | 27 | for file in build/Generated**; do tail -n +2 $$file > src-generated/$$(head -n 1 $$file); rm $$file; done
|
24 | 28 | vendor/bin/php-cs-fixer --diff fix src-generated
|
25 |
| - |
26 |
| -clean-build: |
27 |
| - rm -rf build/messages.php |
28 |
| - rm -rf src-generated/* |
0 commit comments