Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions tools/building.py
Original file line number Diff line number Diff line change
Expand Up @@ -805,13 +805,13 @@ def GenTargetProject(program = None):
from targets.keil import MDK2Project, MDK4Project, MDK5Project, ARMCC_Version

if os.path.isfile('template.uvprojx') and GetOption('target') not in ['mdk4']: # Keil5
MDK5Project(GetOption('project-name') + '.uvprojx', Projects)
MDK5Project(Env, GetOption('project-name') + '.uvprojx', Projects)
print("Keil5 project is generating...")
elif os.path.isfile('template.uvproj') and GetOption('target') not in ['mdk5']: # Keil4
MDK4Project(GetOption('project-name') + '.uvproj', Projects)
MDK4Project(Env, GetOption('project-name') + '.uvproj', Projects)
print("Keil4 project is generating...")
elif os.path.isfile('template.Uv2') and GetOption('target') not in ['mdk4', 'mdk5']: # Keil2
MDK2Project(GetOption('project-name') + '.Uv2', Projects)
MDK2Project(Env, GetOption('project-name') + '.Uv2', Projects)
print("Keil2 project is generating...")
else:
print ('No template project file found.')
Expand Down
30 changes: 8 additions & 22 deletions tools/targets/keil.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,15 @@ def MDK4AddGroup(ProjectFiles, parent, name, files, project_path, group_scons):
return group

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

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

CPPPATH = []
CPPDEFINES = []
CPPDEFINES = env.get('CPPDEFINES', [])
LINKFLAGS = ''
CXXFLAGS = ''
CCFLAGS = ''
Expand All @@ -246,13 +246,6 @@ def MDK45Project(tree, target, script):
else:
CPPPATH += group['CPPPATH']

# get each group's definitions
if 'CPPDEFINES' in group and group['CPPDEFINES']:
if CPPDEFINES:
CPPDEFINES += group['CPPDEFINES']
else:
CPPDEFINES = group['CPPDEFINES']

# get each group's link flags
if 'LINKFLAGS' in group and group['LINKFLAGS']:
if LINKFLAGS:
Expand Down Expand Up @@ -313,15 +306,15 @@ def MDK45Project(tree, target, script):
out.write(etree.tostring(root, encoding='utf-8').decode())
out.close()

def MDK4Project(target, script):
def MDK4Project(env, target, script):

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

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

MDK45Project(template_tree, target, script)
MDK45Project(env, template_tree, target, script)

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

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

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

MDK45Project(template_tree, target, script)
MDK45Project(env, template_tree, target, script)

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

def MDK2Project(target, script):
def MDK2Project(env, target, script):
template = open(os.path.join(os.path.dirname(__file__), 'template.Uv2'), 'r')
lines = template.readlines()

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

ProjectFiles = []
CPPPATH = []
CPPDEFINES = []
CPPDEFINES = env.get('CPPDEFINES', [])
LINKFLAGS = ''
CFLAGS = ''

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

# get each group's definitions
if 'CPPDEFINES' in group and group['CPPDEFINES']:
if CPPDEFINES:
CPPDEFINES += group['CPPDEFINES']
else:
CPPDEFINES = group['CPPDEFINES']

# get each group's link flags
if 'LINKFLAGS' in group and group['LINKFLAGS']:
if LINKFLAGS:
Expand Down