[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-2014 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: post_cfg.py 181 2015-06-12 10:02:03Z t_ishikawa $
|
---|
| 52 | #
|
---|
| 53 |
|
---|
| 54 | import subprocess
|
---|
| 55 | import os
|
---|
| 56 | import sys
|
---|
| 57 | import re # for regular expression
|
---|
| 58 | import shutil
|
---|
| 59 | import os.path
|
---|
| 60 |
|
---|
| 61 | # set relative path from top proj
|
---|
| 62 | proj_rel_dir = "../"
|
---|
| 63 |
|
---|
| 64 | # call definition file
|
---|
| 65 | common.Source(proj_rel_dir + "def.py")
|
---|
| 66 |
|
---|
| 67 | # path
|
---|
| 68 | src_abs_path = os.path.abspath(proj_rel_dir + SRCDIR)
|
---|
| 69 |
|
---|
| 70 | # call common file
|
---|
| 71 | common.Source(src_abs_path + "/arch/ccrh/common.py")
|
---|
| 72 |
|
---|
| 73 | #
|
---|
| 74 | # convert map file
|
---|
| 75 | #
|
---|
| 76 | inputfile = open("./DefaultBuild/cfg.map")
|
---|
| 77 | outputfile = open("cfg1_out.syms", 'w')
|
---|
| 78 |
|
---|
| 79 | r = re.compile("^\s+([0-9a-f]+)\s+[0-9a-f]+\s+\w+\s+,\w+\s+\*\s+")
|
---|
| 80 | line = inputfile.readline()
|
---|
| 81 | pre_line = line
|
---|
| 82 | while line:
|
---|
| 83 | line = line.replace('\r\n','') #delete newline
|
---|
| 84 | m = r.search(line)
|
---|
| 85 | if m:
|
---|
| 86 | outputfile.write(m.group(1) + " T " + pre_line + "\n")
|
---|
| 87 | pre_line = line
|
---|
| 88 | line = inputfile.readline()
|
---|
| 89 |
|
---|
| 90 | inputfile.close()
|
---|
| 91 | outputfile.close()
|
---|
| 92 |
|
---|
| 93 | # remove Os_Lcfg.c
|
---|
| 94 | if os.path.isfile('Os_Lcfg.c'):
|
---|
| 95 | os.remove('Os_Lcfg.c')
|
---|
| 96 |
|
---|
| 97 | #
|
---|
| 98 | # Execute cfg path 2
|
---|
| 99 | #
|
---|
| 100 | # make command
|
---|
| 101 | cfg_command = cfg + " --pass 2 " + "--kernel " + CFG_KERNEL
|
---|
| 102 | cfg_command += " --api-table " + cfg_api_table
|
---|
| 103 | cfg_command += " " + cfg_cfg1_def_tables + cfg_includes
|
---|
| 104 | cfg_command += " -T " + cfg_tf
|
---|
| 105 | cfg_command += " --ini-file " + cfg_ini_file
|
---|
| 106 | cfg_command += " " + cfg_input_str
|
---|
| 107 |
|
---|
| 108 | print cfg_command
|
---|
| 109 |
|
---|
| 110 | # Execute
|
---|
| 111 | try:
|
---|
| 112 | output = subprocess.check_output(cfg_command, stderr=subprocess.STDOUT,)
|
---|
| 113 | except subprocess.CalledProcessError, e:
|
---|
| 114 | print "ERROR!! : ", e.output
|
---|
| 115 | sys.exit()
|
---|
| 116 |
|
---|
| 117 | output.replace('\r','')
|
---|
| 118 | print output
|
---|
| 119 |
|
---|
| 120 | #
|
---|
| 121 | # mov Os_Cfg_tmp.h Os_Cfg.h
|
---|
| 122 | #
|
---|
| 123 | import filecmp
|
---|
| 124 | if not os.path.isfile(r'Os_Cfg.h'):
|
---|
| 125 | print "Rename Os_Cfg_tmp.h to Os_Cfg.h"
|
---|
| 126 | shutil.move("Os_Cfg_tmp.h", "Os_Cfg.h")
|
---|
| 127 | else:
|
---|
| 128 | print "compare Os_Cfg_tmp.h and Os_Cfg.h"
|
---|
| 129 | if not filecmp.cmp(r'Os_Cfg_tmp.h', r'Os_Cfg.h'):
|
---|
| 130 | print "Rename Os_Cfg_tmp.h to Os_Cfg.h"
|
---|
| 131 | shutil.move("Os_Cfg_tmp.h", "Os_Cfg.h")
|
---|
| 132 | else:
|
---|
| 133 | print "Delete Os_Cfg_tmp.h"
|
---|
| 134 | os.remove("Os_Cfg_tmp.h")
|
---|
| 135 |
|
---|
| 136 | #
|
---|
| 137 | # Execute cfg path 3
|
---|
| 138 | #
|
---|
| 139 | # make command
|
---|
| 140 | cfg_command = cfg + " --pass 3 " + "--kernel " + CFG_KERNEL
|
---|
| 141 | cfg_command += " --api-table " + cfg_api_table
|
---|
| 142 | cfg_command += " " + cfg_cfg1_def_tables + cfg_includes
|
---|
| 143 | cfg_command += " --rom-image cfg1_out.srec --symbol-table cfg1_out.syms"
|
---|
| 144 | cfg_command += " -T " + cfg_offset_tf
|
---|
| 145 | cfg_command += " --ini-file " + cfg_ini_file
|
---|
| 146 | cfg_command += " " + cfg_input_str
|
---|
| 147 |
|
---|
| 148 |
|
---|
| 149 | print cfg_command
|
---|
| 150 |
|
---|
| 151 | # Execute
|
---|
| 152 | try:
|
---|
| 153 | output = subprocess.check_output(cfg_command, stderr=subprocess.STDOUT,)
|
---|
| 154 | except subprocess.CalledProcessError, e:
|
---|
| 155 | print "ERROR!! : ", e.output
|
---|
| 156 | sys.exit()
|
---|
| 157 |
|
---|
| 158 | output.replace('\r','')
|
---|
| 159 | print output
|
---|
| 160 |
|
---|
| 161 | common.Source("./ldscript.py")
|
---|
| 162 |
|
---|