]> begriffs open source - freertos/blob - portable/ARMv8M/copy_files.py
Cortex-M35P: Add Cortex-M35P port (#631)
[freertos] / portable / ARMv8M / copy_files.py
1 #/*
2 # * FreeRTOS Kernel <DEVELOPMENT BRANCH>
3 # * Copyright (C) 2021 Amazon.com, Inc. or its affiliates.  All Rights Reserved.
4 # *
5 # * SPDX-License-Identifier: MIT
6 # *
7 # * Permission is hereby granted, free of charge, to any person obtaining a copy of
8 # * this software and associated documentation files (the "Software"), to deal in
9 # * the Software without restriction, including without limitation the rights to
10 # * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
11 # * the Software, and to permit persons to whom the Software is furnished to do so,
12 # * subject to the following conditions:
13 # *
14 # * The above copyright notice and this permission notice shall be included in all
15 # * copies or substantial portions of the Software.
16 # *
17 # * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 # * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
19 # * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20 # * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21 # * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 # * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 # *
24 # * https://www.FreeRTOS.org
25 # * https://github.com/FreeRTOS
26 # *
27 # */
28
29 import os
30 import shutil
31
32 _THIS_FILE_DIRECTORY_ = os.path.dirname(os.path.realpath(__file__))
33 _FREERTOS_PORTABLE_DIRECTORY_ = os.path.dirname(_THIS_FILE_DIRECTORY_)
34
35 _COMPILERS_ = ['GCC', 'IAR']
36 _ARCH_NS_ = ['ARM_CM85', 'ARM_CM85_NTZ', 'ARM_CM55', 'ARM_CM55_NTZ', 'ARM_CM35P', 'ARM_CM35P_NTZ', 'ARM_CM33', 'ARM_CM33_NTZ', 'ARM_CM23', 'ARM_CM23_NTZ']
37 _ARCH_S_ = ['ARM_CM85', 'ARM_CM55', 'ARM_CM35P', 'ARM_CM33', 'ARM_CM23']
38
39 # Files to be compiled in the Secure Project
40 _SECURE_COMMON_FILE_PATHS_ = [
41     os.path.join('secure', 'context'),
42     os.path.join('secure', 'heap'),
43     os.path.join('secure', 'init'),
44     os.path.join('secure', 'macros')
45 ]
46
47 _SECURE_PORTABLE_FILE_PATHS_ = {
48     'GCC':{
49         'ARM_CM23' :[os.path.join('secure', 'context', 'portable', 'GCC', 'ARM_CM23')],
50         'ARM_CM33' :[os.path.join('secure', 'context', 'portable', 'GCC', 'ARM_CM33')],
51         'ARM_CM35P':[os.path.join('secure', 'context', 'portable', 'GCC', 'ARM_CM33')],
52         'ARM_CM55' :[os.path.join('secure', 'context', 'portable', 'GCC', 'ARM_CM33')],
53         'ARM_CM85' :[os.path.join('secure', 'context', 'portable', 'GCC', 'ARM_CM33')]
54     },
55     'IAR':{
56         'ARM_CM23' :[os.path.join('secure', 'context', 'portable', 'IAR', 'ARM_CM23')],
57         'ARM_CM33' :[os.path.join('secure', 'context', 'portable', 'IAR', 'ARM_CM33')],
58         'ARM_CM35P':[os.path.join('secure', 'context', 'portable', 'IAR', 'ARM_CM33')],
59         'ARM_CM55' :[os.path.join('secure', 'context', 'portable', 'IAR', 'ARM_CM33')],
60         'ARM_CM85' :[os.path.join('secure', 'context', 'portable', 'IAR', 'ARM_CM33')]
61     }
62 }
63
64 # Files to be compiled in the Non-Secure Project
65 _NONSECURE_COMMON_FILE_PATHS_ = [
66     'non_secure'
67 ]
68
69 _NONSECURE_PORTABLE_FILE_PATHS_ = {
70     'GCC':{
71         'ARM_CM23'      : [os.path.join('non_secure', 'portable', 'GCC', 'ARM_CM23')],
72         'ARM_CM23_NTZ'  : [os.path.join('non_secure', 'portable', 'GCC', 'ARM_CM23_NTZ')],
73         'ARM_CM33'      : [os.path.join('non_secure', 'portable', 'GCC', 'ARM_CM33')],
74         'ARM_CM33_NTZ'  : [os.path.join('non_secure', 'portable', 'GCC', 'ARM_CM33_NTZ')],
75         'ARM_CM35P'     : [os.path.join('non_secure', 'portable', 'GCC', 'ARM_CM33', 'portasm.c'),
76                            os.path.join('non_secure', 'portable', 'GCC', 'ARM_CM35P', 'portmacro.h')],
77         'ARM_CM35P_NTZ' : [os.path.join('non_secure', 'portable', 'GCC', 'ARM_CM33_NTZ', 'portasm.c'),
78                            os.path.join('non_secure', 'portable', 'GCC', 'ARM_CM35P', 'portmacro.h')],
79         'ARM_CM55'      : [os.path.join('non_secure', 'portable', 'GCC', 'ARM_CM33', 'portasm.c'),
80                            os.path.join('non_secure', 'portable', 'GCC', 'ARM_CM55', 'portmacro.h')],
81         'ARM_CM55_NTZ'  : [os.path.join('non_secure', 'portable', 'GCC', 'ARM_CM33_NTZ', 'portasm.c'),
82                            os.path.join('non_secure', 'portable', 'GCC', 'ARM_CM55', 'portmacro.h')],
83         'ARM_CM85'      : [os.path.join('non_secure', 'portable', 'GCC', 'ARM_CM33', 'portasm.c'),
84                            os.path.join('non_secure', 'portable', 'GCC', 'ARM_CM85', 'portmacro.h')],
85         'ARM_CM85_NTZ'  : [os.path.join('non_secure', 'portable', 'GCC', 'ARM_CM33_NTZ', 'portasm.c'),
86                            os.path.join('non_secure', 'portable', 'GCC', 'ARM_CM85', 'portmacro.h')]
87     },
88     'IAR':{
89         'ARM_CM23'      : [os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM23')],
90         'ARM_CM23_NTZ'  : [os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM23_NTZ')],
91         'ARM_CM33'      : [os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM33')],
92         'ARM_CM33_NTZ'  : [os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM33_NTZ')],
93         'ARM_CM35P'     : [os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM33', 'portasm.s'),
94                            os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM35P', 'portmacro.h')],
95         'ARM_CM35P_NTZ' : [os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM33_NTZ', 'portasm.s'),
96                            os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM35P', 'portmacro.h')],
97         'ARM_CM55'      : [os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM33', 'portasm.s'),
98                            os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM55', 'portmacro.h')],
99         'ARM_CM55_NTZ'  : [os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM33_NTZ', 'portasm.s'),
100                            os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM55', 'portmacro.h')],
101         'ARM_CM85'      : [os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM33', 'portasm.s'),
102                            os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM85', 'portmacro.h')],
103         'ARM_CM85_NTZ'  : [os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM33_NTZ', 'portasm.s'),
104                            os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM85', 'portmacro.h')]
105     },
106 }
107
108
109 def copy_files_in_dir(src_abs_path, dst_abs_path):
110     if os.path.isfile(src_abs_path):
111         print('Src: {}'.format(src_abs_path))
112         print('Dst: {}\n'.format(dst_abs_path))
113         shutil.copy2(src_abs_path, dst_abs_path)
114     else:
115         for src_file in os.listdir(src_abs_path):
116             src_file_abs_path = os.path.join(src_abs_path, src_file)
117             if os.path.isfile(src_file_abs_path) and src_file != 'ReadMe.txt':
118                 if not os.path.exists(dst_abs_path):
119                     os.makedirs(dst_abs_path)
120                 print('Src: {}'.format(src_file_abs_path))
121                 print('Dst: {}\n'.format(dst_abs_path))
122                 shutil.copy2(src_file_abs_path, dst_abs_path)
123
124
125 def copy_common_files_for_compiler_and_arch(compiler, arch, src_paths, dst_path):
126     for src_path in src_paths:
127
128         src_abs_path = os.path.join(_THIS_FILE_DIRECTORY_, src_path)
129         dst_abs_path = os.path.join(_FREERTOS_PORTABLE_DIRECTORY_, compiler, arch, dst_path)
130
131         copy_files_in_dir(src_abs_path, dst_abs_path)
132
133
134 def copy_portable_files_for_compiler_and_arch(compiler, arch, src_paths, dst_path):
135     for src_path in src_paths[compiler][arch]:
136
137         src_abs_path = os.path.join(_THIS_FILE_DIRECTORY_, src_path)
138         dst_abs_path = os.path.join(_FREERTOS_PORTABLE_DIRECTORY_, compiler, arch, dst_path)
139
140         copy_files_in_dir(src_abs_path, dst_abs_path)
141
142
143 def copy_files():
144     # Copy Secure Files
145     for compiler in _COMPILERS_:
146         for arch in _ARCH_S_:
147             copy_common_files_for_compiler_and_arch(compiler, arch, _SECURE_COMMON_FILE_PATHS_, 'secure')
148             copy_portable_files_for_compiler_and_arch(compiler, arch, _SECURE_PORTABLE_FILE_PATHS_, 'secure')
149
150     # Copy Non-Secure Files
151     for compiler in _COMPILERS_:
152         for arch in _ARCH_NS_:
153             copy_common_files_for_compiler_and_arch(compiler, arch, _NONSECURE_COMMON_FILE_PATHS_, 'non_secure')
154             copy_portable_files_for_compiler_and_arch(compiler, arch, _NONSECURE_PORTABLE_FILE_PATHS_, 'non_secure')
155
156
157 def main():
158     copy_files()
159
160
161 if __name__ == '__main__':
162     main()