@@ -215,98 +215,116 @@ def MDK45Project(tree, target, script):
215
215
root = tree .getroot ()
216
216
out = open (target , 'w' )
217
217
out .write ('<?xml version="1.0" encoding="UTF-8" standalone="no" ?>\n ' )
218
-
219
- CPPPATH = []
220
- CPPDEFINES = []
221
- LINKFLAGS = ''
222
- CXXFLAGS = ''
223
- CCFLAGS = ''
224
- CFLAGS = ''
225
- ProjectFiles = []
226
-
227
- # add group
228
- groups = tree .find ('Targets/Target/Groups' )
229
- if groups is None :
230
- groups = SubElement (tree .find ('Targets/Target' ), 'Groups' )
231
- groups .clear () # clean old groups
232
- for group in script :
233
- group_tree = MDK4AddGroup (ProjectFiles , groups , group ['name' ], group ['src' ], project_path , group )
234
-
235
- # get each include path
236
- if 'CPPPATH' in group and group ['CPPPATH' ]:
237
- if CPPPATH :
238
- CPPPATH += group ['CPPPATH' ]
239
- else :
240
- CPPPATH += group ['CPPPATH' ]
241
-
242
- # get each group's definitions
243
- if 'CPPDEFINES' in group and group ['CPPDEFINES' ]:
244
- if CPPDEFINES :
245
- CPPDEFINES += group ['CPPDEFINES' ]
246
- else :
247
- CPPDEFINES = group ['CPPDEFINES' ]
248
-
249
- # get each group's link flags
250
- if 'LINKFLAGS' in group and group ['LINKFLAGS' ]:
251
- if LINKFLAGS :
252
- LINKFLAGS += ' ' + group ['LINKFLAGS' ]
253
- else :
254
- LINKFLAGS += group ['LINKFLAGS' ]
255
-
256
- # get each group's CXXFLAGS flags
257
- if 'CXXFLAGS' in group and group ['CXXFLAGS' ]:
258
- if CXXFLAGS :
259
- CXXFLAGS += ' ' + group ['CXXFLAGS' ]
260
- else :
261
- CXXFLAGS += group ['CXXFLAGS' ]
262
-
263
- # get each group's CCFLAGS flags
264
- if 'CCFLAGS' in group and group ['CCFLAGS' ]:
265
- if CCFLAGS :
266
- CCFLAGS += ' ' + group ['CCFLAGS' ]
267
- else :
268
- CCFLAGS += group ['CCFLAGS' ]
269
-
270
- # get each group's CFLAGS flags
271
- if 'CFLAGS' in group and group ['CFLAGS' ]:
272
- if CFLAGS :
273
- CFLAGS += ' ' + group ['CFLAGS' ]
274
- else :
275
- CFLAGS += group ['CFLAGS' ]
276
-
277
- # get each group's LIBS flags
278
- if 'LIBS' in group and group ['LIBS' ]:
279
- for item in group ['LIBS' ]:
280
- lib_path = ''
281
- for path_item in group ['LIBPATH' ]:
282
- full_path = os .path .join (path_item , item + '.lib' )
283
- if os .path .isfile (full_path ): # has this library
284
- lib_path = full_path
285
- break
286
-
287
- if lib_path != '' :
288
- if group_tree != None :
289
- MDK4AddLibToGroup (ProjectFiles , group_tree , group ['name' ], lib_path , project_path )
290
- else :
291
- group_tree = MDK4AddGroupForFN (ProjectFiles , groups , group ['name' ], lib_path , project_path )
292
-
293
- # write include path, definitions and link flags
294
- IncludePath = tree .find ('Targets/Target/TargetOption/TargetArmAds/Cads/VariousControls/IncludePath' )
295
- IncludePath .text = ';' .join ([_make_path_relative (project_path , os .path .normpath (i )) for i in set (CPPPATH )])
296
-
297
- Define = tree .find ('Targets/Target/TargetOption/TargetArmAds/Cads/VariousControls/Define' )
298
- Define .text = ', ' .join (set (CPPDEFINES ))
299
-
300
- if 'c99' in CXXFLAGS or 'c99' in CCFLAGS or 'c99' in CFLAGS :
301
- uC99 = tree .find ('Targets/Target/TargetOption/TargetArmAds/Cads/uC99' )
302
- uC99 .text = '1'
303
-
304
- if 'gnu' in CXXFLAGS or 'gnu' in CCFLAGS or 'gnu' in CFLAGS :
305
- uGnu = tree .find ('Targets/Target/TargetOption/TargetArmAds/Cads/uGnu' )
306
- uGnu .text = '1'
307
-
308
- Misc = tree .find ('Targets/Target/TargetOption/TargetArmAds/LDads/Misc' )
309
- Misc .text = LINKFLAGS
218
+
219
+ #Addtion the name of OutputDir
220
+ for targcomoOp in root .findall ('.//TargetCommonOption' ):
221
+ OutputDir = targcomoOp .find ('OutputDirectory' )
222
+ OutputName = targcomoOp .find ('OutputName' )
223
+ #print(OutputDir.text)
224
+ #print(OutputName.text)
225
+ OutputDir .text += OutputName .text + '\\ '
226
+ #print(OutputDir.text)
227
+
228
+ for child in root .findall ('.//Target' ):
229
+ CPPPATH = []
230
+ CPPDEFINES = []
231
+ LINKFLAGS = ''
232
+ CXXFLAGS = ''
233
+ CCFLAGS = ''
234
+ CFLAGS = ''
235
+ ProjectFiles = []
236
+ groups = child .find ('Groups' )
237
+ if groups is None :
238
+ groups = SubElement (child ,'Groups' )
239
+ groups .clear () # clean old groups
240
+
241
+ # add group
242
+ #groups = tree.find('Targets/Target/Groups')
243
+ #if groups is None:
244
+ #groups = SubElement(tree.find('Targets/Target'), 'Groups')
245
+ #groups.clear() # clean old groups
246
+ for group in script :
247
+ group_tree = MDK4AddGroup (ProjectFiles , groups , group ['name' ], group ['src' ], project_path , group )
248
+ # get each include path
249
+ if 'CPPPATH' in group and group ['CPPPATH' ]:
250
+ if CPPPATH :
251
+ CPPPATH += group ['CPPPATH' ]
252
+ else :
253
+ CPPPATH += group ['CPPPATH' ]
254
+
255
+ # get each group's definitions
256
+ if 'CPPDEFINES' in group and group ['CPPDEFINES' ]:
257
+ if CPPDEFINES :
258
+ CPPDEFINES += group ['CPPDEFINES' ]
259
+ else :
260
+ CPPDEFINES = group ['CPPDEFINES' ]
261
+
262
+ # get each group's link flags
263
+ if 'LINKFLAGS' in group and group ['LINKFLAGS' ]:
264
+ if LINKFLAGS :
265
+ LINKFLAGS += ' ' + group ['LINKFLAGS' ]
266
+ else :
267
+ LINKFLAGS += group ['LINKFLAGS' ]
268
+
269
+ # get each group's CXXFLAGS flags
270
+ if 'CXXFLAGS' in group and group ['CXXFLAGS' ]:
271
+ if CXXFLAGS :
272
+ CXXFLAGS += ' ' + group ['CXXFLAGS' ]
273
+ else :
274
+ CXXFLAGS += group ['CXXFLAGS' ]
275
+
276
+ # get each group's CCFLAGS flags
277
+ if 'CCFLAGS' in group and group ['CCFLAGS' ]:
278
+ if CCFLAGS :
279
+ CCFLAGS += ' ' + group ['CCFLAGS' ]
280
+ else :
281
+ CCFLAGS += group ['CCFLAGS' ]
282
+
283
+ # get each group's CFLAGS flags
284
+ if 'CFLAGS' in group and group ['CFLAGS' ]:
285
+ if CFLAGS :
286
+ CFLAGS += ' ' + group ['CFLAGS' ]
287
+ else :
288
+ CFLAGS += group ['CFLAGS' ]
289
+
290
+ # get each group's LIBS flags
291
+ if 'LIBS' in group and group ['LIBS' ]:
292
+ for item in group ['LIBS' ]:
293
+ lib_path = ''
294
+ for path_item in group ['LIBPATH' ]:
295
+ full_path = os .path .join (path_item , item + '.lib' )
296
+ if os .path .isfile (full_path ): # has this library
297
+ lib_path = full_path
298
+ break
299
+
300
+ if lib_path != '' :
301
+ if group_tree != None :
302
+ MDK4AddLibToGroup (ProjectFiles , group_tree , group ['name' ], lib_path , project_path )
303
+ else :
304
+ group_tree = MDK4AddGroupForFN (ProjectFiles , groups , group ['name' ], lib_path , project_path )
305
+ # write include path, definitions and link flags
306
+ IncludePath = child .find ('TargetOption/TargetArmAds/Cads/VariousControls/IncludePath' )
307
+ if (IncludePath .text != None ):
308
+ IncludePath .text = IncludePath .text + ';' + ';' .join ([_make_path_relative (project_path , os .path .normpath (i )) for i in set (CPPPATH )])
309
+ else :
310
+ IncludePath .text = ';' .join ([_make_path_relative (project_path , os .path .normpath (i )) for i in set (CPPPATH )])
311
+
312
+ Define = child .find ('TargetOption/TargetArmAds/Cads/VariousControls/Define' )
313
+ if (Define .text != None ):
314
+ Define .text = Define .text + ',' + ', ' .join (set (CPPDEFINES ))
315
+ else :
316
+ Define .text = ',' .join (set (CPPDEFINES ))
317
+
318
+ if 'c99' in CXXFLAGS or 'c99' in CCFLAGS or 'c99' in CFLAGS :
319
+ uC99 = child .find ('TargetOption/TargetArmAds/Cads/uC99' )
320
+ uC99 .text = '1'
321
+
322
+ if 'gnu' in CXXFLAGS or 'gnu' in CCFLAGS or 'gnu' in CFLAGS :
323
+ uGnu = child .find ('TargetOption/TargetArmAds/Cads/uGnu' )
324
+ uGnu .text = '1'
325
+
326
+ Misc = child .find ('TargetOption/TargetArmAds/LDads/Misc' )
327
+ Misc .text = LINKFLAGS
310
328
311
329
xml_indent (root )
312
330
out .write (etree .tostring (root , encoding = 'utf-8' ).decode ())
0 commit comments