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