Skip to content

Commit e9ffee5

Browse files
New Code Generation (#16)
* Rework code generation for Ruby * Rework code generation for Javascript * Rework code generation for Java * Rework code generation for Go * Rework code generation for Perl The part regarding the README which was copied from the parent folder will be managed later. It is part of the TODO list here: cucumber/common#2029 * Add some requirements checks in java makefile * Rework code generation for PHP * Rework root Makefile * Add validation of schemas into root makefile * Add a workflow to check there is no need to generate code * Fix workflow * Fix set up of node in test-codegen workflow * Add missing checkout step into test-codegen workflow * Fix 'composer install' instruction in test-codegen workflow * Update messages.md to test the test-codegen workflow * Run clean-all before generate-all in test-codegen workflow * Fix messages.md to fix the test-codegen workflow
1 parent b3d02e6 commit e9ffee5

File tree

2 files changed

+15
-78
lines changed

2 files changed

+15
-78
lines changed

Makefile

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
include default.mk
1+
schemas = $(shell find ../jsonschema -name "*.json")
22

3-
JSONSCHEMAS = $(shell find ../jsonschema -name "*.json")
3+
.DEFAULT_GOAL = help
44

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)
67

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
89

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)
1016

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/*
1620

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
1822
ruby ../jsonschema/scripts/codegen.rb Php ../jsonschema php.php.erb > build/messages.php
1923
ruby ../jsonschema/scripts/codegen.rb Php ../jsonschema php.enum.php.erb >> build/messages.php
2024
csplit --quiet --prefix=build/Generated --suffix-format=%02d.php.tmp --elide-empty-files build/messages.php /^.*[.]php$$/ {*}
2125
rm -rf src-generated/*
2226
for file in build/Generated**; do mkdir -p src-generated/$$(head -n 1 $$file | sed 's/[^/]*.php$$//'); done
2327
for file in build/Generated**; do tail -n +2 $$file > src-generated/$$(head -n 1 $$file); rm $$file; done
2428
vendor/bin/php-cs-fixer --diff fix src-generated
25-
26-
clean-build:
27-
rm -rf build/messages.php
28-
rm -rf src-generated/*

default.mk

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

0 commit comments

Comments
 (0)