mirror of
https://projects.blender.org/blender/blender.git
synced 2025-01-22 07:22:12 -05:00
GNUmakefile: include autopep8 in the "make format" target
Run autopep8 as well as clang-format when calling "make format", the PATHS argument is passed to both utilities which will only operate on files they support. For example: `make format PATHS=release/scripts` formats Python scripts, `make format PATHS=source/blender/blenlib` would format C/C++. If users really want they can format C/C++ & Python files at the same time since both formatting utilities filter on file extension. `make format PATHS="release/scripts/startup/nodeitems_builtins.py source/creator/creator.c"` A LIBDIR variable has been added to the GNUmakefile to simplify references to this directory which can be one of 3 possible values. Reviewed By: sybren, brecht Ref D14789
This commit is contained in:
parent
74dfb7ca23
commit
4824cad580
1 changed files with 25 additions and 3 deletions
28
GNUmakefile
28
GNUmakefile
|
@ -120,7 +120,7 @@ Utilities
|
|||
Updates git and all submodules but not svn.
|
||||
|
||||
* format:
|
||||
Format source code using clang (uses PATHS if passed in). For example::
|
||||
Format source code using clang-format & autopep8 (uses PATHS if passed in). For example::
|
||||
|
||||
make format PATHS="source/blender/blenlib source/blender/blenkernel"
|
||||
|
||||
|
@ -130,6 +130,7 @@ Environment Variables
|
|||
* BUILD_DIR: Override default build path.
|
||||
* PYTHON: Use this for the Python command (used for checking tools).
|
||||
* NPROCS: Number of processes to use building (auto-detect when omitted).
|
||||
* AUTOPEP8: Command used for Python code-formatting (used for the format target).
|
||||
|
||||
Documentation Targets
|
||||
Not associated with building Blender.
|
||||
|
@ -206,6 +207,27 @@ ifeq ($(OS_NCASE),darwin)
|
|||
endif
|
||||
endif
|
||||
|
||||
# Set the LIBDIR, an empty string when not found.
|
||||
LIBDIR:=$(wildcard ../lib/${OS_NCASE}_${CPU})
|
||||
ifeq (, $(LIBDIR))
|
||||
LIBDIR:=$(wildcard ../lib/${OS_NCASE}_centos7_${CPU})
|
||||
endif
|
||||
ifeq (, $(LIBDIR))
|
||||
LIBDIR:=$(wildcard ../lib/${OS_NCASE})
|
||||
endif
|
||||
|
||||
# Use the autopep8 module in ../lib/ (which can be executed via Python directly).
|
||||
# Otherwise the "autopep8" command can be used.
|
||||
ifndef AUTOPEP8
|
||||
ifneq (, $(LIBDIR))
|
||||
AUTOPEP8:=$(wildcard $(LIBDIR)/python/lib/python3.10/site-packages/autopep8.py)
|
||||
endif
|
||||
ifeq (, $(AUTOPEP8))
|
||||
AUTOPEP8:=autopep8
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# additional targets for the build configuration
|
||||
|
||||
|
@ -527,8 +549,8 @@ update_code: .FORCE
|
|||
@$(PYTHON) ./build_files/utils/make_update.py --no-libraries
|
||||
|
||||
format: .FORCE
|
||||
@PATH="../lib/${OS_NCASE}_${CPU}/llvm/bin/:../lib/${OS_NCASE}_centos7_${CPU}/llvm/bin/:../lib/${OS_NCASE}/llvm/bin/:$(PATH)" \
|
||||
$(PYTHON) source/tools/utils_maintenance/clang_format_paths.py $(PATHS)
|
||||
@PATH="${LIBDIR}/llvm/bin/:$(PATH)" $(PYTHON) source/tools/utils_maintenance/clang_format_paths.py $(PATHS)
|
||||
@$(PYTHON) source/tools/utils_maintenance/autopep8_format_paths.py --autopep8-command="$(AUTOPEP8)" $(PATHS)
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in a new issue