Commit Graph

46 Commits

Author SHA1 Message Date
Brecht Van Lommel
b802f146e6 Tools: Move warning about wrong clang-format version to the bottom
So it doesn't scroll off screen and is easy to miss.
2024-06-27 11:49:00 +02:00
Campbell Barton
7dfedf4e84 Tools: various fixes/corrections to the autopep8 formatter
When autopep8 is accessed as a Python module (using `--no-subprocess`),
which is now default on MS-Windows.

- Perform version checks on the module version instead of the command.
- Remove checks for the command existing in the PATH.
- Adjust errors to make sense for a Python module.
2024-06-26 10:08:03 +10:00
Ray Molenkamp
9f1f869e16 make.bat: Enable .py formatting with make format
autopep8_format_paths.py was never wired up in the windows tooling,
this PR wires it up, to get around a 8191 limitation for command
lines on windows an alternative "--no-subprocess" option has been
introduced to call the pep8 module directly from python.

TODO: A subprocess is still used for getting the version information

Contributors:

- @campbellbarton fixes to autopep8_format_paths.py to support
  the -no-subprocess option.

Pull Request: https://projects.blender.org/blender/blender/pulls/120794
2024-06-06 09:10:19 -06:00
Campbell Barton
e5fb4ad03b Cleanup: replace %-formatting with str.format in tools/ & release/ 2024-04-27 16:06:53 +10:00
Campbell Barton
d5f837a8ee Cleanup: remove redundant string formatting 2024-04-12 10:04:07 +10:00
Campbell Barton
6dffc162c7 Fix error in c_struct_clean.py
All words were counted for each token in the file.
2024-03-08 11:32:14 +11:00
Campbell Barton
44e64b8f29 Cleanup: correct type hints for Python scripts 2024-02-28 11:02:53 +11:00
Campbell Barton
f3753f9bcd CMake: add option to disable pre-compiled headers
./tools/utils_maintenance/code_clean failed to operate on any sources
that used pre-compiled headers.
2024-02-21 10:35:20 +11:00
Campbell Barton
d7dfbce288 code_clean: exclude BLI_strict_flags.h from removal
As this is only added to set strict warnings, cleaning logic would
remove as the compilers output is unchanged.

Support excluding headers from removal, others can be added if needed.
2024-02-14 13:40:33 +11:00
Campbell Barton
4745934306 code_clean: update doc-strings to prevent incorrect include removal 2024-02-13 14:18:19 +11:00
Campbell Barton
3b3eace193 code_clean: fix error running header_clean 2024-02-12 23:26:40 +11:00
Eugene Kuznetsov
d47f1fa1e8 Fix: more meaningful error when autopep8 is missing
Instead of getting a Python UnboundLocalError.

Pull Request: https://projects.blender.org/blender/blender/pulls/116613
2024-01-12 16:14:20 +01:00
Ray Molenkamp
0da2ebf644 make: fix clang-format detection
we're on 17.0.6, not 17.0.0 which resulted in a warning message
being emitted.
2024-01-03 13:29:40 -07:00
Brecht Van Lommel
d377ef2543 Clang Format: bump to version 17
Along with the 4.1 libraries upgrade, we are bumping the clang-format
version from 8-12 to 17. This affects quite a few files.

If not already the case, you may consider pointing your IDE to the
clang-format binary bundled with the Blender precompiled libraries.
2024-01-03 13:38:14 +01:00
Campbell Barton
afd5faceec Tools: add edit to use std min/max instead of MIN2/MAX2 macros 2023-11-07 11:57:02 +11:00
Campbell Barton
8974ca8f24 Tools: set the number of jobs to the CPU count for various utilities
Previously this was the double the CPU count because:

- Modern CPU's from AMD & Intel support SMT/hyper-threading which
  present twice as many cores, doubling again has little to no benefit.
- Using 2x or 4x the number of physical cores number can use a lot of
  memory on systems with many cores which are becoming more common.
2023-10-06 21:47:03 +11:00
Brecht Van Lommel
61f982f0d1 Cleanup: make format 2023-10-04 21:30:41 +02:00
Sergey Sharybin
7365f0b094 Cleanup: Cover .metal files with make format
Pull Request: https://projects.blender.org/blender/blender/pulls/111930
2023-09-05 09:59:47 +02:00
Campbell Barton
0c26c84704 Cleanup: spelling in comments 2023-09-05 11:04:27 +10:00
Campbell Barton
e8c812a307 Cleanup: spelling in comments, update dictionary 2023-09-03 21:35:07 +10:00
Clément Foucault
05816e6f7a Fix GPU: MSL sources not considered by make format 2023-09-01 10:40:21 +02:00
Campbell Barton
e955c94ed3 License Headers: Set copyright to "Blender Authors", add AUTHORS
Listing the "Blender Foundation" as copyright holder implied the Blender
Foundation holds copyright to files which may include work from many
developers.

While keeping copyright on headers makes sense for isolated libraries,
Blender's own code may be refactored or moved between files in a way
that makes the per file copyright holders less meaningful.

Copyright references to the "Blender Foundation" have been replaced with
"Blender Authors", with the exception of `./extern/` since these this
contains libraries which are more isolated, any changed to license
headers there can be handled on a case-by-case basis.

Some directories in `./intern/` have also been excluded:

- `./intern/cycles/` it's own `AUTHORS` file is planned.
- `./intern/opensubdiv/`.

An "AUTHORS" file has been added, using the chromium projects authors
file as a template.

Design task: #110784

Ref !110783.
2023-08-16 00:20:26 +10:00
Campbell Barton
19c3d7ee7d Tools: add use_listbase_foreach_macro edit to code_clean utility
Replaces loops on list bases with LISTBASE_FOREACH &
LISTBASE_FOREACH_BACKWARD.
2023-08-05 14:42:42 +10:00
Campbell Barton
f88f1c4011 Cleanup: quiet mypy warning 2023-08-04 11:27:34 +10:00
Campbell Barton
90e123c746 Tools: fix code_clean cleaning generated files
When a relative build directory was passed in, code-clean wasn't
filtering out generated sources and would clean them too.
2023-07-31 19:57:27 +10:00
Campbell Barton
27cb0e18b7 code_clean: skip "parenthesis_cleanup" in macro definitions
Don't remove parenthesis in macro definitions as it's important to keep
parenthesis around arguments.
2023-07-27 12:10:14 +10:00
Campbell Barton
4fd3ec6337 Tools: code_clean: add a default value for '--edits' & '--match'
Each edit-generate now declares if it's generally considered safe
(isn't likely to make changes that break on other platforms for e.g.)
Default edits are now used when --edits is omitted.

The match argument now defaults to files with c/cc/cpp extensions when
omitted.

It's now possible to run:

  ./tools/utils_maintenance/code_clean.py {BUILD_DIR}

Which gives results that can be used with a very low risk of causing
functional changes or breaking other platforms.
2023-07-25 13:25:19 +10:00
Campbell Barton
ad7150dcca Tools: improve code_clean's 'remove_struct' edit to avoid CPU overhead
Many struct removals were being tested which always failed.
Avoid testing removal of forward declarations & struct declarations.
2023-07-25 13:24:59 +10:00
Campbell Barton
481eaff790 Tools: improve code_clean's 'use_brief_types' edit to skip typedef's
`typedef unsigned int uint;` could be converted into
`typedef uint uint;`.

Resolve by skipping instances of unsigned that follow a typedef.
2023-07-25 13:24:59 +10:00
Campbell Barton
22354e8f84 Tools: add --verbose argument for code_clean.py
Support `--verbose compile,edit_actions` (one or both can be selected),
to output the compiler output of each edit and the text (before/after).

This replaces existing hard-coded values.

Other minor changes:

- Print the file-path for each edit for better context.
- Print skipped edits when multiple edits are passed in so other
  edits might be applied separately are listed.
2023-07-21 11:08:24 +10:00
Campbell Barton
c1cb7f0900 Tools: more efficient grouping of edits code_clean.py
Group edits where possible, instead of waiting for each edit to complete
for all files. This avoids bottlenecks on single files as much.
2023-07-21 00:13:13 +10:00
Campbell Barton
b1daf6bfad Tools: add --jobs arguments to clang checker and code-clean tool
Setting jobs to one is useful for debugging, reducing the number
of threads can be useful for code_clean as a background task.
2023-07-21 00:13:13 +10:00
Campbell Barton
1dec7189ed Fix '--help' message error in code_clean when '%' characters were used 2023-07-13 09:54:05 +10:00
Campbell Barton
feb83e66c6 code_clean: add use_empty_void_arg cleanup operation
Removes the use of (void) in C++ for functions with no arguments
2023-07-02 19:54:27 +10:00
Campbell Barton
65f99397ec License headers: use SPDX-FileCopyrightText in all sources 2023-06-15 13:35:34 +10:00
Campbell Barton
8f109712ee License headers: use SPDX-FileCopyrightText for build_files/ & tools/ 2023-06-14 23:36:23 +10:00
Hans Goudey
7d935f94f3 Cleanup: Grammar: it's vs its 2023-06-13 14:51:49 -04:00
Campbell Barton
e2cb52594a code_clean: add 'remove_struct_qualifier' edit
Removes struct qualifier when it's not needed.
2023-05-31 17:12:19 +10:00
Campbell Barton
b18b7c1de1 make format: include tools/ as it's no longer a sub-module 2023-05-27 13:43:33 +10:00
Campbell Barton
2f9538a8c7 code_clean: add utility for replacing BLI string copy/printf with macros
These macros have the advantage of being less verbose and disallowing
sizeof(..) referencing the size of a pointer. e.g. #107443.
2023-05-09 13:16:09 +10:00
Damien Picard
3f0d2cf9e1 Add scripts dir to the make format paths for Python
`make format` uses autopep8 to format Python, using a list of paths
specified in `tools/utils_maintenance/autopep8_format_paths.py`. The
scripts folder used to be a submodule inside release, but it is now at
the root of the blender repo.

This commit adds `scripts` to the list of paths to format.

Ref !107143
2023-04-20 05:30:34 +02:00
Campbell Barton
31147c90c4 code_clean: restrict 'use_function_style_cast' edits to C++
Allows running multiple edits at once on C & C++ files without
C++ edits being attempted on C source.
2023-03-21 19:50:46 +11:00
Campbell Barton
bd0aa88909 Fix invalid path references after moving tools & scripts 2023-03-01 22:00:46 +11:00
Sergey Sharybin
9b70039014 Fix paths in the auto-formatting tools
Those got missed in the submodule change commit.

Pull Request #105178
2023-02-24 15:52:34 +01:00
Sergey Sharybin
e28a9a87c9 Fix references to the /release/scripts directories
Those were moved to the /scripts
2023-02-21 18:40:47 +01:00
Sergey Sharybin
03806d0b67 Re-design of submodules used in blender.git
This commit implements described in the #104573.

The goal is to fix the confusion of the submodule hashes change, which are not
ideal for any of the supported git-module configuration (they are either always
visible causing confusion, or silently staged and committed, also causing
confusion).

This commit replaces submodules with a checkout of addons and addons_contrib,
covered by the .gitignore, and locale and developer tools are moved to the
main repository.

This also changes the paths:
- /release/scripts are moved to the /scripts
- /source/tools are moved to the /tools
- /release/datafiles/locale is moved to /locale

This is done to avoid conflicts when using bisect, and also allow buildbot to
automatically "recover" wgen building older or newer branches/patches.

Running `make update` will initialize the local checkout to the changed
repository configuration.

Another aspect of the change is that the make update will support Github style
of remote organization (origin remote pointing to thy fork, upstream remote
pointing to the upstream blender/blender.git).

Pull Request #104755
2023-02-21 16:39:58 +01:00