[script] Now top-level makefile a command 'format-py' to apply python formatting

This commit is contained in:
tangxifan 2022-11-21 14:20:45 -08:00
parent 62d387b12a
commit 14361159d5
1 changed files with 8 additions and 0 deletions

View File

@ -43,6 +43,7 @@ endif
PYTHON_EXEC ?= python3 PYTHON_EXEC ?= python3
CLANG_FORMAT_EXEC ?= clang-format-10 CLANG_FORMAT_EXEC ?= clang-format-10
XML_FORMAT_EXEC ?= xmllint XML_FORMAT_EXEC ?= xmllint
PYTHON_FORMAT_EXEC ?= black
# Put it first so that "make" without argument is like "make help". # Put it first so that "make" without argument is like "make help".
export COMMENT_EXTRACT export COMMENT_EXTRACT
@ -83,6 +84,13 @@ format-xml:
XMLLINT_INDENT=" " && ${XML_FORMAT_EXEC} --format $${f} --output $${f} || exit 1; \ XMLLINT_INDENT=" " && ${XML_FORMAT_EXEC} --format $${f} --output $${f} || exit 1; \
done done
format-py:
# Format all the python scripts under this project, excluding submodules
for f in `find openfpga_flow/scripts -iname *.py`; \
do \
${PYTHON_FORMAT_EXEC} $${f} --line-length 100 || exit 1; \
done
clean: clean:
# Remove current build results # Remove current build results
rm -rf ${BUILD_DIR} yosys/install rm -rf ${BUILD_DIR} yosys/install