diff --git a/tools/export/uvision4.py b/tools/export/uvision4.py index 1bc41e46a9..02c630f26d 100644 --- a/tools/export/uvision4.py +++ b/tools/export/uvision4.py @@ -19,6 +19,7 @@ from project_generator_definitions.definitions import ProGenDef from tools.export.exporters import Exporter, ExporterTargetsProperty from tools.targets import TARGET_MAP, TARGET_NAMES +from tools.utils import remove_if_in # If you wish to add a new target, add it to project_generator_definitions, and then # define progen_target name in the target class (`` self.progen_target = 'my_target_name' ``) @@ -87,11 +88,11 @@ class Uvision4(Exporter): + self.flags['c_flags'] + self.flags['cxx_flags'])) # not compatible with c99 flag set in the template - project_data['misc']['c_flags'].remove("--c99") + remove_if_in(project_data['misc']['c_flags'], "--c99") # cpp is not required as it's implicit for cpp files - project_data['misc']['c_flags'].remove("--cpp") + remove_if_in(project_data['misc']['c_flags'], "--cpp") # we want no-vla for only cxx, but it's also applied for C in IDE, thus we remove it - project_data['misc']['c_flags'].remove("--no_vla") + remove_if_in(project_data['misc']['c_flags'], "--no_vla") project_data['misc']['ld_flags'] = self.flags['ld_flags'] project_data['build_dir'] = project_data['build_dir'] + '\\' + 'uvision4' diff --git a/tools/export/uvision5.py b/tools/export/uvision5.py index ab04ffd9dd..5b4a6756e0 100644 --- a/tools/export/uvision5.py +++ b/tools/export/uvision5.py @@ -19,6 +19,7 @@ from project_generator_definitions.definitions import ProGenDef from tools.export.exporters import Exporter, ExporterTargetsProperty from tools.targets import TARGET_MAP, TARGET_NAMES +from tools.utils import remove_if_in # If you wish to add a new target, add it to project_generator_definitions, and then # define progen_target name in the target class (`` self.progen_target = 'my_target_name' ``) @@ -83,14 +84,12 @@ class Uvision5(Exporter): + self.flags['c_flags'] + self.flags['cxx_flags'])) # not compatible with c99 flag set in the template - try:project_data['misc']['c_flags'].remove("--c99") - except ValueError: pass + remove_if_in(project_data['misc']['c_flags'], "--c99") # cpp is not required as it's implicit for cpp files - try:project_data['misc']['c_flags'].remove("--cpp") - except ValueError: pass - # we want no-vla for only cxx, but it's also applied for C in IDE, thus we remove it= - try:project_data['misc']['c_flags'].remove("--no_vla") - except ValueError: pass + remove_if_in(project_data['misc']['c_flags'], "--cpp") + # we want no-vla for only cxx, but it's also applied for C in IDE, thus we remove it + remove_if_in(project_data['misc']['c_flags'], "--no_vla") + # not compatible with c99 flag set in the template project_data['misc']['ld_flags'] = self.flags['ld_flags'] i = 0 diff --git a/tools/utils.py b/tools/utils.py index b250491dc0..9ad74de63d 100644 --- a/tools/utils.py +++ b/tools/utils.py @@ -28,6 +28,10 @@ import json from collections import OrderedDict import logging +def remove_if_in(lst, thing): + if thing in lst: + lst.remove(thing) + def compile_worker(job): """Standard task runner used for compiling