summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorCYFS <[email protected]>2025-07-04 20:57:50 +0800
committerRbb666 <[email protected]>2025-07-04 21:00:22 +0800
commit492e33dd3cee2f111c9d0b9ccc85020b243ed6cf (patch)
tree6315c51cb0990676ccb0aae9d1fdb77e2f665674 /tools
parentf4168669a71449133184167987595a56591d4bdf (diff)
fix:buding_keil_CPPDEFINES
Diffstat (limited to 'tools')
-rw-r--r--tools/building.py6
-rw-r--r--tools/targets/keil.py30
2 files changed, 11 insertions, 25 deletions
diff --git a/tools/building.py b/tools/building.py
index 12689345e7..f73c30d9b3 100644
--- a/tools/building.py
+++ b/tools/building.py
@@ -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.')
diff --git a/tools/targets/keil.py b/tools/targets/keil.py
index d2b6e72e8a..452f273dff 100644
--- a/tools/targets/keil.py
+++ b/tools/targets/keil.py
@@ -216,7 +216,7 @@ 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()
@@ -224,7 +224,7 @@ def MDK45Project(tree, target, script):
out.write('<?xml version="1.0" encoding="UTF-8" standalone="no" ?>\n')
CPPPATH = []
- CPPDEFINES = []
+ CPPDEFINES = env.get('CPPDEFINES', [])
LINKFLAGS = ''
CXXFLAGS = ''
CCFLAGS = ''
@@ -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:
@@ -313,7 +306,7 @@ 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!')
@@ -321,7 +314,7 @@ def MDK4Project(target, script):
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')
@@ -352,7 +345,7 @@ 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!')
@@ -360,7 +353,7 @@ def MDK5Project(target, script):
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')
@@ -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()
@@ -407,7 +400,7 @@ def MDK2Project(target, script):
ProjectFiles = []
CPPPATH = []
- CPPDEFINES = []
+ CPPDEFINES = env.get('CPPDEFINES', [])
LINKFLAGS = ''
CFLAGS = ''
@@ -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: