-
-
Notifications
You must be signed in to change notification settings - Fork 67
/
Makefile
74 lines (55 loc) · 2.38 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
SHELL := /usr/bin/env bash
ALPINE := $(shell which apk 2> /dev/null)
GOOD_FEATURE_FILES = $(shell find ../testdata/good -name "*.feature")
BAD_FEATURE_FILES = $(shell find ../testdata/bad -name "*.feature")
TOKENS = $(patsubst ../testdata/%.feature,acceptance/testdata/%.feature.tokens,$(GOOD_FEATURE_FILES))
ASTS = $(patsubst ../testdata/%.feature,acceptance/testdata/%.feature.ast.ndjson,$(GOOD_FEATURE_FILES))
ERRORS = $(patsubst ../testdata/%.feature,acceptance/testdata/%.feature.errors.ndjson,$(BAD_FEATURE_FILES))
M_FILES = $(shell find . -type f \( -iname "*.m" \))
ifdef ALPINE
DEFAULT_TARGET=skip_build
else
DEFAULT_TARGET=.compared
endif
.DELETE_ON_ERROR:
default: $(DEFAULT_TARGET)
.PHONY: default
skip_build:
@echo -e "\x1b[31;01mSKIPPING GHERKIN OBJECTIVE-C BUILD ON ALPINE\x1b[0m"
.PHONY: skip_build
.compared: .built $(TOKENS)
#.compared: .built $(TOKENS) $(ASTS) $(ERRORS)
touch $@
.built: build/AstGenerator build/TokensGenerator LICENSE
touch $@
acceptance/testdata/%.feature.tokens: ../testdata/%.feature ../testdata/%.feature.tokens .built
mkdir -p $(@D)
bin/gherkin-generate-tokens $< > $@
diff --unified $<.tokens $@
acceptance/testdata/%.feature.ast.ndjson: ../testdata/%.feature ../testdata/%.feature.ast.ndjson .built
mkdir -p $(@D)
bin/gherkin-generate-ast $< | jq --sort-keys "." > $@
diff --unified <(jq "." $<.ast.ndjson) <(jq "." $@)
acceptance/testdata/%.feature.errors.ndjson: ../testdata/%.feature ../testdata/%.feature.errors.ndjson .built
mkdir -p $(@D)
bin/gherkin $< | jq --sort-keys --compact-output "." > $@
diff --unified <(jq "." $<.errors.ndjson) <(jq "." $@)
clean:
rm -rf .compared .built acceptance
rm -rf build/
rm -rf *~
.PHONY: clean
clobber: clean
rm -rf Gherkin/GHParser.m Gherkin/GHParser.h
.PHONY: clobber
define berp-generate-parser =
berp -g ../gherkin.berp -t $< -o $@ --noBOM
endef
Gherkin/GHParser.h: gherkin-objective-c-header.razor ../gherkin.berp
$(berp-generate-parser)
Gherkin/GHParser.m: gherkin-objective-c-implementation.razor ../gherkin.berp
$(berp-generate-parser)
build/AstGenerator: Gherkin/GHParser.h Gherkin/GHParser.m $(M_FILES) GherkinLanguages/gherkin-languages.json
xcodebuild -scheme "AstGenerator" CONFIGURATION_BUILD_DIR=build/
build/TokensGenerator: Gherkin/GHParser.h Gherkin/GHParser.m $(M_FILES) GherkinLanguages/gherkin-languages.json
xcodebuild -scheme "TokensGenerator" CONFIGURATION_BUILD_DIR=build/