[117] | 1 | #!python
|
---|
| 2 | # -*- coding: euc-jp -*-
|
---|
| 3 | #
|
---|
| 4 | # TOPPERS ATK2
|
---|
| 5 | # Toyohashi Open Platform for Embedded Real-Time Systems
|
---|
| 6 | # Automotive Kernel Version 2
|
---|
| 7 | #
|
---|
| 8 | # Copyright (C) 2013-2015 by Center for Embedded Computing Systems
|
---|
| 9 | # Graduate School of Information Science, Nagoya Univ., JAPAN
|
---|
| 10 | # Copyright (C) 2013-2014 by FUJI SOFT INCORPORATED, JAPAN
|
---|
| 11 | # Copyright (C) 2013-2014 by Panasonic Advanced Technology Development Co., Ltd., JAPAN
|
---|
| 12 | # Copyright (C) 2013-2014 by Renesas Electronics Corporation, JAPAN
|
---|
| 13 | # Copyright (C) 2013-2014 by Sunny Giken Inc., JAPAN
|
---|
| 14 | # Copyright (C) 2013-2014 by TOSHIBA CORPORATION, JAPAN
|
---|
| 15 | # Copyright (C) 2013-2014 by Witz Corporation, JAPAN
|
---|
| 16 | #
|
---|
| 17 | # 上記著作権者は,以下の(1)〜(4)の条件を満たす場合に限り,本ソフトウェ
|
---|
| 18 | # ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
|
---|
| 19 | # 変・再配布(以下,利用と呼ぶ)することを無償で許諾する.
|
---|
| 20 | # (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
|
---|
| 21 | # 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
|
---|
| 22 | # スコード中に含まれていること.
|
---|
| 23 | # (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
|
---|
| 24 | # 用できる形で再配布する場合には,再配布に伴うドキュメント(利用
|
---|
| 25 | # 者マニュアルなど)に,上記の著作権表示,この利用条件および下記
|
---|
| 26 | # の無保証規定を掲載すること.
|
---|
| 27 | # (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
|
---|
| 28 | # 用できない形で再配布する場合には,次のいずれかの条件を満たすこ
|
---|
| 29 | # と.
|
---|
| 30 | # (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
|
---|
| 31 | # 作権表示,この利用条件および下記の無保証規定を掲載すること.
|
---|
| 32 | # (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに
|
---|
| 33 | # 報告すること.
|
---|
| 34 | # (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
|
---|
| 35 | # 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
|
---|
| 36 | # また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理
|
---|
| 37 | # 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
|
---|
| 38 | # 免責すること.
|
---|
| 39 | #
|
---|
| 40 | # 本ソフトウェアは,AUTOSAR(AUTomotive Open System ARchitecture)仕
|
---|
| 41 | # 様に基づいている.上記の許諾は,AUTOSARの知的財産権を許諾するもので
|
---|
| 42 | # はない.AUTOSARは,AUTOSAR仕様に基づいたソフトウェアを商用目的で利
|
---|
| 43 | # 用する者に対して,AUTOSARパートナーになることを求めている.
|
---|
| 44 | #
|
---|
| 45 | # 本ソフトウェアは,無保証で提供されているものである.上記著作権者お
|
---|
| 46 | # よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
|
---|
| 47 | # に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ
|
---|
| 48 | # アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
|
---|
| 49 | # の責任を負わない.
|
---|
| 50 | #
|
---|
| 51 | # $Id: configure_body.py 182 2015-06-24 07:14:37Z t_ishikawa $
|
---|
| 52 | #
|
---|
| 53 |
|
---|
| 54 | import os.path
|
---|
| 55 | import os
|
---|
| 56 | import shutil
|
---|
| 57 |
|
---|
| 58 | # call common file
|
---|
| 59 | common.Source(src_abs_path + "/arch/ccrh/common.py")
|
---|
| 60 |
|
---|
| 61 | src_abs_path = os.path.abspath(SRCDIR)
|
---|
| 62 | wd_abs_path = os.path.abspath('.')
|
---|
| 63 | cfg_mtsp = wd_abs_path + r"\cfg\cfg.mtsp"
|
---|
| 64 | kernel_mtsp = wd_abs_path + r"\kernel\kernel.mtsp"
|
---|
| 65 | cfg_pass4_mtsp = wd_abs_path + r"\cfg_pass4\cfg_pass4.mtsp"
|
---|
| 66 | atk2_sc3_mtpj = wd_abs_path + r"\atk2-sc3.mtpj"
|
---|
| 67 |
|
---|
| 68 | if COPY_SAMPLE1:
|
---|
| 69 | shutil.copy(src_abs_path + r'/sample/sample1.c', '.')
|
---|
| 70 | shutil.copy(src_abs_path + r'/sample/sample2.c', '.')
|
---|
| 71 | shutil.copy(src_abs_path + r'/sample/sample.h', '.')
|
---|
| 72 | shutil.copy(src_abs_path + r'/sample/sample1.h', '.')
|
---|
| 73 | shutil.copy(src_abs_path + r'/sample/sample2.h', '.')
|
---|
| 74 | shutil.copy(src_abs_path + r'/sample/sample1.arxml', '.')
|
---|
| 75 | shutil.copy(src_abs_path + r'/sample/Rte_Type.h', '.')
|
---|
| 76 | shutil.copy(src_abs_path + r'/sample/sample_asm.asm', '.')
|
---|
| 77 |
|
---|
| 78 | #
|
---|
| 79 | # close project
|
---|
| 80 | #
|
---|
| 81 | #project.Close()
|
---|
| 82 | print wd_abs_path + "\\atk2-sc3"
|
---|
| 83 | project.Create(wd_abs_path + "\\atk2-sc3",
|
---|
| 84 | MicomType.RH850,
|
---|
| 85 | TARGET_MCU,
|
---|
| 86 | ProjectKind.Empty,
|
---|
| 87 | Compiler.CC_RH,
|
---|
| 88 | False)
|
---|
| 89 |
|
---|
| 90 | project.Create(wd_abs_path + "\\cfg\\cfg",
|
---|
| 91 | MicomType.RH850,
|
---|
| 92 | TARGET_MCU,
|
---|
| 93 | ProjectKind.Empty,
|
---|
| 94 | Compiler.CC_RH,
|
---|
| 95 | True)
|
---|
| 96 |
|
---|
| 97 | project.Create(wd_abs_path + "\\kernel\\kernel",
|
---|
| 98 | MicomType.RH850,
|
---|
| 99 | TARGET_MCU,
|
---|
| 100 | ProjectKind.Library,
|
---|
| 101 | Compiler.CC_RH,
|
---|
| 102 | True)
|
---|
| 103 |
|
---|
| 104 | project.Create(wd_abs_path + "\\cfg_pass4\\cfg_pass4",
|
---|
| 105 | MicomType.RH850,
|
---|
| 106 | TARGET_MCU,
|
---|
| 107 | ProjectKind.Empty,
|
---|
| 108 | Compiler.CC_RH,
|
---|
| 109 | True)
|
---|
| 110 |
|
---|
| 111 | #
|
---|
| 112 | # Change debug tool
|
---|
| 113 | #
|
---|
| 114 | debugger.DebugTool.Change(DebugTool.E1Lpd)
|
---|
| 115 |
|
---|
| 116 | #
|
---|
| 117 | # Add files for atk2-sc3 project
|
---|
| 118 | #
|
---|
| 119 | for file in app_app_files:
|
---|
| 120 | project.File.Add(wd_abs_path + "\\" + file, u"app")
|
---|
| 121 |
|
---|
| 122 | for file in app_sysmod_files:
|
---|
| 123 | project.File.Add(src_abs_path + "\\" + file, u"sysmod")
|
---|
| 124 |
|
---|
| 125 | for file in app_library_files:
|
---|
| 126 | project.File.Add(src_abs_path + "\\" + file, u"library")
|
---|
| 127 |
|
---|
| 128 | for file in app_configuration_files:
|
---|
| 129 | if file == 'kernel_mem.c':
|
---|
| 130 | project.File.Add(wd_abs_path + "\\cfg_pass4\\" + file, u"configuration4")
|
---|
| 131 | else:
|
---|
| 132 | project.File.Add(wd_abs_path + "\\cfg\\" + file, u"configuration")
|
---|
| 133 |
|
---|
| 134 | str = src_abs_path + '\\' + statup_file
|
---|
| 135 | project.File.Add(str, u"スタートアップ")
|
---|
| 136 |
|
---|
| 137 | #
|
---|
| 138 | # Add files fot cfg project
|
---|
| 139 | #
|
---|
| 140 | project.Change(cfg_mtsp)
|
---|
| 141 |
|
---|
| 142 | file_list = project.File.Information()
|
---|
| 143 | for file in file_list:
|
---|
| 144 | project.File.Remove(file)
|
---|
| 145 |
|
---|
| 146 | str = src_abs_path + '\\' + statup_file
|
---|
| 147 | project.File.Add(str, u"スタートアップ")
|
---|
| 148 |
|
---|
| 149 | for file in cfg_configuration_files:
|
---|
| 150 | project.File.Add(wd_abs_path + "\\cfg\\" + file, u"configuration")
|
---|
| 151 |
|
---|
| 152 | #
|
---|
| 153 | # Add files fot kernel project
|
---|
| 154 | #
|
---|
| 155 | project.Change(kernel_mtsp)
|
---|
| 156 |
|
---|
| 157 | file_list = project.File.Information()
|
---|
| 158 | for file in file_list:
|
---|
| 159 | project.File.Remove(file)
|
---|
| 160 |
|
---|
| 161 | for file in kernel_kernel_files:
|
---|
| 162 | project.File.Add(src_abs_path + "\\" + file, u"kernel")
|
---|
| 163 |
|
---|
| 164 | for file in kernel_arch_files:
|
---|
| 165 | project.File.Add(src_abs_path + "\\" + file, u"arch")
|
---|
| 166 |
|
---|
| 167 | for file in kernel_target_files:
|
---|
| 168 | project.File.Add(src_abs_path + "\\" + file, u"target")
|
---|
| 169 |
|
---|
| 170 | #
|
---|
| 171 | # Add files for cfg_pass4 project
|
---|
| 172 | #
|
---|
| 173 | project.Change(cfg_pass4_mtsp)
|
---|
| 174 |
|
---|
| 175 | file_list = project.File.Information()
|
---|
| 176 | for file in file_list:
|
---|
| 177 | project.File.Remove(file)
|
---|
| 178 |
|
---|
| 179 | for file in app_app_files:
|
---|
| 180 | project.File.Add(wd_abs_path + "\\" + file, u"app")
|
---|
| 181 |
|
---|
| 182 | for file in app_sysmod_files:
|
---|
| 183 | project.File.Add(src_abs_path + "\\" + file, u"sysmod")
|
---|
| 184 |
|
---|
| 185 | for file in app_library_files:
|
---|
| 186 | project.File.Add(src_abs_path + "\\" + file, u"library")
|
---|
| 187 |
|
---|
| 188 | for file in app_configuration_files:
|
---|
| 189 | if file == 'kernel_mem.c':
|
---|
| 190 | file = 'kernel_mem2.c'
|
---|
| 191 | project.File.Add(wd_abs_path + "\\cfg\\" + file, u"configuration")
|
---|
| 192 |
|
---|
| 193 | str = src_abs_path + '\\' + statup_file
|
---|
| 194 | project.File.Add(str, u"スタートアップ")
|
---|
| 195 |
|
---|
| 196 | project.Close(True)
|
---|
| 197 |
|
---|
| 198 | #
|
---|
| 199 | # Modify atk2-sc3.mtpfj
|
---|
| 200 | #
|
---|
| 201 | inputstr = ReadFile('atk2-sc3.mtpj')
|
---|
| 202 |
|
---|
| 203 | # Set cx include path
|
---|
| 204 | inputstr = NewSetCCRHIncludes(inputstr, atk2_sc3_rel_includes, INCLUDES, SRCDIR)
|
---|
| 205 | # Set libary path and file
|
---|
| 206 | #inputstr = NewSetLibIncludes(inputstr, atk2_sc3_lib_includes, [], SRCDIR)
|
---|
| 207 | inputstr = NewSetLibFiles(inputstr, atk2_sc3_lib_files)
|
---|
| 208 | # change Option
|
---|
| 209 | inputstr = ChangeItemXml(inputstr, 'OutputMessageFormat-0', '%Program% %Options%')
|
---|
| 210 | #inputstr = ChangeItemXml(inputstr, 'UseProEpiRuntimeLibrary-0', 'False')
|
---|
| 211 | #inputstr = ChangeItemXml(inputstr, 'HexadecimalFileFormat-0','MotrolaSType32Bit')
|
---|
| 212 | inputstr = ChangeItemXml(inputstr, 'HexOptionOutputFileName-0', r'%ProjectName%.srec')
|
---|
| 213 | #inputstr = ChangeItemXml(inputstr, 'OutputLinkMapFile-0', 'True')
|
---|
| 214 | inputstr = ChangeItemXml(inputstr, 'LinkOptionPadding-0', 'True')
|
---|
| 215 | inputstr = ChangeItemXml(inputstr, 'LinkOptionShowSymbol-0', 'True')
|
---|
| 216 | #inputstr = ChangeItemXml(inputstr, 'OutputSymbolInformationToLinkMapFile-0', 'True')
|
---|
| 217 | inputstr = ChangeItemXml(inputstr, 'DebuggerProperty-EssentialProperty-Clock-MainClockGeneration', MAIN_CLK)
|
---|
| 218 | inputstr = ChangeItemXml(inputstr, 'GeneralOptionXreserveR2-0', 'True')
|
---|
| 219 | inputstr = ChangeItemXml(inputstr, 'COptionOsize-0', 'AdvancedSpeed')
|
---|
| 220 | # Change linkoption if link_option is exist.
|
---|
| 221 | try:
|
---|
| 222 | link_option = link_option
|
---|
| 223 | inputstr = ChangeItemXml(inputstr, 'LinkOptionStart-0', link_option)
|
---|
| 224 | except NameError:
|
---|
| 225 | link_option = ''
|
---|
| 226 |
|
---|
| 227 |
|
---|
| 228 |
|
---|
| 229 | # Set user macro definitions
|
---|
| 230 | inputstr = NewSetDefine(inputstr, USER_MACRO)
|
---|
| 231 |
|
---|
| 232 | # Set Prebuild/Postbuile
|
---|
| 233 | # inputstr = NewSetPrebuild(inputstr, atk2_sc3_pre_python_files, "./")
|
---|
| 234 |
|
---|
| 235 | WriteFile('atk2-sc3.mtpj', inputstr)
|
---|
| 236 |
|
---|
| 237 | #
|
---|
| 238 | # Modify ./cfg/cfg.mtsp
|
---|
| 239 | #
|
---|
| 240 | inputstr = ReadFile('./cfg/cfg.mtsp')
|
---|
| 241 |
|
---|
| 242 | # Set cx include path
|
---|
| 243 | inputstr = NewSetCCRHIncludes(inputstr, cfg_rel_includes, INCLUDES, "../" + SRCDIR)
|
---|
| 244 |
|
---|
| 245 | # change Option
|
---|
| 246 | inputstr = ChangeItemXml(inputstr, 'OutputMessageFormat-0', '%Program% %Options%')
|
---|
| 247 | #inputstr = ChangeItemXml(inputstr, 'UseProEpiRuntimeLibrary-0', 'False')
|
---|
| 248 | #inputstr = ChangeItemXml(inputstr, 'HexadecimalFileFormat-0','MotrolaSType32Bit')
|
---|
| 249 | inputstr = ChangeItemXml(inputstr, 'HexOptionOutputFileName-0', 'cfg1_out.srec')
|
---|
| 250 | #inputstr = ChangeItemXml(inputstr, 'OutputLinkMapFile-0', 'True')
|
---|
| 251 | inputstr = ChangeItemXml(inputstr, 'LinkOptionShowSymbol-0', 'True')
|
---|
| 252 | inputstr = ChangeItemXml(inputstr, 'HexOptionOutputFolder-0', '.')
|
---|
| 253 |
|
---|
| 254 | # Set Prebuild/Postbuile
|
---|
| 255 | inputstr = NewSetPrebuild(inputstr, cfg_pre_python_files, "../" + SRCDIR)
|
---|
| 256 | inputstr = NewSetPostbuild(inputstr, cfg_post_python_files, "../" + SRCDIR)
|
---|
| 257 |
|
---|
| 258 | # Set user macro definitions
|
---|
| 259 | inputstr = NewSetDefine(inputstr, USER_MACRO)
|
---|
| 260 |
|
---|
| 261 | WriteFile('./cfg/cfg.mtsp', inputstr)
|
---|
| 262 |
|
---|
| 263 | #
|
---|
| 264 | # Mofity ./kernel/kernel.mtsp
|
---|
| 265 | #
|
---|
| 266 | inputstr = ReadFile('./kernel/kernel.mtsp')
|
---|
| 267 |
|
---|
| 268 | # Add user macro definitions
|
---|
| 269 | kernel_define = kernel_define + USER_MACRO
|
---|
| 270 |
|
---|
| 271 | # Set cx include path
|
---|
| 272 | inputstr = NewSetCCRHIncludes(inputstr, kernel_rel_includes, INCLUDES, "../" + SRCDIR)
|
---|
| 273 | # Set cx define
|
---|
| 274 | inputstr = NewSetDefine(inputstr, kernel_define)
|
---|
| 275 | # Set cx addition option
|
---|
| 276 | inputstr = NewSetCAddOpt(inputstr, kernel_c_addopt)
|
---|
| 277 | inputstr = NewSetAsmAddOpt(inputstr, kernel_asm_addopt)
|
---|
| 278 |
|
---|
| 279 | # change Option
|
---|
| 280 | inputstr = ChangeItemXml(inputstr, 'OutputMessageFormat-0', '%Program% %Options%')
|
---|
| 281 | #inputstr = ChangeItemXml(inputstr, 'UseProEpiRuntimeLibrary-0', 'False')
|
---|
| 282 | inputstr = ChangeItemXml(inputstr, 'GeneralOptionXreserveR2-0', 'True')
|
---|
| 283 | inputstr = ChangeItemXml(inputstr, 'COptionOsize-0', 'AdvancedSpeed')
|
---|
| 284 |
|
---|
| 285 | WriteFile('./kernel/kernel.mtsp', inputstr)
|
---|
| 286 |
|
---|
| 287 | #
|
---|
| 288 | # Modify cfg_pass4.mtpfj
|
---|
| 289 | #
|
---|
| 290 | inputstr = ReadFile('./cfg_pass4/cfg_pass4.mtsp')
|
---|
| 291 |
|
---|
| 292 | # Set cx include path
|
---|
| 293 | inputstr = NewSetCCRHIncludes(inputstr, kernel_rel_includes, INCLUDES, "../" + SRCDIR)
|
---|
| 294 | # Set libary path and file
|
---|
| 295 | #inputstr = NewSetLibIncludes(inputstr, atk2_sc3_lib_includes, [], SRCDIR)
|
---|
| 296 | inputstr = NewSetLibFiles(inputstr, cfg_pass4_lib_files)
|
---|
| 297 | # change Option
|
---|
| 298 | inputstr = ChangeItemXml(inputstr, 'OutputMessageFormat-0', '%Program% %Options%')
|
---|
| 299 | #inputstr = ChangeItemXml(inputstr, 'UseProEpiRuntimeLibrary-0', 'False')
|
---|
| 300 | #inputstr = ChangeItemXml(inputstr, 'HexadecimalFileFormat-0','MotrolaSType32Bit')
|
---|
| 301 | inputstr = ChangeItemXml(inputstr, 'HexOptionOutputFileName-0', r'%ProjectName%.srec')
|
---|
| 302 | #inputstr = ChangeItemXml(inputstr, 'OutputLinkMapFile-0', 'True')
|
---|
| 303 | inputstr = ChangeItemXml(inputstr, 'LinkOptionPadding-0', 'True')
|
---|
| 304 | inputstr = ChangeItemXml(inputstr, 'LinkOptionShowSymbol-0', 'True')
|
---|
| 305 | #inputstr = ChangeItemXml(inputstr, 'OutputSymbolInformationToLinkMapFile-0', 'True')
|
---|
| 306 | inputstr = ChangeItemXml(inputstr, 'DebuggerProperty-EssentialProperty-Clock-MainClockGeneration', MAIN_CLK)
|
---|
| 307 | inputstr = ChangeItemXml(inputstr, 'GeneralOptionXreserveR2-0', 'True')
|
---|
| 308 | inputstr = ChangeItemXml(inputstr, 'COptionOsize-0', 'AdvancedSpeed')
|
---|
| 309 | # Change linkoption if link_option is exist.
|
---|
| 310 | try:
|
---|
| 311 | link_option = link_option
|
---|
| 312 | inputstr = ChangeItemXml(inputstr, 'LinkOptionStart-0', link_option)
|
---|
| 313 | except NameError:
|
---|
| 314 | link_option = ''
|
---|
| 315 |
|
---|
| 316 | # Set user macro definitions
|
---|
| 317 | inputstr = NewSetDefine(inputstr, USER_MACRO)
|
---|
| 318 |
|
---|
| 319 | # Set Prebuild/Postbuile
|
---|
| 320 | inputstr = NewSetPostbuild(inputstr, cfg_pass4_post_python_files, "../" + SRCDIR)
|
---|
| 321 |
|
---|
| 322 | WriteFile('./cfg_pass4/cfg_pass4.mtsp', inputstr)
|
---|
| 323 |
|
---|
| 324 | project.Open(wd_abs_path + r'\atk2-sc3.mtpj')
|
---|
| 325 | project.Change(atk2_sc3_mtpj)
|
---|