is it possible to manipulate (read-modify-write) the compiler arguments (aka "Compiler defines") of an object?
How can I set global compiler arguments for the current project?
Thanks.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
\# Prints out all devices in the currently open project
\# and manipulates the compiler defines in the VICTIM object.
\# We enable the new python 3 print syntaxfrom__future__importprint_function
\# define the printing functiondefprinttree(treeobj,depth=0):Â Â name=treeobj.get_name(False)Â Â print("{0}- {1} {2} {3}".format("--"*depth,name,treeobj.effectively_excluded_from_build,treeobj.exclusion_from_build_is_inherited))Â Â props=treeobj.build_properties;Â Â ifprops:Â Â Â Â print("{0}Â + {1} {2} {3}".format("--"*depth,"external",props.external_is_valid,props.external_is_validandprops.external))Â Â Â Â print("{0}Â + {1} {2} {3}".format("--"*depth,"enable_system_call",props.enable_system_call_is_valid,props.enable_system_call_is_validandprops.enable_system_call))Â Â Â Â print("{0}Â + {1} {2} {3}".format("--"*depth,"compiler_defines",props.compiler_defines_is_valid,props.compiler_defines_is_validandprops.compiler_defines))Â Â Â Â print("{0}Â + {1} {2} {3}".format("--"*depth,"link_always",props.link_always_is_valid,props.link_always_is_validandprops.link_always))Â Â Â Â print("{0}Â + {1} {2} {3}".format("--"*depth,"exclude_from_build",props.exclude_from_build_is_valid,props.exclude_from_build_is_validandprops.exclude_from_build))Â Â Â forchildintreeobj.get_children(False):Â Â Â Â printtree(child,depth+1)forobjinprojects.primary.get_children():Â Â Â Â printtree(obj)
\# Find Object VICTIM in projecttreevictim=projects.primary.find("VICTIM",True)[0]props=victim.build_propertiesprops.external=notprops.externalprops.enable_system_call=notprops.enable_system_callprops.link_always=notprops.link_alwaysprops.exclude_from_build=notprops.exclude_from_buildif";FOOBAR"inprops.compiler_defines:Â Â Â Â props.compiler_defines=props.compiler_defines.replace(";FOOBAR","")else:Â Â Â Â props.compiler_defines=props.compiler_defines+";FOOBAR"print("--- Script finished. ---")
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
is it possible to manipulate (read-modify-write) the compiler arguments (aka "Compiler defines") of an object?
How can I set global compiler arguments for the current project?
Thanks.
Yes it is possible. Here the example code of 3S.