forked from cucumber/gherkin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
112 lines (83 loc) · 3.88 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
SHELL := /usr/bin/env bash
SUB_DIR = gherkin/cucumber/gherkin
GRAMMAR_GENERATED = \
include/$(SUB_DIR)/rule_type.hpp \
include/$(SUB_DIR)/parser.hpp
LANGUAGE_GENERATED = \
src/lib/$(SUB_DIR)/dialect.cpp
ALL_GENERATED := $(GRAMMAR_GENERATED) $(LANGUAGE_GENERATED)
ALL_SOURCE_FILES = $(shell find include src -name "*.[ch]*")
SOURCE_FILES := $(filter-out $(ALL_GENERATED),$(ALL_SOURCE_FILES))
HERE = $(shell pwd)
CMAKE_BUILDROOT = $(HERE)/build/root
CMAKELISTS = $(shell find src -name CMakeLists.txt)
GHERKIN = stage/bin/gherkin
GHERKIN_GENERATE_TOKENS = stage/bin/gherkin-generate-tokens
GOOD_FEATURE_FILES = $(shell find ../testdata/good -name "*.feature")
BAD_FEATURE_FILES = $(shell find ../testdata/bad -name "*.feature")
TOKENS = $(patsubst ../testdata/%,acceptance/testdata/%.tokens,$(GOOD_FEATURE_FILES))
ASTS = $(patsubst ../testdata/%,acceptance/testdata/%.ast.ndjson,$(GOOD_FEATURE_FILES))
PICKLES = $(patsubst ../testdata/%,acceptance/testdata/%.pickles.ndjson,$(GOOD_FEATURE_FILES))
SOURCES = $(patsubst ../testdata/%,acceptance/testdata/%.source.ndjson,$(GOOD_FEATURE_FILES))
ERRORS = $(patsubst ../testdata/%,acceptance/testdata/%.errors.ndjson,$(BAD_FEATURE_FILES))
.DEFAULT_GOAL = help
# Dummy 1
help: ## Show this help
@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)
generate: $(GRAMMAR_GENERATED) ## Generate gherkin parser files
generate-all: $(ALL_GENERATED)
clean-generate: ## Remove generated Gherkin parser files ## Generate gherkin parser files
rm -f $(GRAMMAR_GENERATED)
copy-gherkin-languages:
echo "Nothing to do"
clean-gherkin-languages: ## Remove gherkin-languages.json and any derived files
echo "Nothing to do"
clean: clean-deps ## Remove all build artifacts and files generated by the acceptance tests
rm -rf .built .configured
rm -rf acceptance
rm -rf build
.DELETE_ON_ERROR:
acceptance: .built $(TOKENS) $(ASTS) $(PICKLES) $(ERRORS) $(SOURCES) ## Build acceptance test dir and compare results with reference
.built: $(SOURCE_FILES)
./cmake/cmate install
./cmake/cmate build
./cmake/cmate stage
touch $@
define berp-generate-parser =
berp -g ../gherkin.berp -t $< -o $@ --noBOM
endef
include/$(SUB_DIR)/rule_type.hpp: gherkin-cpp-rule-type.razor ../gherkin.berp
$(berp-generate-parser)
include/$(SUB_DIR)/parser.hpp: gherkin-cpp-parser.razor ../gherkin.berp
$(berp-generate-parser)
src/lib/$(SUB_DIR)/dialect.cpp: ../gherkin-languages.json dialect.cpp.jq
jq -f dialect.cpp.jq -r -c < $< > $@
acceptance/testdata/%.tokens: ../testdata/% ../testdata/%.tokens
mkdir -p $(@D)
$(GHERKIN_GENERATE_TOKENS) $< > $@
diff --unified $<.tokens $@
acceptance/testdata/%.ast.ndjson: ../testdata/% ../testdata/%.ast.ndjson
mkdir -p $(@D)
$(GHERKIN) --no-source --no-pickles --predictable-ids $< | jq --sort-keys --compact-output "." > $@
diff --unified <(jq "." $<.ast.ndjson) <(jq "." $@)
acceptance/testdata/%.pickles.ndjson: ../testdata/% ../testdata/%.pickles.ndjson
mkdir -p $(@D)
$(GHERKIN) --no-source --no-ast --predictable-ids $< | jq --sort-keys --compact-output "." > $@
diff --unified <(jq "." $<.pickles.ndjson) <(jq "." $@)
acceptance/testdata/%.source.ndjson: ../testdata/% ../testdata/%.source.ndjson
mkdir -p $(@D)
$(GHERKIN) --no-ast --no-pickles --predictable-ids $< | jq --sort-keys --compact-output "." > $@
diff --unified <(jq "." $<.source.ndjson) <(jq "." $@)
acceptance/testdata/%.errors.ndjson: ../testdata/% ../testdata/%.errors.ndjson
mkdir -p $(@D)
$(GHERKIN) --no-source --predictable-ids $< | jq --sort-keys --compact-output "." > $@
diff --unified <(jq "." $<.errors.ndjson) <(jq "." $@)
#
# External dependencies
#
install-deps:
./cmake/cmate install
.PHONY: install-deps
clean-deps:
./cmake/cmate clean --purge
.PHONY: clean-deps