[172] | 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-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 | # ä¸è¨èä½æ¨©è
|
---|
| 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: common.py 182 2015-06-24 07:14:37Z t_ishikawa $
|
---|
| 68 | #
|
---|
| 69 |
|
---|
| 70 | #
|
---|
| 71 | # variable definition
|
---|
| 72 | #
|
---|
| 73 | INCLUDES = []
|
---|
| 74 | CFG1_DEF_TABLES = []
|
---|
| 75 |
|
---|
| 76 | #
|
---|
| 77 | # set cfg and cfg kernel param
|
---|
| 78 | #
|
---|
| 79 | CFG = SRCDIR + "cfg/cfg/cfg.exe"
|
---|
| 80 | CFG_KERNEL = "atk2"
|
---|
| 81 |
|
---|
| 82 | #
|
---|
| 83 | # files for each project
|
---|
| 84 | #
|
---|
| 85 | app_files = []
|
---|
| 86 | app_configuration_files = ['Os_Lcfg_asm.asm', 'Os_Lcfg.c', 'kernel_mem.c', 'ioc.c']
|
---|
| 87 | app_sysmod_files = ['sysmod/banner.c', 'sysmod/serial.c', 'sysmod/syslog.c']
|
---|
| 88 | app_library_files = ['library/log_output.c', 'library/strerror.c', 'library/t_perror.c', 'library/vasyslog.c']
|
---|
| 89 |
|
---|
| 90 | kernel_kernel_files = ['kernel/alarm.c','kernel/counter.c','kernel/counter_manage.c','kernel/event.c','kernel/interrupt.c','kernel/interrupt_manage.c','kernel/osctl.c','kernel/osctl_manage.c','kernel/resource.c','kernel/scheduletable.c','kernel/task.c','kernel/task_manage.c','kernel/ioc_manage.c','kernel/memory.c','kernel/osap.c','kernel/svc_table.c']
|
---|
| 91 |
|
---|
| 92 | cfg_files = []
|
---|
| 93 | cfg_configuration_files = ['cfg1_out.c']
|
---|
| 94 |
|
---|
| 95 | #
|
---|
| 96 | # pre/postbuiled file
|
---|
| 97 | #
|
---|
| 98 | cfg_pre_python_files = ['arch/ccrh/pre_cfg.py']
|
---|
| 99 | cfg_post_python_files = ['arch/ccrh/post_cfg.py']
|
---|
| 100 | #atk2_sc3_post_python_files = ['arch/ccrh/post_atk2.py']
|
---|
| 101 | cfg_pass4_post_python_files = ['arch/ccrh/post_cfg_pass4.py']
|
---|
| 102 | # atk2_sc3_pre_python_files = ['cfg/ldscript.py']
|
---|
| 103 |
|
---|
| 104 | #
|
---|
| 105 | # cubesuite+ depend files
|
---|
| 106 | #
|
---|
| 107 | atk2_sc3_rel_includes = [".","cfg"]
|
---|
| 108 | cfg_rel_includes = [".."]
|
---|
| 109 | kernel_rel_includes = ["..","..\cfg"]
|
---|
| 110 |
|
---|
| 111 | #
|
---|
| 112 | # library
|
---|
| 113 | #
|
---|
| 114 | #atk2_sc3_lib_includes = []
|
---|
| 115 | atk2_sc3_lib_files = [r'kernel\%BuildModeName%\kernel']
|
---|
| 116 | cfg_pass4_lib_files = [r'..\kernel\%BuildModeName%\kernel']
|
---|
| 117 |
|
---|
| 118 | #
|
---|
| 119 | # cx define
|
---|
| 120 | #
|
---|
| 121 | kernel_define = ['ALLFUNC', 'TOPPERS_LABEL_ASM', 'USE_CCRH', 'MPU_REGION_NUM=%d' % (MPU_REGION_NUM)]
|
---|
| 122 |
|
---|
| 123 | #
|
---|
| 124 | # cx additional option
|
---|
| 125 | # -Xno_warning=20177 : Suppress warnings no refer label(exit_no_errorhooh, d_exit_no_errorhook)
|
---|
| 126 | kernel_c_addopt = ['-Xno_warning=20177']
|
---|
| 127 | # -Xno_warning=50013 : Use r1 register as source register
|
---|
| 128 | kernel_asm_addopt = ['-Xno_warning=50013']
|
---|
| 129 |
|
---|
| 130 | #
|
---|
| 131 | # Set cfg path and srdir path
|
---|
| 132 | #
|
---|
| 133 | cfg = proj_rel_dir + CFG
|
---|
| 134 | srcdir = proj_rel_dir + SRCDIR
|
---|
| 135 |
|
---|
| 136 | #
|
---|
| 137 | # soucre target file
|
---|
| 138 | #
|
---|
| 139 |
|
---|
| 140 | f = open(src_abs_path + r'/log', 'w')
|
---|
| 141 | f.write(srcdir + "target/" + TARGET + "/target.py")
|
---|
| 142 | f.close()
|
---|
| 143 | execfile(srcdir + "target/" + TARGET + "/target.py")
|
---|
| 144 |
|
---|
| 145 | #
|
---|
| 146 | # merge files
|
---|
| 147 | #
|
---|
| 148 | app_files.append(statup_file)
|
---|
| 149 | app_files = app_files + app_sysmod_files + app_library_files
|
---|
| 150 | kernel_files = kernel_kernel_files + kernel_target_files + kernel_arch_files
|
---|
| 151 |
|
---|
| 152 | #
|
---|
| 153 | # Set include path and cfg1_def_table
|
---|
| 154 | #
|
---|
| 155 | INCLUDES = USER_INCLUDE + ["", "arch", "include", "kernel", "arch", "sysmod", "library"] + INCLUDES
|
---|
| 156 | CFG1_DEF_TABLES = ["kernel/kernel_def.csv"] + CFG1_DEF_TABLES
|
---|
| 157 |
|
---|
| 158 | API_TABLE = "kernel/kernel.csv"
|
---|
| 159 | INI_FILE = "kernel/kernel.ini"
|
---|
| 160 |
|
---|
| 161 | CFG_TF = "target/" + TARGET + "/target.tf"
|
---|
| 162 | CFG_OFFSET_TF = "target/" + TARGET + "/target_offset.tf"
|
---|
| 163 | CFG_MEM_TF = "target/" + TARGET + "/target_mem.tf"
|
---|
| 164 |
|
---|
| 165 | #
|
---|
| 166 | # cfg input files
|
---|
| 167 | #
|
---|
| 168 | cfg_rel_files = []
|
---|
| 169 | cfg_input_str = ""
|
---|
| 170 | for cfg_filename in CFGNAME:
|
---|
| 171 | cfg_rel_file = cfg_filename + '.arxml'
|
---|
| 172 |
|
---|
| 173 | cfg_list = [proj_rel_dir + cfg_rel_file]
|
---|
| 174 | for inc_path in INCLUDES:
|
---|
| 175 | cfg_list = cfg_list + [src_abs_path + '/' + inc_path + '/' + cfg_rel_file]
|
---|
| 176 |
|
---|
| 177 | flg = 0
|
---|
| 178 | for cfg_rel_file in cfg_list:
|
---|
| 179 | if os.path.exists(cfg_rel_file):
|
---|
| 180 | cfg_rel_files.append(cfg_rel_file)
|
---|
| 181 | flg = 1
|
---|
| 182 | break
|
---|
| 183 |
|
---|
| 184 | if flg == 0:
|
---|
| 185 | print "WARNING!! : Not Exist %s" % cfg_filename
|
---|
| 186 |
|
---|
| 187 | cfg_input_str = " ".join(cfg_rel_files)
|
---|
| 188 |
|
---|
| 189 | #
|
---|
| 190 | # make cfg include path
|
---|
| 191 | #
|
---|
| 192 | cfg_includes = ""
|
---|
| 193 | for include in INCLUDES:
|
---|
| 194 | cfg_includes = cfg_includes + " -I" + srcdir + include
|
---|
| 195 |
|
---|
| 196 | #
|
---|
| 197 | # make cfg1_def_table
|
---|
| 198 | #
|
---|
| 199 | cfg_cfg1_def_tables = ""
|
---|
| 200 | for cfg1_def_table in CFG1_DEF_TABLES:
|
---|
| 201 | cfg_cfg1_def_tables = cfg_cfg1_def_tables + " --cfg1-def-table " + srcdir + cfg1_def_table
|
---|
| 202 |
|
---|
| 203 | #
|
---|
| 204 | # Set api_table
|
---|
| 205 | #
|
---|
| 206 | cfg_api_table = srcdir + API_TABLE
|
---|
| 207 |
|
---|
| 208 | #
|
---|
| 209 | # Set ini_file
|
---|
| 210 | #
|
---|
| 211 | cfg_ini_file = srcdir + INI_FILE
|
---|
| 212 |
|
---|
| 213 | #
|
---|
| 214 | # Set tf
|
---|
| 215 | #
|
---|
| 216 | cfg_tf = srcdir + CFG_TF
|
---|
| 217 |
|
---|
| 218 | #
|
---|
| 219 | # Set offset tf
|
---|
| 220 | #
|
---|
| 221 | cfg_offset_tf = srcdir + CFG_OFFSET_TF
|
---|
| 222 |
|
---|
| 223 | #
|
---|
| 224 | # Set check tf
|
---|
| 225 | #
|
---|
| 226 | cfg_mem_tf = srcdir + CFG_MEM_TF
|
---|
| 227 |
|
---|
| 228 | #
|
---|
| 229 | #
|
---|
| 230 | # Functions
|
---|
| 231 | #
|
---|
| 232 | #
|
---|
| 233 | import re
|
---|
| 234 |
|
---|
| 235 | #
|
---|
| 236 | # Set Cx Includes
|
---|
| 237 | #
|
---|
| 238 | def SetCxIncludes(inputstr, include_list, rel_include_list, relpath):
|
---|
| 239 | cx_includes = ""
|
---|
| 240 | for include in rel_include_list:
|
---|
| 241 | include_list.append(relpath + include)
|
---|
| 242 | for include in include_list:
|
---|
| 243 | cx_includes = cx_includes + include + "\n"
|
---|
| 244 | cx_includes = cx_includes.replace('/', r'\\')
|
---|
| 245 | pattern_pre = r'(\s\<AdditionalIncludePaths-0\>)[\s\S]+?(\</AdditionalIncludePaths-0\>)'
|
---|
| 246 | pattern_post = r'\1' + cx_includes + r'\2'
|
---|
| 247 | inputstr = re.sub (pattern_pre, pattern_post, inputstr)
|
---|
| 248 | return inputstr
|
---|
| 249 |
|
---|
| 250 | #
|
---|
| 251 | # ChangeSetItemXml
|
---|
| 252 | #
|
---|
| 253 | def ChangeItemXml(inputstr, xml_pattern, newitemstr):
|
---|
| 254 | pattern_pre = r'<' + xml_pattern + r'>[\s\S]+?</' + xml_pattern + '>'
|
---|
| 255 | pattern_post = '<' + xml_pattern + '>' + newitemstr + '</' + xml_pattern + '>'
|
---|
| 256 | inputstr = re.sub (pattern_pre, pattern_post, inputstr)
|
---|
| 257 | return inputstr
|
---|
| 258 |
|
---|
| 259 | #
|
---|
| 260 | # NewSetItemXml
|
---|
| 261 | #
|
---|
| 262 | def NewSetItemXml(inputstr, xml_pattern, newitemstr):
|
---|
| 263 | pattern_pre = r'\<' + xml_pattern + r' /\>'
|
---|
| 264 | pattern_post = r'<' + xml_pattern + r'>' + newitemstr + '</' + xml_pattern + r'>'
|
---|
| 265 | inputstr = re.sub (pattern_pre, pattern_post, inputstr)
|
---|
| 266 | return inputstr
|
---|
| 267 |
|
---|
| 268 | #
|
---|
| 269 | # NewSetItemXmlOnce
|
---|
| 270 | #
|
---|
| 271 | def NewSetItemXmlOnce(inputstr, xml_pattern, newitemstr):
|
---|
| 272 | pattern_pre = r'\<' + xml_pattern + r' /\>'
|
---|
| 273 | pattern_post = r'<' + xml_pattern + r'>' + newitemstr + '</' + xml_pattern + r'>'
|
---|
| 274 | inputstr = re.sub (pattern_pre, pattern_post, inputstr, 1)
|
---|
| 275 | return inputstr
|
---|
| 276 |
|
---|
| 277 | #
|
---|
| 278 | # New set Cx Include
|
---|
| 279 | #
|
---|
| 280 | def NewSetCxIncludes(inputstr, include_list, rel_include_list, relpath):
|
---|
| 281 | cx_includes = ""
|
---|
| 282 | for include in rel_include_list:
|
---|
| 283 | include_list.append(relpath + include)
|
---|
| 284 | for include in include_list:
|
---|
| 285 | cx_includes = cx_includes + include + "\n"
|
---|
| 286 | cx_includes = cx_includes.replace('/', r'\\')
|
---|
| 287 | return NewSetItemXml(inputstr, 'AdditionalIncludePaths-0', cx_includes)
|
---|
| 288 |
|
---|
| 289 | def NewSetCCRHIncludes(inputstr, include_list, rel_include_list, relpath):
|
---|
| 290 | ccrh_includes = ""
|
---|
| 291 | for include in rel_include_list:
|
---|
| 292 | include_list.append(relpath + include)
|
---|
| 293 | for include in include_list:
|
---|
| 294 | ccrh_includes = ccrh_includes + include + "\n"
|
---|
| 295 | ccrh_includes = ccrh_includes.replace('/', r'\\')
|
---|
| 296 | return NewSetItemXml(inputstr, 'COptionI-0', ccrh_includes)
|
---|
| 297 |
|
---|
| 298 | #
|
---|
| 299 | # New set library Include
|
---|
| 300 | #
|
---|
| 301 | def NewSetLibIncludes(inputstr, include_list, rel_include_list, relpath):
|
---|
| 302 | lib_includes = ""
|
---|
| 303 | for include in rel_include_list:
|
---|
| 304 | include_list.append(relpath + include)
|
---|
| 305 | for include in include_list:
|
---|
| 306 | lib_includes = lib_includes + include + "\n"
|
---|
| 307 | lib_includes = lib_includes.replace('/', r'\\')
|
---|
| 308 | return NewSetItemXml(inputstr, 'AdditionalLibraryPaths-0', lib_includes)
|
---|
| 309 |
|
---|
| 310 | #
|
---|
| 311 | # New set library files
|
---|
| 312 | #
|
---|
| 313 | def NewSetLibFiles(inputstr, file_list):
|
---|
| 314 | lib_files = ""
|
---|
| 315 | for file in file_list:
|
---|
| 316 | lib_files = lib_files + file + "\n"
|
---|
| 317 | lib_files = lib_files.replace('/', r'\\')
|
---|
| 318 | return NewSetItemXml(inputstr, 'LinkOptionLibrary-0', lib_files)
|
---|
| 319 |
|
---|
| 320 | #
|
---|
| 321 | # New set prebuild
|
---|
| 322 | #
|
---|
| 323 | def NewSetPrebuild(inputstr, rel_command_list, relpath):
|
---|
| 324 | command_str = ''
|
---|
| 325 | for command in rel_command_list:
|
---|
| 326 | command_str = command_str + relpath + command
|
---|
| 327 | command_str = r'#!python\ncommon.Source("' + command_str + r'")\n'
|
---|
| 328 | return NewSetItemXml(inputstr, 'PreBuildCommands-0', command_str)
|
---|
| 329 |
|
---|
| 330 |
|
---|
| 331 | #
|
---|
| 332 | # New set postbuild
|
---|
| 333 | #
|
---|
| 334 | def NewSetPostbuild(inputstr, rel_command_list, relpath):
|
---|
| 335 | command_str = ''
|
---|
| 336 | for command in rel_command_list:
|
---|
| 337 | command_str = command_str + relpath + command
|
---|
| 338 | command_str = r'#!python\ncommon.Source("' + command_str + r'")\n'
|
---|
| 339 | return NewSetItemXml(inputstr, 'PostBuildCommands-0', command_str)
|
---|
| 340 |
|
---|
| 341 |
|
---|
| 342 | #
|
---|
| 343 | # New set Define
|
---|
| 344 | #
|
---|
| 345 | def NewSetDefine(inputstr, define_list):
|
---|
| 346 | define_str = ''
|
---|
| 347 | for define in define_list:
|
---|
| 348 | define_str = define_str + define + '\n'
|
---|
| 349 | return NewSetItemXml(inputstr, 'COptionD-0', define_str)
|
---|
| 350 |
|
---|
| 351 | #
|
---|
| 352 | # New set additional options
|
---|
| 353 | #
|
---|
| 354 | def NewSetCAddOpt(inputstr, option_list):
|
---|
| 355 | option_str = ''
|
---|
| 356 | for option in option_list:
|
---|
| 357 | option_str = option_str + option + ' '
|
---|
| 358 | return NewSetItemXmlOnce(inputstr, 'COptionOtherAdditionalOptions-0', option_str)
|
---|
| 359 |
|
---|
| 360 | def NewSetAsmAddOpt(inputstr, option_list):
|
---|
| 361 | option_str = ''
|
---|
| 362 | for option in option_list:
|
---|
| 363 | option_str = option_str + option + ' '
|
---|
| 364 | return NewSetItemXmlOnce(inputstr, 'AsmOptionOtherAdditionalOptions-0', option_str)
|
---|
| 365 |
|
---|
| 366 | #
|
---|
| 367 | # Set target file relative path
|
---|
| 368 | #
|
---|
| 369 | def SetTargetFileRelativePath(inputstr, file_list, relpath):
|
---|
| 370 | relpath_win = re.sub(r'/',r'\\\\', relpath)
|
---|
| 371 | for file_path in file_list:
|
---|
| 372 | file_path = re.sub(r'/',r'\\\\',file_path)
|
---|
| 373 | pattern_pre = r'(\s\<RelativePath\>).+?' + file_path + r'(\</RelativePath\>)'
|
---|
| 374 | pattern_post = r'\1' + relpath_win + file_path + r'\2'
|
---|
| 375 | inputstr = re.sub (pattern_pre, pattern_post, inputstr)
|
---|
| 376 | return inputstr
|
---|
| 377 |
|
---|
| 378 |
|
---|
| 379 | #
|
---|
| 380 | # Set python file relative path
|
---|
| 381 | #
|
---|
| 382 | def SetPythonFileRelativePath(inputstr, file_list, relpath):
|
---|
| 383 | for file_path in file_list:
|
---|
| 384 | pattern_pre = r'".+?' + file_path + r'"'
|
---|
| 385 | pattern_post = r'"' + relpath + file_path + r'"'
|
---|
| 386 | inputstr = re.sub (pattern_pre, pattern_post, inputstr)
|
---|
| 387 | return inputstr
|
---|
| 388 |
|
---|
| 389 | def ReadFile(filename):
|
---|
| 390 | f = open(filename, "r")
|
---|
| 391 | str = f.read()
|
---|
| 392 | f.close()
|
---|
| 393 | return str
|
---|
| 394 |
|
---|
| 395 | def WriteFile(filename, str):
|
---|
| 396 | f = open(filename, "w")
|
---|
| 397 | f.write(str)
|
---|
| 398 | f.close()
|
---|
| 399 |
|
---|
| 400 | def WriteFile_B(filename, str):
|
---|
| 401 | f = open(filename, "wb")
|
---|
| 402 | f.write(str)
|
---|
| 403 | f.close()
|
---|
| 404 |
|
---|