forked from FreeRTOS/FreeRTOS-Kernel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into autoReloadName
- Loading branch information
Showing
123 changed files
with
2,722 additions
and
6,627 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ | |
# */ | ||
|
||
import os | ||
import re | ||
from common.header_checker import HeaderChecker | ||
|
||
#-------------------------------------------------------------------------------------------------- | ||
|
@@ -106,6 +107,15 @@ | |
r'.*portable/GCC/AVR32_UC3/.*', | ||
] | ||
|
||
KERNEL_ARM_COLLAB_FILES_PATTERNS = [ | ||
r'.*portable/ARMv8M/*', | ||
r'.*portable/.*/ARM_CM23*', | ||
r'.*portable/.*/ARM_CM33*', | ||
r'.*portable/.*/ARM_CM35*', | ||
r'.*portable/.*/ARM_CM55*', | ||
r'.*portable/.*/ARM_CM85*', | ||
] | ||
|
||
KERNEL_HEADER = [ | ||
'/*\n', | ||
' * FreeRTOS Kernel <DEVELOPMENT BRANCH>\n', | ||
|
@@ -139,19 +149,92 @@ | |
|
||
FREERTOS_COPYRIGHT_REGEX = r"^(;|#)?( *(\/\*|\*|#|\/\/))? Copyright \(C\) 20\d\d Amazon.com, Inc. or its affiliates. All Rights Reserved\.( \*\/)?$" | ||
|
||
FREERTOS_ARM_COLLAB_COPYRIGHT_REGEX = r"(^(;|#)?( *(\/\*|\*|#|\/\/))? Copyright \(C\) 20\d\d Amazon.com, Inc. or its affiliates. All Rights Reserved\.( \*\/)?$)|" + \ | ||
r"(^(;|#)?( *(\/\*|\*|#|\/\/))? Copyright 20\d\d Arm Limited and/or its affiliates( \*\/)?$)|" + \ | ||
r"(^(;|#)?( *(\/\*|\*|#|\/\/))? <[email protected]>( \*\/)?$)" | ||
|
||
|
||
class KernelHeaderChecker(HeaderChecker): | ||
def __init__( | ||
self, | ||
header, | ||
padding=1000, | ||
ignored_files=None, | ||
ignored_ext=None, | ||
ignored_patterns=None, | ||
py_ext=None, | ||
asm_ext=None, | ||
third_party_patterns=None, | ||
copyright_regex = None | ||
): | ||
super().__init__(header, padding, ignored_files, ignored_ext, ignored_patterns, | ||
py_ext, asm_ext, third_party_patterns, copyright_regex) | ||
|
||
self.armCollabRegex = re.compile(FREERTOS_ARM_COLLAB_COPYRIGHT_REGEX) | ||
|
||
self.armCollabFilesPatternList = [] | ||
for pattern in KERNEL_ARM_COLLAB_FILES_PATTERNS: | ||
self.armCollabFilesPatternList.append(re.compile(pattern)) | ||
|
||
def isArmCollabFile(self, path): | ||
for pattern in self.armCollabFilesPatternList: | ||
if pattern.match(path): | ||
return True | ||
return False | ||
|
||
def checkArmCollabFile(self, path): | ||
isValid = False | ||
file_ext = os.path.splitext(path)[-1] | ||
|
||
with open(path, encoding="utf-8", errors="ignore") as file: | ||
chunk = file.read(len("".join(self.header)) + self.padding) | ||
lines = [("%s\n" % line) for line in chunk.strip().splitlines()][ | ||
: len(self.header) + 2 | ||
] | ||
if (len(lines) > 0) and (lines[0].find("#!") == 0): | ||
lines.remove(lines[0]) | ||
|
||
# Split lines in sections. | ||
headers = dict() | ||
headers["text"] = [] | ||
headers["copyright"] = [] | ||
headers["spdx"] = [] | ||
for line in lines: | ||
if self.armCollabRegex.match(line): | ||
headers["copyright"].append(line) | ||
elif "SPDX-License-Identifier:" in line: | ||
headers["spdx"].append(line) | ||
else: | ||
headers["text"].append(line) | ||
|
||
text_equal = self.isValidHeaderSection(file_ext, "text", headers["text"]) | ||
spdx_equal = self.isValidHeaderSection(file_ext, "spdx", headers["spdx"]) | ||
|
||
if text_equal and spdx_equal and len(headers["copyright"]) == 3: | ||
isValid = True | ||
|
||
return isValid | ||
|
||
def customCheck(self, path): | ||
isValid = False | ||
if self.isArmCollabFile(path): | ||
isValid = self.checkArmCollabFile(path) | ||
return isValid | ||
|
||
|
||
def main(): | ||
parser = HeaderChecker.configArgParser() | ||
args = parser.parse_args() | ||
|
||
# Configure the checks then run | ||
checker = HeaderChecker(KERNEL_HEADER, | ||
copyright_regex=FREERTOS_COPYRIGHT_REGEX, | ||
ignored_files=KERNEL_IGNORED_FILES, | ||
ignored_ext=KERNEL_IGNORED_EXTENSIONS, | ||
ignored_patterns=KERNEL_IGNORED_PATTERNS, | ||
third_party_patterns=KERNEL_THIRD_PARTY_PATTERNS, | ||
py_ext=KERNEL_PY_EXTENSIONS, | ||
asm_ext=KERNEL_ASM_EXTENSIONS) | ||
checker = KernelHeaderChecker(KERNEL_HEADER, | ||
copyright_regex=FREERTOS_COPYRIGHT_REGEX, | ||
ignored_files=KERNEL_IGNORED_FILES, | ||
ignored_ext=KERNEL_IGNORED_EXTENSIONS, | ||
ignored_patterns=KERNEL_IGNORED_PATTERNS, | ||
third_party_patterns=KERNEL_THIRD_PARTY_PATTERNS, | ||
py_ext=KERNEL_PY_EXTENSIONS, | ||
asm_ext=KERNEL_ASM_EXTENSIONS) | ||
checker.ignoreFile(os.path.split(__file__)[-1]) | ||
|
||
rc = checker.processArgs(args) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.