[libcamera-devel] [PATCH v3] utils: ipc: extract-docs: Extract the SPDX header

Paul Elder paul.elder at ideasonboard.com
Fri May 28 12:48:24 CEST 2021


Take the SPDX header from the mojom file. Error out if the mojom file
has no SPDX header.

Signed-off-by: Paul Elder <paul.elder at ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>

---
Changes in v3:
- make the if nicer

Changes in v2:
- Error out if SPDX header is unavailable
- add newline at end of default SPDX string
---
 utils/ipc/extract-docs.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/utils/ipc/extract-docs.py b/utils/ipc/extract-docs.py
index 56566ce0..8f7fff9f 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,12 @@ 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 not regex_spdx.match(lines[0]):
+        raise Exception(f'Missing SPDX license header in {args.input}')
+
+    data = lines[0]
+    data += f'''\
 /*
  * Copyright (C) 2021, Google Inc.
  *
-- 
2.27.0



More information about the libcamera-devel mailing list