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