Skip to content

Commit c99fc8e

Browse files
committed
No longer assume that flags are present when removing them in exporters
1 parent 7599e88 commit c99fc8e

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

tools/export/iar.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
from tools.export.exporters import Exporter, ExporterTargetsProperty
2222
from tools.targets import TARGET_MAP, TARGET_NAMES
23+
from tools.utils import remove_when_present
2324

2425
# If you wish to add a new target, add it to project_generator_definitions, and then
2526
# define progen_target name in the target class (`` self.progen_target = 'my_target_name' ``)
@@ -63,7 +64,7 @@ def generate(self):
6364

6465
project_data['misc'] = self.flags
6566
# VLA is enabled via template IccAllowVLA
66-
project_data['misc']['c_flags'].remove("--vla")
67+
remove_when_present(project_data['misc']['c_flags'], ("--vla"))
6768
project_data['build_dir'] = os.path.join(project_data['build_dir'], 'iar_arm')
6869
self.progen_gen_file(project_data)
6970

tools/export/uvision4.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
from tools.export.exporters import Exporter, ExporterTargetsProperty
2121
from tools.targets import TARGET_MAP, TARGET_NAMES
22+
from tools.utils import remove_when_present
2223

2324
# If you wish to add a new target, add it to project_generator_definitions, and then
2425
# define progen_target name in the target class (`` self.progen_target = 'my_target_name' ``)
@@ -84,11 +85,11 @@ def generate(self):
8485
+ self.flags['c_flags']
8586
+ self.flags['cxx_flags']))
8687
# not compatible with c99 flag set in the template
87-
project_data['misc']['c_flags'].remove("--c99")
88+
remove_when_present(project_data['misc']['c_flags'], "--c99")
8889
# cpp is not required as it's implicit for cpp files
89-
project_data['misc']['c_flags'].remove("--cpp")
90+
remove_when_present(project_data['misc']['c_flags'], "--cpp")
9091
# we want no-vla for only cxx, but it's also applied for C in IDE, thus we remove it
91-
project_data['misc']['c_flags'].remove("--no_vla")
92+
remove_when_present(project_data['misc']['c_flags'], "--no_vla")
9293
project_data['misc']['ld_flags'] = self.flags['ld_flags']
9394

9495
project_data['build_dir'] = project_data['build_dir'] + '\\' + 'uvision4'

tools/export/uvision5.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
from tools.export.exporters import Exporter, ExporterTargetsProperty
2121
from tools.targets import TARGET_MAP, TARGET_NAMES
22+
from tools.utils import remove_when_present
2223

2324
# If you wish to add a new target, add it to project_generator_definitions, and then
2425
# define progen_target name in the target class (`` self.progen_target = 'my_target_name' ``)
@@ -84,11 +85,11 @@ def generate(self):
8485
+ self.flags['c_flags']
8586
+ self.flags['cxx_flags']))
8687
# not compatible with c99 flag set in the template
87-
project_data['misc']['c_flags'].remove("--c99")
88+
remove_when_present(project_data['misc']['c_flags'], ("--c99"))
8889
# cpp is not required as it's implicit for cpp files
89-
project_data['misc']['c_flags'].remove("--cpp")
90+
remove_when_present(project_data['misc']['c_flags'], ("--cpp"))
9091
# we want no-vla for only cxx, but it's also applied for C in IDE, thus we remove it
91-
project_data['misc']['c_flags'].remove("--no_vla")
92+
remove_when_present(project_data['misc']['c_flags'], ("--no_vla"))
9293
project_data['misc']['ld_flags'] = self.flags['ld_flags']
9394

9495
i = 0

tools/utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,3 +470,7 @@ def parse_type(not_parent):
470470
else:
471471
return not_parent
472472
return parse_type
473+
474+
def remove_when_present(list, thing):
475+
if thing in list:
476+
list.remove(thing)

0 commit comments

Comments
 (0)