2 # * FreeRTOS Kernel V10.3.1
3 # * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5 # * Permission is hereby granted, free of charge, to any person obtaining a copy of
6 # * this software and associated documentation files (the "Software"), to deal in
7 # * the Software without restriction, including without limitation the rights to
8 # * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 # * the Software, and to permit persons to whom the Software is furnished to do so,
10 # * subject to the following conditions:
12 # * The above copyright notice and this permission notice shall be included in all
13 # * copies or substantial portions of the Software.
15 # * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 # * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 # * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 # * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 # * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 # * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 # * http://www.FreeRTOS.org
23 # * http://aws.amazon.com/freertos
25 # * 1 tab == 4 spaces!
31 _THIS_FILE_DIRECTORY_ = os.path.dirname(os.path.realpath(__file__))
32 _FREERTOS_PORTABLE_DIRECTORY_ = os.path.dirname(_THIS_FILE_DIRECTORY_)
34 _COMPILERS_ = ['GCC', 'IAR']
35 _ARCH_NS_ = ['ARM_CM33', 'ARM_CM33_NTZ', 'ARM_CM23', 'ARM_CM23_NTZ']
36 _ARCH_S_ = ['ARM_CM33', 'ARM_CM23']
38 _SUPPORTED_CONFIGS_ = {
39 'GCC' : ['ARM_CM33', 'ARM_CM33_NTZ', 'ARM_CM23', 'ARM_CM23_NTZ'],
40 'IAR' : ['ARM_CM33', 'ARM_CM33_NTZ', 'ARM_CM23', 'ARM_CM23_NTZ']
43 # Files to be complied in the Secure Project
44 _SECURE_FILE_PATHS_ = [
45 os.path.join('secure', 'context'),
46 os.path.join('secure', 'context', 'portable', '_COMPILER_ARCH_'),
47 os.path.join('secure', 'heap'),
48 os.path.join('secure', 'init'),
49 os.path.join('secure', 'macros')
52 # Files to be complied in the Non-Secure Project
53 _NONSECURE_FILE_PATHS_ = [
55 os.path.join('non_secure', 'portable', '_COMPILER_ARCH_')
59 def is_supported_config(compiler, arch):
60 return arch in _SUPPORTED_CONFIGS_[compiler]
63 def copy_files_in_dir(src_abs_path, dst_abs_path):
64 for src_file in os.listdir(src_abs_path):
65 src_file_abs_path = os.path.join(src_abs_path, src_file)
66 if os.path.isfile(src_file_abs_path) and src_file != 'ReadMe.txt':
67 if not os.path.exists(dst_abs_path):
68 os.makedirs(dst_abs_path)
69 print('Copying {}...'.format(os.path.basename(src_file_abs_path)))
70 shutil.copy2(src_file_abs_path, dst_abs_path)
73 def copy_files_for_compiler_and_arch(compiler, arch, src_paths, dst_path):
74 _COMPILER_ARCH_ = os.path.join(compiler, arch)
75 for src_path in src_paths:
76 src_path_sanitized = src_path.replace('_COMPILER_ARCH_', _COMPILER_ARCH_ )
78 src_abs_path = os.path.join(_THIS_FILE_DIRECTORY_, src_path_sanitized)
79 dst_abs_path = os.path.join(_FREERTOS_PORTABLE_DIRECTORY_, _COMPILER_ARCH_, dst_path)
81 copy_files_in_dir(src_abs_path, dst_abs_path)
86 for compiler in _COMPILERS_:
88 if is_supported_config(compiler, arch):
89 copy_files_for_compiler_and_arch(compiler, arch, _SECURE_FILE_PATHS_, 'secure')
91 # Copy Non-Secure Files
92 for compiler in _COMPILERS_:
93 for arch in _ARCH_NS_:
94 if is_supported_config(compiler, arch):
95 copy_files_for_compiler_and_arch(compiler, arch, _NONSECURE_FILE_PATHS_, 'non_secure')
102 if __name__ == '__main__':