-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
111 lines (91 loc) · 2.99 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
# Run 'make setup' to install the correct versions of the dependencies.
# Run 'make' to regenerate all files.
#
# You must run 'make' after editing an atd file. This will update
# other files that we keep under version control. Naturally, don't edit
# generated files by hand.
VER=v1
# Those files are in lowercase because atdpy/atdts seems to
# generate lowercase files, even though the input is capitalized
FILES= \
semgrep_output_$(VER)_j.ml \
semgrep_output_$(VER)_j.mli \
semgrep_output_$(VER).py \
semgrep_output_$(VER).ts \
semgrep_output_$(VER).jsonschema \
semgrep_output_$(VER).proto \
ast_generic_$(VER)_j.ml \
ast_generic_$(VER)_j.mli \
Language.ml \
Language.mli \
lang.json \
semgrep_metrics.py
# Regenerate all files.
#
# If someone accidentally touches a generated file, the lazy file regeneration
# based on timestamps won't happen. This is really only a problem because
# we keep the generated files, with their timestamp, in git.
# To avoid such issues, force-build is now the default target.
#
.PHONY: force-build
force-build:
$(MAKE) clean
$(MAKE) build
.PHONY: build
build: $(FILES)
# need atdpy >= 2.11.0 to support parametrized types
# need atdpy >= 2.12.0 for semgrep_metric.py
%.py: %.atd
atdpy $<
# -j-defaults is for producing '"field" = []' instead of omitting the field
# if it's defined as '~field: item list'.
# This allows us to produce the same JSON output with pysemgrep and osemgrep
# since atdpy keeps it simple and will always output '"field" = []'.
%_j.ml %_j.mli: %.atd
atdgen -j -j-std -j-defaults $<
# need atdts >= 2.13.0
%.ts: %.atd
atdts $<
# need atdcat >= 2.6.0
semgrep_output_$(VER).jsonschema: semgrep_output_$(VER).atd
atdcat -jsonschema cli_output $< > $@
semgrep_output_$(VER).proto: semgrep_output_$(VER).jsonschema
scripts/jsonschema2protobuf.py $< semgrep_output_$(VER) > $@
# The call to ocamlc is just to typecheck the generated OCaml files
Language.ml Language.mli lang.json: generate.py
mypy generate
./generate
ocamlc -o Language Language.mli Language.ml
.PHONY: clean
clean:
rm -f $(FILES) Language
# This takes a while but ensures we use the correct versions of the atd tools.
.PHONY: setup
setup:
# Please install check-jsonschema (Python tool) if this fails:
check-jsonschema --version
opam update -y
opam install -y --deps-only ./dev.opam
.PHONY: setup-ALPINE
setup-ALPINE: setup-PYTHON
.PHONY: setup-MACOS
setup-MACOS:
brew install check-jsonschema
.PHONY: setup-PYTHON
setup-PYTHON:
pip install check-jsonschema
# The tests require semgrep-core, among other things.
#
.PHONY: test
test:
$(MAKE) -C tests
###############################################################################
# Pad's targets
###############################################################################
pr:
git push origin `git rev-parse --abbrev-ref HEAD`
hub pull-request -b main -r returntocorp/pa
push:
git push origin `git rev-parse --abbrev-ref HEAD`
merge:
A=`git rev-parse --abbrev-ref HEAD` && git checkout main && git pull && git branch -D $$A