Page MenuHome

clang-format configuraiton & migration for T53211
Needs ReviewPublic

Authored by Campbell Barton (campbellbarton) on Wed, Jan 9, 8:24 PM.

Details

Summary

This task adds configuration and migration script, to evaluate moving to clang-format.

Usage

To run the migration:

make format

Or to only operate on certain paths:

make format PATHS="intern/cycles source/creator"

Migration TODO's

Migration scripts.

  • Check clang-format version is >= 6.0.
  • make format for windows make.bat

    Although windows users will likely use MSVC's built-in clang-format.
  • make format could only format modified files

    Better default for developers) perhaps make format-all runs on all files.

Pre Migration cleanup.

  • Some header guards are not the first pre-processor lines in the file causing them not to be detected, causing all preprocessor arguments to be indented. rB5681631109852d1037cddafd60f39552f8ba3bbf

    Search for #\s+define\s+.*_H__\b after formatting to see issues.
  • Tabs in string literals should be replaced with \t or converted to spaces.

    This way we can avoid tabs in C/C++ source, expanding all tabs to spaces when migrating.

Clang-format TODO's

Where clang-format doesn't produce acceptable output.

Notes

  • the clang-format script will eventually be moved into source/tools/utils.

Diff Detail

Repository
rB Blender
Branch
temp-clang-format
Build Status
Buildable 2735
Build 2735: arc lint + arc unit

Event Timeline

Campbell Barton (campbellbarton) retitled this revision from Initial clang-format for T53211 to clang-format configuraiton & migration for T53211.
Campbell Barton (campbellbarton) edited the summary of this revision. (Show Details)

I can't count on python being available on windows, I'd prefer doing this from cmake if possible.

Campbell Barton (campbellbarton) edited the summary of this revision. (Show Details)
Campbell Barton (campbellbarton) edited the summary of this revision. (Show Details)
Campbell Barton (campbellbarton) edited the summary of this revision. (Show Details)
  • clang-format-paths: add version check
Campbell Barton (campbellbarton) edited the summary of this revision. (Show Details)

Update from branch.

  • clang-format-paths: fix version check for case like 6.0.0-1ubuntu2.
  • clang-format: use clang-format binary from lib directory on macOS.
  • clang-format: add most intern/ modules for formatting, including cycles.
  • clang-format: exclude opensubdiv, it uses Google style.
  • clang-format: Add test/gtest ignore BLI headers that fail badly to format
  • clang-format: skip files copied from other projects
  • Merge branch 'master' into temp-clang-format
  • clang-format: disable formatting via comments where possible
  • clang-format: Add FixNamespaceComments
  • Merge branch 'master' into temp-clang-format
  • clang-format: disable for parts of unit.c
  • Merge branch 'master' into temp-clang-format
  • clang-format: disable for bmesh operator defines.
  • Merge branch 'master' into temp-clang-format