Skip to content

Commit fc03d62

Browse files
committed
fix:buding_keil_CPPDEFINES
1 parent a1e8651 commit fc03d62

File tree

2 files changed

+11
-25
lines changed

2 files changed

+11
-25
lines changed

tools/building.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -805,13 +805,13 @@ def GenTargetProject(program = None):
805805
from targets.keil import MDK2Project, MDK4Project, MDK5Project, ARMCC_Version
806806

807807
if os.path.isfile('template.uvprojx') and GetOption('target') not in ['mdk4']: # Keil5
808-
MDK5Project(GetOption('project-name') + '.uvprojx', Projects)
808+
MDK5Project(Env, GetOption('project-name') + '.uvprojx', Projects)
809809
print("Keil5 project is generating...")
810810
elif os.path.isfile('template.uvproj') and GetOption('target') not in ['mdk5']: # Keil4
811-
MDK4Project(GetOption('project-name') + '.uvproj', Projects)
811+
MDK4Project(Env, GetOption('project-name') + '.uvproj', Projects)
812812
print("Keil4 project is generating...")
813813
elif os.path.isfile('template.Uv2') and GetOption('target') not in ['mdk4', 'mdk5']: # Keil2
814-
MDK2Project(GetOption('project-name') + '.Uv2', Projects)
814+
MDK2Project(Env, GetOption('project-name') + '.Uv2', Projects)
815815
print("Keil2 project is generating...")
816816
else:
817817
print ('No template project file found.')

tools/targets/keil.py

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -216,15 +216,15 @@ def MDK4AddGroup(ProjectFiles, parent, name, files, project_path, group_scons):
216216
return group
217217

218218
# The common part of making MDK4/5 project
219-
def MDK45Project(tree, target, script):
219+
def MDK45Project(env, tree, target, script):
220220
project_path = os.path.dirname(os.path.abspath(target))
221221

222222
root = tree.getroot()
223223
out = open(target, 'w')
224224
out.write('<?xml version="1.0" encoding="UTF-8" standalone="no" ?>\n')
225225

226226
CPPPATH = []
227-
CPPDEFINES = []
227+
CPPDEFINES = env.get('CPPDEFINES', [])
228228
LINKFLAGS = ''
229229
CXXFLAGS = ''
230230
CCFLAGS = ''
@@ -246,13 +246,6 @@ def MDK45Project(tree, target, script):
246246
else:
247247
CPPPATH += group['CPPPATH']
248248

249-
# get each group's definitions
250-
if 'CPPDEFINES' in group and group['CPPDEFINES']:
251-
if CPPDEFINES:
252-
CPPDEFINES += group['CPPDEFINES']
253-
else:
254-
CPPDEFINES = group['CPPDEFINES']
255-
256249
# get each group's link flags
257250
if 'LINKFLAGS' in group and group['LINKFLAGS']:
258251
if LINKFLAGS:
@@ -313,15 +306,15 @@ def MDK45Project(tree, target, script):
313306
out.write(etree.tostring(root, encoding='utf-8').decode())
314307
out.close()
315308

316-
def MDK4Project(target, script):
309+
def MDK4Project(env, target, script):
317310

318311
if os.path.isfile('template.uvproj') is False:
319312
print ('Warning: The template project file [template.uvproj] not found!')
320313
return
321314

322315
template_tree = etree.parse('template.uvproj')
323316

324-
MDK45Project(template_tree, target, script)
317+
MDK45Project(env, template_tree, target, script)
325318

326319
# remove project.uvopt file
327320
project_uvopt = os.path.abspath(target).replace('uvproj', 'uvopt')
@@ -352,15 +345,15 @@ def monitor_log_file(log_file_path):
352345
if empty_line_count > 30:
353346
print("Timeout reached or too many empty lines, exiting log monitoring thread.")
354347
break
355-
def MDK5Project(target, script):
348+
def MDK5Project(env, target, script):
356349

357350
if os.path.isfile('template.uvprojx') is False:
358351
print ('Warning: The template project file [template.uvprojx] not found!')
359352
return
360353

361354
template_tree = etree.parse('template.uvprojx')
362355

363-
MDK45Project(template_tree, target, script)
356+
MDK45Project(env, template_tree, target, script)
364357

365358
# remove project.uvopt file
366359
project_uvopt = os.path.abspath(target).replace('uvprojx', 'uvoptx')
@@ -387,7 +380,7 @@ def MDK5Project(target, script):
387380
else:
388381
print('UV4.exe is not available, please check your keil installation')
389382

390-
def MDK2Project(target, script):
383+
def MDK2Project(env, target, script):
391384
template = open(os.path.join(os.path.dirname(__file__), 'template.Uv2'), 'r')
392385
lines = template.readlines()
393386

@@ -407,7 +400,7 @@ def MDK2Project(target, script):
407400

408401
ProjectFiles = []
409402
CPPPATH = []
410-
CPPDEFINES = []
403+
CPPDEFINES = env.get('CPPDEFINES', [])
411404
LINKFLAGS = ''
412405
CFLAGS = ''
413406

@@ -423,13 +416,6 @@ def MDK2Project(target, script):
423416
else:
424417
CPPPATH += group['CPPPATH']
425418

426-
# get each group's definitions
427-
if 'CPPDEFINES' in group and group['CPPDEFINES']:
428-
if CPPDEFINES:
429-
CPPDEFINES += group['CPPDEFINES']
430-
else:
431-
CPPDEFINES = group['CPPDEFINES']
432-
433419
# get each group's link flags
434420
if 'LINKFLAGS' in group and group['LINKFLAGS']:
435421
if LINKFLAGS:

0 commit comments

Comments
 (0)