Skip to content

Commit 1d8f352

Browse files
committed
license: check for CMakeLists.txt and Kconfig files
Check license for cmake and kconfig files. Signed-off-by: Anas Nashif <[email protected]>
1 parent 188915d commit 1d8f352

File tree

1 file changed

+28
-10
lines changed

1 file changed

+28
-10
lines changed

scripts/ci/check_compliance.py

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -578,33 +578,51 @@ def run(self):
578578

579579
report = ""
580580

581-
whitelist_extensions = ['.yaml', '.html']
582-
whitelist_languages = ['CMake', 'HTML']
581+
never_check_ext = ['.yaml', '.html', '.rst', '.conf', '.cfg']
582+
never_check_langs = ['HTML']
583+
check_langs = ['CMake']
583584
with open('scancode.json', 'r') as json_fp:
584585
scancode_results = json.load(json_fp)
585586
for file in scancode_results['files']:
586587
if file['type'] == 'directory':
587588
continue
588589

589-
original_fp = str(file['path']).replace('scancode-files/', '')
590+
orig_path = str(file['path']).replace('scancode-files/', '')
590591
licenses = file['licenses']
591-
if (file['is_script'] or file['is_source']) and (file['programming_language'] not in whitelist_languages) and (file['extension'] not in whitelist_extensions):
592-
if not file['licenses']:
593-
report += ("* {} missing license.\n".format(original_fp))
592+
file_type = file.get("file_type")
593+
kconfig = "Kconfig" in orig_path and file_type in ['ASCII text']
594+
check = False
595+
596+
if file.get("extension") in never_check_ext:
597+
check = False
598+
elif file.get("programming_language") in never_check_langs:
599+
check = False
600+
elif kconfig:
601+
check = True
602+
elif file.get("programming_language") in check_langs:
603+
check = True
604+
elif file.get("is_script"):
605+
check = True
606+
elif file.get("is_source"):
607+
check = True
608+
609+
if check:
610+
if not licenses:
611+
report += ("* {} missing license.\n".format(orig_path))
594612
else:
595613
for lic in licenses:
596614
if lic['key'] != "apache-2.0":
597615
report += ("* {} is not apache-2.0 licensed: {}\n".format(
598-
original_fp, lic['key']))
616+
orig_path, lic['key']))
599617
if lic['category'] != 'Permissive':
600618
report += ("* {} has non-permissive license: {}\n".format(
601-
original_fp, lic['key']))
619+
orig_path, lic['key']))
602620
if lic['key'] == 'unknown-spdx':
603621
report += ("* {} has unknown SPDX: {}\n".format(
604-
original_fp, lic['key']))
622+
orig_path, lic['key']))
605623

606624
if not file['copyrights']:
607-
report += ("* {} missing copyright.\n".format(original_fp))
625+
report += ("* {} missing copyright.\n".format(orig_path))
608626

609627
if report != "":
610628
self.add_failure("""

0 commit comments

Comments
 (0)