[libcamera-devel] [PATCH] clang-format: Enable sorted includes
Kieran Bingham
kieran.bingham at ideasonboard.com
Mon Mar 8 12:44:06 CET 2021
On 22/02/2021 09:56, Laurent Pinchart wrote:
> 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.
These look interesting but I haven't spent the time to figure out how
they really work yet.
An interesting thing to tackle in the future though, we just need to add
it to some todo list ... ;-)
--
Kieran
>
>> .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
--
Kieran
More information about the libcamera-devel
mailing list