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