Skip to content
Snippets Groups Projects
Commit 4824cad5 authored by Campbell Barton's avatar Campbell Barton
Browse files

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
parent 74dfb7ca
No related branches found
No related tags found
No related merge requests found
...@@ -120,7 +120,7 @@ Utilities ...@@ -120,7 +120,7 @@ Utilities
Updates git and all submodules but not svn. Updates git and all submodules but not svn.
* format: * 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" make format PATHS="source/blender/blenlib source/blender/blenkernel"
...@@ -130,6 +130,7 @@ Environment Variables ...@@ -130,6 +130,7 @@ Environment Variables
* BUILD_DIR: Override default build path. * BUILD_DIR: Override default build path.
* PYTHON: Use this for the Python command (used for checking tools). * PYTHON: Use this for the Python command (used for checking tools).
* NPROCS: Number of processes to use building (auto-detect when omitted). * 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 Documentation Targets
Not associated with building Blender. Not associated with building Blender.
...@@ -206,6 +207,27 @@ ifeq ($(OS_NCASE),darwin) ...@@ -206,6 +207,27 @@ ifeq ($(OS_NCASE),darwin)
endif endif
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 # additional targets for the build configuration
...@@ -527,8 +549,8 @@ update_code: .FORCE ...@@ -527,8 +549,8 @@ update_code: .FORCE
@$(PYTHON) ./build_files/utils/make_update.py --no-libraries @$(PYTHON) ./build_files/utils/make_update.py --no-libraries
format: .FORCE format: .FORCE
@PATH="../lib/${OS_NCASE}_${CPU}/llvm/bin/:../lib/${OS_NCASE}_centos7_${CPU}/llvm/bin/:../lib/${OS_NCASE}/llvm/bin/:$(PATH)" \ @PATH="${LIBDIR}/llvm/bin/:$(PATH)" $(PYTHON) source/tools/utils_maintenance/clang_format_paths.py $(PATHS)
$(PYTHON) source/tools/utils_maintenance/clang_format_paths.py $(PATHS) @$(PYTHON) source/tools/utils_maintenance/autopep8_format_paths.py --autopep8-command="$(AUTOPEP8)" $(PATHS)
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment