@@ -42,67 +42,69 @@ build: $(FILES)
4242# need atdpy >= 2.12.0 for semgrep_metric.py
4343# need atdpy >= 2.11.0 to support parametrized types
4444% .py : % .atd
45- atdpy $<
45+ opam exec -- atdpy $<
4646
4747# -j-defaults is for producing '"field" = []' instead of omitting the field
4848# if it's defined as '~field: item list'.
4949# This allows us to produce the same JSON output with pysemgrep and osemgrep
5050# since atdpy keeps it simple and will always output '"field" = []'.
5151% _j.ml % _j.mli : % .atd
52- atdgen -j -j-std -j-defaults $<
52+ opam exec -- atdgen -j -j-std -j-defaults $<
5353
5454% _t.ml % _t.mli : % .atd
55- atdgen -t $<
55+ opam exec -- atdgen -t $<
5656
5757# need atdts >= 2.13.0
5858% .ts : % .atd
59- atdts $<
59+ opam exec -- atdts $<
6060
6161# need atdcat >= 2.6.0
6262semgrep_output_$(VER ) .jsonschema : semgrep_output_$(VER ) .atd
63- atdcat -jsonschema cli_output $< > $@
63+ opam exec -- atdcat -jsonschema cli_output $< > $@
6464
6565semgrep_output_$(VER ) .proto : semgrep_output_$(VER ) .jsonschema
6666 scripts/jsonschema2protobuf.py $< semgrep_output_$(VER ) > $@
6767
6868# The call to ocamlc is just to typecheck the generated OCaml files
6969Language.ml Language.mli lang.json : generate.py
70- mypy generate
70+ uvx mypy generate
7171 ./generate
72- ocamlc -o Language Language.mli Language.ml
72+ opam exec -- ocamlc -o Language Language.mli Language.ml
7373
7474.PHONY : clean
7575clean :
7676 rm -f $(FILES ) Language
7777
78+ .PHONY : dev-setup
79+ dev-setup :
80+ opam switch create semgrep-interfaces-dev 5.3.0
81+ $(MAKE ) setup
82+
7883# This takes a while but ensures we use the correct versions of the atd tools.
7984.PHONY : setup
8085setup :
81- opam update -y
8286 opam install -y --deps-only ./semgrep-interfaces.opam
83- # Please install check-jsonschema (Python tool) if this fails:
84- check-jsonschema --version
85-
86- .PHONY : setup-PYTHON
87- setup-PYTHON :
88- pip install check-jsonschema
89- pip install mypy
87+ jq --version > /dev/null || (echo " jq is required to run the tests" && exit 1)
88+
89+ .PHONY : test-backwards-compatibility
90+ test-backwards-compatibility :
91+ opam exec -- ./scripts/check-backwards-compatibility
92+
93+ .PHONY : test-schema-validation
94+ test-schema-validation :
95+ uv run ./scripts/validate.py rule_schema_v1.yaml tests/jsonschema/rules
96+
97+ # putting these files in their own dir is a workaround so we don't have to
98+ # delete __init__.py. running mypy normally doesn't work since the folder name
99+ # has a - in it which isn't allowed
100+ # TODO? rename the repo to semgrep_interfaces to avoid this hack?
101+ .PHONY : typecheck
102+ typecheck :
103+ mkdir -p typecheck
104+ ln -s ../semgrep_output_v1.py typecheck/semgrep_output_v1.py
105+ ln -s ../semgrep_metrics.py typecheck/semgrep_metrics.py
106+ uvx mypy@1.19.1 -p typecheck
90107
91108# The tests require semgrep-core, among other things.
92109.PHONY : test
93- test :
94- $(MAKE ) -C tests
95-
96- # ##############################################################################
97- # Pad's targets
98- # ##############################################################################
99-
100- pr :
101- git push origin ` git rev-parse --abbrev-ref HEAD`
102- hub pull-request -b main -r returntocorp/pa
103-
104- push :
105- git push origin ` git rev-parse --abbrev-ref HEAD`
106-
107- merge :
108- A=` git rev-parse --abbrev-ref HEAD` && git checkout main && git pull && git branch -D $$ A
110+ test : test-backwards-compatibility test-schema-validation typecheck
0 commit comments