2020-04-22 19:29:27 -03:00
|
|
|
UNAME_S := $(shell uname -s)
|
|
|
|
ifeq ($(UNAME_S),Linux)
|
|
|
|
PYTHON ?= ../../python
|
|
|
|
endif
|
|
|
|
ifeq ($(UNAME_S),Darwin)
|
|
|
|
PYTHON ?= ../../python.exe
|
|
|
|
endif
|
2020-05-18 15:27:40 -03:00
|
|
|
VENVDIR ?= ./venv
|
|
|
|
VENVPYTHON ?= $(VENVDIR)/bin/python
|
2020-04-22 19:29:27 -03:00
|
|
|
CPYTHON ?= ../../Lib
|
2023-06-01 12:24:15 -03:00
|
|
|
MYPY ?= ./venv/bin/mypy
|
|
|
|
BLACK ?= ./venv/bin/black
|
2020-04-22 19:29:27 -03:00
|
|
|
|
|
|
|
GRAMMAR = ../../Grammar/python.gram
|
2020-04-28 09:11:55 -03:00
|
|
|
TOKENS = ../../Grammar/Tokens
|
2020-04-22 19:29:27 -03:00
|
|
|
|
|
|
|
build: peg_extension/parse.c
|
|
|
|
|
2021-11-20 21:08:50 -04:00
|
|
|
peg_extension/parse.c: $(GRAMMAR) $(TOKENS) pegen/*.py peg_extension/peg_extension.c ../../Parser/pegen.c ../../Parser/pegen_errors.c ../../Parser/string_parser.c ../../Parser/action_helpers.c ../../Parser/*.h pegen/grammar_parser.py
|
2023-06-01 12:24:15 -03:00
|
|
|
$(VENVPYTHON) -m pegen -q c $(GRAMMAR) $(TOKENS) -o peg_extension/parse.c --compile-extension
|
2020-04-22 19:29:27 -03:00
|
|
|
|
|
|
|
clean:
|
|
|
|
-rm -f peg_extension/*.o peg_extension/*.so peg_extension/parse.c
|
2020-05-18 15:27:40 -03:00
|
|
|
-rm -rf $(VENVDIR)
|
2020-04-22 19:29:27 -03:00
|
|
|
|
|
|
|
regen-metaparser: pegen/metagrammar.gram pegen/*.py
|
2023-06-01 12:24:15 -03:00
|
|
|
$(VENVPYTHON) -m pegen -q python pegen/metagrammar.gram -o pegen/grammar_parser.py
|
2020-04-22 19:29:27 -03:00
|
|
|
|
|
|
|
# Note: These targets really depend on the generated shared object in peg_extension/parse.*.so but
|
|
|
|
# this has different names in different systems so we are abusing the implicit dependency on
|
|
|
|
# parse.c by the use of --compile-extension.
|
|
|
|
|
2020-05-18 15:27:40 -03:00
|
|
|
venv:
|
|
|
|
$(PYTHON) -m venv $(VENVDIR)
|
2023-06-01 12:24:15 -03:00
|
|
|
$(VENVPYTHON) -m pip install -U pip setuptools black mypy
|
2020-05-18 15:27:40 -03:00
|
|
|
@echo "The venv has been created in the $(VENVDIR) directory"
|
|
|
|
|
2020-04-22 19:29:27 -03:00
|
|
|
mypy: regen-metaparser
|
|
|
|
$(MYPY) # For list of files, see mypy.ini
|
|
|
|
|
|
|
|
format-python:
|
2023-06-01 12:24:15 -03:00
|
|
|
$(BLACK) pegen
|
2020-04-22 19:29:27 -03:00
|
|
|
|
2023-06-01 12:24:15 -03:00
|
|
|
format: venv format-python
|
2020-04-22 19:29:27 -03:00
|
|
|
|
|
|
|
tags: TAGS
|
|
|
|
|
|
|
|
TAGS: pegen/*.py test/test_pegen.py
|
|
|
|
etags pegen/*.py test/test_pegen.py
|