Message ID | 20220526110009.13874-2-laurent.pinchart@ideasonboard.com |
---|---|
State | Accepted |
Commit | c58ac2f4984f63e8b9cbbdfea04fb3d8ecfccac1 |
Headers | show |
Series |
|
Related | show |
Hi Laurent, Thank you for the patch. On 5/26/22 13:00, Laurent Pinchart via libcamera-devel wrote: > The IncludeOrderFormatter will be extended with more formatting rules > that should be applied before clang-format gets run, as it will > influence its output. > > Add a priority mechanism for formatters, and give a negative priority to > the ClangFormatter to make it run last. > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > --- > utils/checkstyle.py | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/utils/checkstyle.py b/utils/checkstyle.py > index 835f2a9fcd71..66af96abd402 100755 > --- a/utils/checkstyle.py > +++ b/utils/checkstyle.py > @@ -279,6 +279,8 @@ class ClassRegistry(type): > newclass = super().__new__(cls, clsname, bases, attrs) > if bases: > bases[0].subclasses.append(newclass) > + bases[0].subclasses.sort(key=lambda x: getattr(x, 'priority', 0), > + reverse=True) Makes sense.. > return newclass > > > @@ -568,6 +570,7 @@ class Formatter(metaclass=ClassRegistry): > > class CLangFormatter(Formatter): Couldn't help with notice the "L" in CLangFormatter, is it intentional. Anyways not related to this patch so: Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> > patterns = ('*.c', '*.cpp', '*.h') > + priority = -1 > > @classmethod > def format(cls, filename, data):
Hi Umang, On Fri, May 27, 2022 at 12:02:56PM +0200, Umang Jain wrote: > On 5/26/22 13:00, Laurent Pinchart via libcamera-devel wrote: > > The IncludeOrderFormatter will be extended with more formatting rules > > that should be applied before clang-format gets run, as it will > > influence its output. > > > > Add a priority mechanism for formatters, and give a negative priority to > > the ClangFormatter to make it run last. > > > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > > --- > > utils/checkstyle.py | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/utils/checkstyle.py b/utils/checkstyle.py > > index 835f2a9fcd71..66af96abd402 100755 > > --- a/utils/checkstyle.py > > +++ b/utils/checkstyle.py > > @@ -279,6 +279,8 @@ class ClassRegistry(type): > > newclass = super().__new__(cls, clsname, bases, attrs) > > if bases: > > bases[0].subclasses.append(newclass) > > + bases[0].subclasses.sort(key=lambda x: getattr(x, 'priority', 0), > > + reverse=True) > > > Makes sense.. > > > return newclass > > > > > > @@ -568,6 +570,7 @@ class Formatter(metaclass=ClassRegistry): > > > > class CLangFormatter(Formatter): > > Couldn't help with notice the "L" in CLangFormatter, is it intentional. Indeed. I'm not sure it was intentional. I've updated the commit message accordingly. > Anyways not related to this patch so: > > Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> > > > patterns = ('*.c', '*.cpp', '*.h') > > + priority = -1 > > > > @classmethod > > def format(cls, filename, data):
Hi Laurent, On Thu, May 26, 2022 at 02:00:07PM +0300, Laurent Pinchart via libcamera-devel wrote: > The IncludeOrderFormatter will be extended with more formatting rules > that should be applied before clang-format gets run, as it will > influence its output. > > Add a priority mechanism for formatters, and give a negative priority to > the ClangFormatter to make it run last. > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> > --- > utils/checkstyle.py | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/utils/checkstyle.py b/utils/checkstyle.py > index 835f2a9fcd71..66af96abd402 100755 > --- a/utils/checkstyle.py > +++ b/utils/checkstyle.py > @@ -279,6 +279,8 @@ class ClassRegistry(type): > newclass = super().__new__(cls, clsname, bases, attrs) > if bases: > bases[0].subclasses.append(newclass) > + bases[0].subclasses.sort(key=lambda x: getattr(x, 'priority', 0), > + reverse=True) > return newclass > > > @@ -568,6 +570,7 @@ class Formatter(metaclass=ClassRegistry): > > class CLangFormatter(Formatter): > patterns = ('*.c', '*.cpp', '*.h') > + priority = -1 > > @classmethod > def format(cls, filename, data):
diff --git a/utils/checkstyle.py b/utils/checkstyle.py index 835f2a9fcd71..66af96abd402 100755 --- a/utils/checkstyle.py +++ b/utils/checkstyle.py @@ -279,6 +279,8 @@ class ClassRegistry(type): newclass = super().__new__(cls, clsname, bases, attrs) if bases: bases[0].subclasses.append(newclass) + bases[0].subclasses.sort(key=lambda x: getattr(x, 'priority', 0), + reverse=True) return newclass @@ -568,6 +570,7 @@ class Formatter(metaclass=ClassRegistry): class CLangFormatter(Formatter): patterns = ('*.c', '*.cpp', '*.h') + priority = -1 @classmethod def format(cls, filename, data):
The IncludeOrderFormatter will be extended with more formatting rules that should be applied before clang-format gets run, as it will influence its output. Add a priority mechanism for formatters, and give a negative priority to the ClangFormatter to make it run last. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- utils/checkstyle.py | 3 +++ 1 file changed, 3 insertions(+)