[libcamera-devel] utils: ipc: extract-docs: Extract the SPDX header if it exists
diff mbox series

Message ID 20210527092743.1347857-1-paul.elder@ideasonboard.com
State Superseded
Headers show
Series
  • [libcamera-devel] utils: ipc: extract-docs: Extract the SPDX header if it exists
Related show

Commit Message

Paul Elder May 27, 2021, 9:27 a.m. UTC
Take the SPDX header from the mojom file, if it exists. Otherwise
default to LGPL-2.1+ as before.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
---
 utils/ipc/extract-docs.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Comments

Paul Elder May 27, 2021, 9:30 a.m. UTC | #1
Hi me,

On Thu, May 27, 2021 at 06:27:43PM +0900, Paul Elder wrote:
> Take the SPDX header from the mojom file, if it exists. Otherwise
> default to LGPL-2.1+ as before.
> 
> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
> ---
>  utils/ipc/extract-docs.py | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/utils/ipc/extract-docs.py b/utils/ipc/extract-docs.py
> index 56566ce0..b617b6fa 100755
> --- a/utils/ipc/extract-docs.py
> +++ b/utils/ipc/extract-docs.py
> @@ -12,6 +12,7 @@ import sys
>  
>  regex_block_start = re.compile('^\/\*\*$')
>  regex_block_end = re.compile('^ \*\/$')
> +regex_spdx = re.compile('^\/\* SPDX-License-Identifier: .* \*\/$')
>  
>  
>  def main(argv):
> @@ -28,8 +29,13 @@ def main(argv):
>  
>      lines = open(args.input, 'r').readlines()
>      pipeline = args.input.split('/')[-1].replace('.mojom', '')
> -    data = f'''\
> -/* SPDX-License-Identifier: LGPL-2.1-or-later */
> +
> +    if regex_spdx.match(lines[0]):
> +        data = lines[0]
> +    else:
> +        data = '/* SPDX-License-Identifier: LGPL-2.1-or-later */'

This needs \n at the end of the string.


Paul
> +
> +    data += f'''\
>  /*
>   * Copyright (C) 2021, Google Inc.
>   *
> -- 
> 2.27.0
>
Laurent Pinchart May 27, 2021, 9:36 a.m. UTC | #2
Hi Paul,

Thank you for the patch.

On Thu, May 27, 2021 at 06:27:43PM +0900, Paul Elder wrote:
> Take the SPDX header from the mojom file, if it exists. Otherwise
> default to LGPL-2.1+ as before.

Do we need a default ? All the mojom files should have an SPDX header.

> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
> ---
>  utils/ipc/extract-docs.py | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/utils/ipc/extract-docs.py b/utils/ipc/extract-docs.py
> index 56566ce0..b617b6fa 100755
> --- a/utils/ipc/extract-docs.py
> +++ b/utils/ipc/extract-docs.py
> @@ -12,6 +12,7 @@ import sys
>  
>  regex_block_start = re.compile('^\/\*\*$')
>  regex_block_end = re.compile('^ \*\/$')
> +regex_spdx = re.compile('^\/\* SPDX-License-Identifier: .* \*\/$')
>  
>  
>  def main(argv):
> @@ -28,8 +29,13 @@ def main(argv):
>  
>      lines = open(args.input, 'r').readlines()
>      pipeline = args.input.split('/')[-1].replace('.mojom', '')
> -    data = f'''\
> -/* SPDX-License-Identifier: LGPL-2.1-or-later */
> +
> +    if regex_spdx.match(lines[0]):
> +        data = lines[0]
> +    else:
> +        data = '/* SPDX-License-Identifier: LGPL-2.1-or-later */'
> +
> +    data += f'''\
>  /*
>   * Copyright (C) 2021, Google Inc.
>   *
Paul Elder May 27, 2021, 9:59 a.m. UTC | #3
Hi Laurent,

On Thu, May 27, 2021 at 12:36:25PM +0300, Laurent Pinchart wrote:
> Hi Paul,
> 
> Thank you for the patch.
> 
> On Thu, May 27, 2021 at 06:27:43PM +0900, Paul Elder wrote:
> > Take the SPDX header from the mojom file, if it exists. Otherwise
> > default to LGPL-2.1+ as before.
> 
> Do we need a default ? All the mojom files should have an SPDX header.

Maybe we don't.

Just error out then? Or output without the SPDX header?


Paul

> 
> > Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
> > ---
> >  utils/ipc/extract-docs.py | 10 ++++++++--
> >  1 file changed, 8 insertions(+), 2 deletions(-)
> > 
> > diff --git a/utils/ipc/extract-docs.py b/utils/ipc/extract-docs.py
> > index 56566ce0..b617b6fa 100755
> > --- a/utils/ipc/extract-docs.py
> > +++ b/utils/ipc/extract-docs.py
> > @@ -12,6 +12,7 @@ import sys
> >  
> >  regex_block_start = re.compile('^\/\*\*$')
> >  regex_block_end = re.compile('^ \*\/$')
> > +regex_spdx = re.compile('^\/\* SPDX-License-Identifier: .* \*\/$')
> >  
> >  
> >  def main(argv):
> > @@ -28,8 +29,13 @@ def main(argv):
> >  
> >      lines = open(args.input, 'r').readlines()
> >      pipeline = args.input.split('/')[-1].replace('.mojom', '')
> > -    data = f'''\
> > -/* SPDX-License-Identifier: LGPL-2.1-or-later */
> > +
> > +    if regex_spdx.match(lines[0]):
> > +        data = lines[0]
> > +    else:
> > +        data = '/* SPDX-License-Identifier: LGPL-2.1-or-later */'
> > +
> > +    data += f'''\
> >  /*
> >   * Copyright (C) 2021, Google Inc.
> >   *
Laurent Pinchart May 27, 2021, 10:07 a.m. UTC | #4
Hi Paul,

On Thu, May 27, 2021 at 06:59:48PM +0900, paul.elder@ideasonboard.com wrote:
> On Thu, May 27, 2021 at 12:36:25PM +0300, Laurent Pinchart wrote:
> > On Thu, May 27, 2021 at 06:27:43PM +0900, Paul Elder wrote:
> > > Take the SPDX header from the mojom file, if it exists. Otherwise
> > > default to LGPL-2.1+ as before.
> > 
> > Do we need a default ? All the mojom files should have an SPDX header.
> 
> Maybe we don't.
> 
> Just error out then? Or output without the SPDX header?

I'd error out, we'll catch missing SPDX tags faster.

> > > Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
> > > ---
> > >  utils/ipc/extract-docs.py | 10 ++++++++--
> > >  1 file changed, 8 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/utils/ipc/extract-docs.py b/utils/ipc/extract-docs.py
> > > index 56566ce0..b617b6fa 100755
> > > --- a/utils/ipc/extract-docs.py
> > > +++ b/utils/ipc/extract-docs.py
> > > @@ -12,6 +12,7 @@ import sys
> > >  
> > >  regex_block_start = re.compile('^\/\*\*$')
> > >  regex_block_end = re.compile('^ \*\/$')
> > > +regex_spdx = re.compile('^\/\* SPDX-License-Identifier: .* \*\/$')
> > >  
> > >  
> > >  def main(argv):
> > > @@ -28,8 +29,13 @@ def main(argv):
> > >  
> > >      lines = open(args.input, 'r').readlines()
> > >      pipeline = args.input.split('/')[-1].replace('.mojom', '')
> > > -    data = f'''\
> > > -/* SPDX-License-Identifier: LGPL-2.1-or-later */
> > > +
> > > +    if regex_spdx.match(lines[0]):
> > > +        data = lines[0]
> > > +    else:
> > > +        data = '/* SPDX-License-Identifier: LGPL-2.1-or-later */'
> > > +
> > > +    data += f'''\
> > >  /*
> > >   * Copyright (C) 2021, Google Inc.
> > >   *

Patch
diff mbox series

diff --git a/utils/ipc/extract-docs.py b/utils/ipc/extract-docs.py
index 56566ce0..b617b6fa 100755
--- a/utils/ipc/extract-docs.py
+++ b/utils/ipc/extract-docs.py
@@ -12,6 +12,7 @@  import sys
 
 regex_block_start = re.compile('^\/\*\*$')
 regex_block_end = re.compile('^ \*\/$')
+regex_spdx = re.compile('^\/\* SPDX-License-Identifier: .* \*\/$')
 
 
 def main(argv):
@@ -28,8 +29,13 @@  def main(argv):
 
     lines = open(args.input, 'r').readlines()
     pipeline = args.input.split('/')[-1].replace('.mojom', '')
-    data = f'''\
-/* SPDX-License-Identifier: LGPL-2.1-or-later */
+
+    if regex_spdx.match(lines[0]):
+        data = lines[0]
+    else:
+        data = '/* SPDX-License-Identifier: LGPL-2.1-or-later */'
+
+    data += f'''\
 /*
  * Copyright (C) 2021, Google Inc.
  *