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