[libcamera-devel] [PATCH] clang-format: Enable sorted includes

Laurent Pinchart laurent.pinchart at ideasonboard.com
Mon Feb 22 10:56:26 CET 2021


Hi Kieran,

Thank you for the patch.

On Mon, Feb 22, 2021 at 09:46:08AM +0000, Kieran Bingham wrote:
> We aim to ensure that our includes are alphabetically sorted.  Whilst
> checkstyle.py also handles this, enable the clang-format explicitly to
> define the code-style requirement, and allow clang-format to also
> correct un-sorted header includes.
> 
> Signed-off-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
> 
> ---
> I can't see why this isn't enabled, unless clang-format is sorting in a
> manner which is incompatible with the implementation in our
> checkstyle.py ?
> 
> Some initial testing shows that clang-format only sorts per block,
> separated by newlines, which seems to match our implementation.

I was considering enabling this along with corresponding include
regexes, but I suppose it can go on its own too, if you guarantee it
works properly :-)

Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>

With appropriate regexes we could possibly drop the include formatter
from checkstyle.py.

>  .clang-format | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/.clang-format b/.clang-format
> index bef07cd84338..f5d9ba940eeb 100644
> --- a/.clang-format
> +++ b/.clang-format
> @@ -97,7 +97,7 @@ PenaltyReturnTypeOnItsOwnLine: 60
>  
>  PointerAlignment: Right
>  ReflowComments: false
> -SortIncludes: false
> +SortIncludes: true
>  #SortUsingDeclarations: false # Unknown to clang-format-4.0
>  SpaceAfterCStyleCast: false
>  SpaceAfterTemplateKeyword: false

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list