Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
89 lines (75 loc) · 2.56 KB
/
Copy pathMakefile
File metadata and controls
89 lines (75 loc) · 2.56 KB
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
# SPDX-Copyright: Copyright (c) Capital One Services, LLC
# SPDX-License-Identifier: Apache-2.0
# Copyright 2020 Capital One Services, LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and limitations under the License.
# Builds feature files from cel-spec textproto definitions.
# Either have https://github.com/google/cel-spec checked out adjacent to cel-python
# OR set CEL_SPEC_PATH to be location of the cel-spec project.
HERE := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
TOOLS = $(HERE)../tools
CEL_SPEC_PATH ?= $(HERE)../../cel-spec
CEL_SIMPLE_TESTDATA ?= $(CEL_SPEC_PATH)/tests/simple/testdata
# This is most -- but not all -- the feature files.
# Some are built manually. These are built from textproto files.
FEATURES = \
basic.feature \
comparisons.feature \
conversions.feature \
dynamic.feature \
enums.feature \
fields.feature \
fp_math.feature \
integer_math.feature \
lists.feature \
logic.feature \
macros.feature \
namespace.feature \
parse.feature \
plumbing.feature \
proto2.feature \
proto3.feature \
string.feature \
timestamps.feature \
unknowns.feature
SOURCES := $(patsubst %.feature,%.textproto,$(FEATURES))
.PRECIOUS: %.textproto
.DELETE_ON_ERROR:
all : $(FEATURES)
# Copy the textproto from the cel-spec directory to keep our reference copy.
%.textproto : $(CEL_SIMPLE_TESTDATA)/%.textproto
cp $(CEL_SIMPLE_TESTDATA)/$@ $@
# Create Gherkin from the textproto serialization.
%.feature : %.textproto
python $(TOOLS)/pb2g.py $^ -o $@
# Run the lark scanner to be sure the grammar works for *all* of the textproto files.
# This is necessary because we don't have a full textproto implementation.
scan : $(SOURCES)
@python $(TOOLS)/pb2g.py
@for name in $(SOURCES); do \
python $(TOOLS)/pb2g.py $$name >/dev/null; \
done
@echo "\nAll files scanned successfully"
# When the grammar was incomplete, we sometimes had empty .feature files.
# It helps to remove them before rerunning.
clean-broken:
@for name in $(FEATURES); do \
if [ -f $$name -a ! -s $$name ]; then \
echo empty $$name; \
rm $$name; \
fi; \
done
clean-features:
rm $(FEATURES)
clean:
rm $(FEATURES)
rm $(SOURCES)