1#!/usr/bin/env python3 2#/* 3# * FreeRTOS Kernel V11.1.0 4# * Copyright (C) 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. 5# * 6# * SPDX-License-Identifier: MIT 7# * 8# * Permission is hereby granted, free of charge, to any person obtaining a copy of 9# * this software and associated documentation files (the "Software"), to deal in 10# * the Software without restriction, including without limitation the rights to 11# * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 12# * the Software, and to permit persons to whom the Software is furnished to do so, 13# * subject to the following conditions: 14# * 15# * The above copyright notice and this permission notice shall be included in all 16# * copies or substantial portions of the Software. 17# * 18# * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19# * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 20# * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 21# * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 22# * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 23# * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24# * 25# * https://www.FreeRTOS.org 26# * https://github.com/FreeRTOS 27# * 28# */ 29 30import os 31from common.header_checker import HeaderChecker 32 33#-------------------------------------------------------------------------------------------------- 34# CONFIG 35#-------------------------------------------------------------------------------------------------- 36KERNEL_IGNORED_FILES = [ 37 'FreeRTOS-openocd.c', 38 'Makefile', 39 '.DS_Store', 40 'cspell.config.yaml', 41 '.clang-format' 42] 43 44KERNEL_IGNORED_EXTENSIONS = [ 45 '.yml', 46 '.css', 47 '.idx', 48 '.md', 49 '.url', 50 '.sty', 51 '.0-rc2', 52 '.s82', 53 '.js', 54 '.out', 55 '.pack', 56 '.2', 57 '.1-kernel-only', 58 '.0-kernel-only', 59 '.0-rc1', 60 '.readme', 61 '.tex', 62 '.png', 63 '.bat', 64 '.sh', 65 '.txt', 66 '.cmake', 67 '.config' 68] 69 70KERNEL_ASM_EXTENSIONS = [ 71 '.s', 72 '.S', 73 '.src', 74 '.inc', 75 '.s26', 76 '.s43', 77 '.s79', 78 '.s85', 79 '.s87', 80 '.s90', 81 '.asm', 82 '.h' 83] 84 85KERNEL_PY_EXTENSIONS = [ 86 '.py' 87] 88 89KERNEL_IGNORED_PATTERNS = [ 90 r'.*\.git.*', 91 r'.*portable/IAR/AtmelSAM7S64/.*AT91SAM7.*', 92 r'.*portable/GCC/ARM7_AT91SAM7S/.*', 93 r'.*portable/MPLAB/PIC18F/stdio.h', 94 r'.*portable/ThirdParty/xClang/XCOREAI/*', 95 r'.*IAR/ARM_C*', 96 r'.*IAR/78K0R/*', 97 r'.*CCS/MSP430X/*', 98 r'.*portable/template/*', 99 r'.*template_configuration/*' 100] 101 102KERNEL_THIRD_PARTY_PATTERNS = [ 103 r'.*portable/ThirdParty/GCC/Posix/port*', 104 r'.*portable/ThirdParty/*', 105 r'.*portable/IAR/AVR32_UC3/.*', 106 r'.*portable/GCC/AVR32_UC3/.*', 107] 108 109KERNEL_HEADER = [ 110 '/*\n', 111 ' * FreeRTOS Kernel V11.1.0\n', 112 ' * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n', 113 ' *\n', 114 ' * SPDX-License-Identifier: MIT\n', 115 ' *\n', 116 ' * Permission is hereby granted, free of charge, to any person obtaining a copy of\n', 117 ' * this software and associated documentation files (the "Software"), to deal in\n', 118 ' * the Software without restriction, including without limitation the rights to\n', 119 ' * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\n', 120 ' * the Software, and to permit persons to whom the Software is furnished to do so,\n', 121 ' * subject to the following conditions:\n', 122 ' *\n', 123 ' * The above copyright notice and this permission notice shall be included in all\n', 124 ' * copies or substantial portions of the Software.\n', 125 ' *\n', 126 ' * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n', 127 ' * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\n', 128 ' * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\n', 129 ' * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\n', 130 ' * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n', 131 ' * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n', 132 ' *\n', 133 ' * https://www.FreeRTOS.org\n', 134 ' * https://github.com/FreeRTOS\n', 135 ' *\n', 136 ' */\n', 137] 138 139 140FREERTOS_COPYRIGHT_REGEX = r"^(;|#)?( *(\/\*|\*|#|\/\/))? Copyright \(C\) 20\d\d Amazon.com, Inc. or its affiliates. All Rights Reserved\.( \*\/)?$" 141 142def main(): 143 parser = HeaderChecker.configArgParser() 144 args = parser.parse_args() 145 146 # Configure the checks then run 147 checker = HeaderChecker(KERNEL_HEADER, 148 copyright_regex=FREERTOS_COPYRIGHT_REGEX, 149 ignored_files=KERNEL_IGNORED_FILES, 150 ignored_ext=KERNEL_IGNORED_EXTENSIONS, 151 ignored_patterns=KERNEL_IGNORED_PATTERNS, 152 third_party_patterns=KERNEL_THIRD_PARTY_PATTERNS, 153 py_ext=KERNEL_PY_EXTENSIONS, 154 asm_ext=KERNEL_ASM_EXTENSIONS) 155 checker.ignoreFile(os.path.split(__file__)[-1]) 156 157 rc = checker.processArgs(args) 158 if rc: 159 checker.showHelp(__file__) 160 161 return rc 162 163if __name__ == '__main__': 164 exit(main()) 165