MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / MDK4AddGroup

Function MDK4AddGroup

tools/targets/keil.py:147–216  ·  view source on GitHub ↗
(ProjectFiles, parent, name, files, project_path, group_scons)

Source from the content-addressed store, hash-verified

145 return group
146
147def MDK4AddGroup(ProjectFiles, parent, name, files, project_path, group_scons):
148 # don't add an empty group
149 if len(files) == 0:
150 return
151
152 group = SubElement(parent, 'Group')
153 group_name = SubElement(group, 'GroupName')
154 group_name.text = name
155
156 for f in files:
157 fn = f.rfile()
158 name = fn.name
159 path = os.path.dirname(fn.abspath)
160
161 basename = os.path.basename(path)
162 path = _make_path_relative(project_path, path)
163 path = os.path.join(path, name)
164
165 files = SubElement(group, 'Files')
166 file = SubElement(files, 'File')
167 file_name = SubElement(file, 'FileName')
168 name = os.path.basename(path)
169
170 if name.find('.cpp') != -1:
171 obj_name = name.replace('.cpp', '.o')
172 elif name.find('.c') != -1:
173 obj_name = name.replace('.c', '.o')
174 elif name.find('.s') != -1:
175 obj_name = name.replace('.s', '.o')
176 elif name.find('.S') != -1:
177 obj_name = name.replace('.s', '.o')
178
179 if ProjectFiles.count(obj_name):
180 name = basename + '_' + name
181 ProjectFiles.append(obj_name)
182 file_name.text = name # name.decode(fs_encoding)
183 file_type = SubElement(file, 'FileType')
184 file_type.text = '%d' % _get_filetype(name)
185 file_path = SubElement(file, 'FilePath')
186 file_path.text = path # path.decode(fs_encoding)
187
188 # for local LOCAL_CFLAGS/LOCAL_CXXFLAGS/LOCAL_CCFLAGS/LOCAL_CPPPATH/LOCAL_CPPDEFINES
189 MiscControls_text = ' '
190 if file_type.text == '1' and 'LOCAL_CFLAGS' in group_scons:
191 MiscControls_text = MiscControls_text + group_scons['LOCAL_CFLAGS']
192 elif file_type.text == '8' and 'LOCAL_CXXFLAGS' in group_scons:
193 MiscControls_text = MiscControls_text + group_scons['LOCAL_CXXFLAGS']
194 if 'LOCAL_CCFLAGS' in group_scons:
195 MiscControls_text = MiscControls_text + group_scons['LOCAL_CCFLAGS']
196 if MiscControls_text != ' ' or ('LOCAL_CPPDEFINES' in group_scons):
197 FileOption = SubElement(file, 'FileOption')
198 FileArmAds = SubElement(FileOption, 'FileArmAds')
199 Cads = SubElement(FileArmAds, 'Cads')
200 VariousControls = SubElement(Cads, 'VariousControls')
201 MiscControls = SubElement(VariousControls, 'MiscControls')
202 MiscControls.text = MiscControls_text
203 Define = SubElement(VariousControls, 'Define')
204 if 'LOCAL_CPPDEFINES' in group_scons:

Callers 1

MDK45ProjectFunction · 0.85

Calls 4

_make_path_relativeFunction · 0.90
_get_filetypeFunction · 0.85
setFunction · 0.50
joinMethod · 0.45

Tested by

no test coverage detected