1 | #!python
|
---|
2 | # -*- coding: utf-8 -*-
|
---|
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 | # ä¸è¨èä½æ¨©è
|
---|
18 | ã¯ï¼ä»¥ä¸ã®(1)ã(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
|
---|
19 | # ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹
|
---|
20 | # å¤ã»åé
|
---|
21 | å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
|
---|
22 | # (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
|
---|
23 | # 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
|
---|
24 | # ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼
|
---|
25 | # (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
26 | # ç¨ã§ããå½¢ã§åé
|
---|
27 | å¸ããå ´åã«ã¯ï¼åé
|
---|
28 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨
|
---|
29 | # è
|
---|
30 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
|
---|
31 | # ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
32 | # (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
33 | # ç¨ã§ããªãå½¢ã§åé
|
---|
34 | å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
|
---|
35 | # ã¨ï¼
|
---|
36 | # (a) åé
|
---|
37 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è
|
---|
38 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
|
---|
39 | # ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
40 | # (b) åé
|
---|
41 | å¸ã®å½¢æ
|
---|
42 | ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSããã¸ã§ã¯ãã«
|
---|
43 | # å ±åãããã¨ï¼
|
---|
44 | # (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
|
---|
45 | # 害ãããï¼ä¸è¨èä½æ¨©è
|
---|
46 | ããã³TOPPERSããã¸ã§ã¯ããå
|
---|
47 | 責ãããã¨ï¼
|
---|
48 | # ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
|
---|
49 | # ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
|
---|
50 | ããã³TOPPERSããã¸ã§ã¯ãã
|
---|
51 | # å
|
---|
52 | 責ãããã¨ï¼
|
---|
53 | #
|
---|
54 | # æ¬ã½ããã¦ã§ã¢ã¯ï¼AUTOSARï¼AUTomotive Open System ARchitectureï¼ä»
|
---|
55 | # æ§ã«åºã¥ãã¦ããï¼ä¸è¨ã®è¨±è«¾ã¯ï¼AUTOSARã®ç¥ç財ç£æ¨©ã許諾ãããã®ã§
|
---|
56 | # ã¯ãªãï¼AUTOSARã¯ï¼AUTOSARä»æ§ã«åºã¥ããã½ããã¦ã§ã¢ãåç¨ç®çã§å©
|
---|
57 | # ç¨ããè
|
---|
58 | ã«å¯¾ãã¦ï¼AUTOSARãã¼ããã¼ã«ãªããã¨ãæ±ãã¦ããï¼
|
---|
59 | #
|
---|
60 | # æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
|
---|
61 | ã
|
---|
62 | # ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
|
---|
63 | # ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
|
---|
64 | # ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ã
|
---|
65 | # ã®è²¬ä»»ãè² ããªãï¼
|
---|
66 | #
|
---|
67 | # $Id: post_cfg.py 181 2015-06-12 10:02:03Z t_ishikawa $
|
---|
68 | #
|
---|
69 |
|
---|
70 | import subprocess
|
---|
71 | import os
|
---|
72 | import sys
|
---|
73 | import re # for regular expression
|
---|
74 | import shutil
|
---|
75 | import os.path
|
---|
76 |
|
---|
77 | # set relative path from top proj
|
---|
78 | proj_rel_dir = "../"
|
---|
79 |
|
---|
80 | # call definition file
|
---|
81 | common.Source(proj_rel_dir + "def.py")
|
---|
82 |
|
---|
83 | # path
|
---|
84 | src_abs_path = os.path.abspath(proj_rel_dir + SRCDIR)
|
---|
85 |
|
---|
86 | # call common file
|
---|
87 | common.Source(src_abs_path + "/arch/ccrh/common.py")
|
---|
88 |
|
---|
89 | #
|
---|
90 | # convert map file
|
---|
91 | #
|
---|
92 | inputfile = open("./DefaultBuild/cfg.map")
|
---|
93 | outputfile = open("cfg1_out.syms", 'w')
|
---|
94 |
|
---|
95 | r = re.compile("^\s+([0-9a-f]+)\s+[0-9a-f]+\s+\w+\s+,\w+\s+\*\s+")
|
---|
96 | line = inputfile.readline()
|
---|
97 | pre_line = line
|
---|
98 | while line:
|
---|
99 | line = line.replace('\r\n','') #delete newline
|
---|
100 | m = r.search(line)
|
---|
101 | if m:
|
---|
102 | outputfile.write(m.group(1) + " T " + pre_line + "\n")
|
---|
103 | pre_line = line
|
---|
104 | line = inputfile.readline()
|
---|
105 |
|
---|
106 | inputfile.close()
|
---|
107 | outputfile.close()
|
---|
108 |
|
---|
109 | # remove Os_Lcfg.c
|
---|
110 | if os.path.isfile('Os_Lcfg.c'):
|
---|
111 | os.remove('Os_Lcfg.c')
|
---|
112 |
|
---|
113 | #
|
---|
114 | # Execute cfg path 2
|
---|
115 | #
|
---|
116 | # make command
|
---|
117 | cfg_command = cfg + " --pass 2 " + "--kernel " + CFG_KERNEL
|
---|
118 | cfg_command += " --api-table " + cfg_api_table
|
---|
119 | cfg_command += " " + cfg_cfg1_def_tables + cfg_includes
|
---|
120 | cfg_command += " -T " + cfg_tf
|
---|
121 | cfg_command += " --ini-file " + cfg_ini_file
|
---|
122 | cfg_command += " " + cfg_input_str
|
---|
123 |
|
---|
124 | print cfg_command
|
---|
125 |
|
---|
126 | # Execute
|
---|
127 | try:
|
---|
128 | output = subprocess.check_output(cfg_command, stderr=subprocess.STDOUT,)
|
---|
129 | except subprocess.CalledProcessError, e:
|
---|
130 | print "ERROR!! : ", e.output
|
---|
131 | sys.exit()
|
---|
132 |
|
---|
133 | output.replace('\r','')
|
---|
134 | print output
|
---|
135 |
|
---|
136 | #
|
---|
137 | # mov Os_Cfg_tmp.h Os_Cfg.h
|
---|
138 | #
|
---|
139 | import filecmp
|
---|
140 | if not os.path.isfile(r'Os_Cfg.h'):
|
---|
141 | print "Rename Os_Cfg_tmp.h to Os_Cfg.h"
|
---|
142 | shutil.move("Os_Cfg_tmp.h", "Os_Cfg.h")
|
---|
143 | else:
|
---|
144 | print "compare Os_Cfg_tmp.h and Os_Cfg.h"
|
---|
145 | if not filecmp.cmp(r'Os_Cfg_tmp.h', r'Os_Cfg.h'):
|
---|
146 | print "Rename Os_Cfg_tmp.h to Os_Cfg.h"
|
---|
147 | shutil.move("Os_Cfg_tmp.h", "Os_Cfg.h")
|
---|
148 | else:
|
---|
149 | print "Delete Os_Cfg_tmp.h"
|
---|
150 | os.remove("Os_Cfg_tmp.h")
|
---|
151 |
|
---|
152 | #
|
---|
153 | # Execute cfg path 3
|
---|
154 | #
|
---|
155 | # make command
|
---|
156 | cfg_command = cfg + " --pass 3 " + "--kernel " + CFG_KERNEL
|
---|
157 | cfg_command += " --api-table " + cfg_api_table
|
---|
158 | cfg_command += " " + cfg_cfg1_def_tables + cfg_includes
|
---|
159 | cfg_command += " --rom-image cfg1_out.srec --symbol-table cfg1_out.syms"
|
---|
160 | cfg_command += " -T " + cfg_offset_tf
|
---|
161 | cfg_command += " --ini-file " + cfg_ini_file
|
---|
162 | cfg_command += " " + cfg_input_str
|
---|
163 |
|
---|
164 |
|
---|
165 | print cfg_command
|
---|
166 |
|
---|
167 | # Execute
|
---|
168 | try:
|
---|
169 | output = subprocess.check_output(cfg_command, stderr=subprocess.STDOUT,)
|
---|
170 | except subprocess.CalledProcessError, e:
|
---|
171 | print "ERROR!! : ", e.output
|
---|
172 | sys.exit()
|
---|
173 |
|
---|
174 | output.replace('\r','')
|
---|
175 | print output
|
---|
176 |
|
---|
177 | common.Source("./ldscript.py")
|
---|
178 |
|
---|