Skip to content

Commit 3408e25

Browse files
JarnoEttadbridge
authored andcommitted
Review changes + including config header from toolchain.get_config_header() instead of hardcoding it to project file.
1 parent c2eafc9 commit 3408e25

File tree

2 files changed

+34
-21
lines changed

2 files changed

+34
-21
lines changed

tools/export/sw4stm32/__init__.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
limitations under the License.
1616
"""
1717

18+
import copy
19+
1820
from os import walk, sep
19-
from os.path import splitext, basename, join, dirname
21+
from os.path import splitext, basename, join, dirname, relpath
2022
from random import randint
2123
from tools.utils import mkdir
2224
from tools.export.exporters import Exporter
@@ -251,7 +253,7 @@ class Sw4STM32(Exporter):
251253

252254
def __gen_dir(self, dir_name):
253255
"""
254-
Method that created directory
256+
Method that creates directory
255257
"""
256258
settings = join(self.export_dir, dir_name)
257259
mkdir(settings)
@@ -268,9 +270,9 @@ def filter_dot(path):
268270
This function removes ./ from str.
269271
str must be converted with win_to_unix() before using this function.
270272
"""
271-
if path is None:
272-
return None
273-
if path[:2] == './':
273+
if not path:
274+
return path
275+
if path.startswith('./'):
274276
return path[2:]
275277
return path
276278

@@ -302,15 +304,12 @@ def remove_unused(self, path):
302304
Method adds path to excluded list if not needed
303305
and is not subdirectory of already excluded directory
304306
"""
305-
found = False
306-
for used in self.include_path:
307-
if path == used:
308-
found = True
307+
found = path in self.include_path
309308
needtoadd = True
310309
if not found:
311310
for directory in self.exclude_dirs:
312-
# Do not exclude subfolders from excluded folder
313-
if path.find(directory+'/') != -1:
311+
# Do not exclude subfolders from excluded folder
312+
if directory+'/' in path:
314313
needtoadd = False
315314
if needtoadd:
316315
self.exclude_dirs.append(path)
@@ -326,6 +325,8 @@ def generate(self):
326325
fp_hardware = "fpv5-d16"
327326
fp_abi = "softfp"
328327

328+
config_header = self.filter_dot(self.toolchain.get_config_header())
329+
329330
self.resources.win_to_unix()
330331

331332
libraries = []
@@ -346,7 +347,6 @@ def generate(self):
346347

347348
ld_script = self.filter_dot(self.resources.linker_script)
348349

349-
# self.lib_dirs = [self.filter_dot(s) for s in self.resources.lib_dirs]
350350
lib_dirs = [self.filter_dot(s) for s in self.resources.lib_dirs]
351351

352352
symbols = [s.replace('"', '"')
@@ -355,6 +355,7 @@ def generate(self):
355355
ctx = {
356356
'name': self.project_name,
357357
'include_paths': self.include_path,
358+
'config_header': config_header,
358359
'exclude_paths': self.exclude_dirs,
359360
'linker_script': ld_script,
360361
'library_paths': lib_dirs,
@@ -363,8 +364,6 @@ def generate(self):
363364
'symbols': symbols,
364365
'board_name': self.BOARDS[self.target.upper()]['name'],
365366
'mcu_name': self.BOARDS[self.target.upper()]['mcuId'],
366-
'c_include_uid': self.__generate_uid(),
367-
'cpp_include_uid': self.__generate_uid(),
368367
'debug_config_uid': self.__generate_uid(),
369368
'debug_tool_compiler_uid': self.__generate_uid(),
370369
'debug_tool_compiler_input_uid': self.__generate_uid(),

tools/export/sw4stm32/cproject_common.tmpl

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@
3636
<listOptionValue builtIn="false" value="{{s}}"/>
3737
{% endfor %}
3838
</option>
39-
<option id="gnu.c.compiler.option.include.files.{{c_include_uid}}" name="Include files (-include)" superClass="gnu.c.compiler.option.include.files" useByScannerDiscovery="false" valueType="includeFiles">
40-
<listOptionValue builtIn="false" value="${ProjDirPath}/mbed_config.h"/>
39+
{% if config_header %}
40+
<option id="gnu.c.compiler.option.include.files.{{uid}}" name="Include files (-include)" superClass="gnu.c.compiler.option.include.files" useByScannerDiscovery="false" valueType="includeFiles">
41+
<listOptionValue builtIn="false" value="${ProjDirPath}/{{config_header}}"/>
4142
</option>
43+
{% endif %}
4244
<inputType id="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.input.c.{{release_tool_compiler_input_uid}}" superClass="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.input.c"/>
4345
<inputType id="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.input.s.{{uid}}" superClass="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.input.s"/>
4446
</tool>
@@ -56,9 +58,11 @@
5658
<listOptionValue builtIn="false" value="{{s}}"/>
5759
{% endfor %}
5860
</option>
59-
<option id="gnu.cpp.compiler.option.include.files.{{cpp_include_uid}}" name="Include files (-include)" superClass="gnu.cpp.compiler.option.include.files" useByScannerDiscovery="false" valueType="includeFiles">
60-
<listOptionValue builtIn="false" value="${ProjDirPath}/mbed_config.h"/>
61-
</option>
61+
{% if config_header %}
62+
<option id="gnu.cpp.compiler.option.include.files.{{uid}}" name="Include files (-include)" superClass="gnu.cpp.compiler.option.include.files" useByScannerDiscovery="false" valueType="includeFiles">
63+
<listOptionValue builtIn="false" value="${ProjDirPath}/{{config_header}}"/>
64+
</option>
65+
{% endif %}
6266
<inputType id="fr.ac6.managedbuild.tool.gnu.cross.cpp.compiler.input.cpp.{{uid}}" superClass="fr.ac6.managedbuild.tool.gnu.cross.cpp.compiler.input.cpp"/>
6367
<inputType id="fr.ac6.managedbuild.tool.gnu.cross.cpp.compiler.input.s.{{uid}}" superClass="fr.ac6.managedbuild.tool.gnu.cross.cpp.compiler.input.s"/>
6468
</tool>
@@ -103,7 +107,7 @@
103107
</toolChain>
104108
</folderInfo>
105109
<sourceEntries>
106-
<entry excluding="{{exclude_paths}}" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
110+
<entry excluding="{{exclude_paths}}|Debug|Release" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
107111
</sourceEntries>
108112
</configuration>
109113
</storageModule>
@@ -142,6 +146,11 @@
142146
<listOptionValue builtIn="false" value="{{s}}"/>
143147
{% endfor %}
144148
</option>
149+
{% if config_header %}
150+
<option id="gnu.c.compiler.option.include.files.{{uid}}" name="Include files (-include)" superClass="gnu.c.compiler.option.include.files" useByScannerDiscovery="false" valueType="includeFiles">
151+
<listOptionValue builtIn="false" value="${ProjDirPath}/{{config_header}}"/>
152+
</option>
153+
{% endif %}
145154
<inputType id="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.input.c.{{debug_tool_compiler_input_uid}}" superClass="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.input.c"/>
146155
<inputType id="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.input.s.{{uid}}" superClass="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.input.s"/>
147156
</tool>
@@ -158,6 +167,11 @@
158167
<listOptionValue builtIn="false" value="{{s}}"/>
159168
{% endfor %}
160169
</option>
170+
{% if config_header %}
171+
<option id="gnu.cpp.compiler.option.include.files.{{uid}}" name="Include files (-include)" superClass="gnu.c.compiler.option.include.files" useByScannerDiscovery="false" valueType="includeFiles">
172+
<listOptionValue builtIn="false" value="${ProjDirPath}/{{config_header}}"/>
173+
</option>
174+
{% endif %}
161175
<inputType id="fr.ac6.managedbuild.tool.gnu.cross.cpp.compiler.input.cpp.{{uid}}" superClass="fr.ac6.managedbuild.tool.gnu.cross.cpp.compiler.input.cpp"/>
162176
<inputType id="fr.ac6.managedbuild.tool.gnu.cross.cpp.compiler.input.s.{{uid}}" superClass="fr.ac6.managedbuild.tool.gnu.cross.cpp.compiler.input.s"/>
163177
</tool>
@@ -203,7 +217,7 @@
203217
</toolChain>
204218
</folderInfo>
205219
<sourceEntries>
206-
<entry excluding="{{exclude_paths}}" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
220+
<entry excluding="{{exclude_paths}}|Debug|Release" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
207221
</sourceEntries>
208222
</configuration>
209223
</storageModule>

0 commit comments

Comments
 (0)