<?xml version="1.0" encoding="UTF-8"?>
<Config>
   <Tool Header="GCC" Desc="ARM Compiler"  ExitFail="0" SourceFilter="*.c" TargetFilter="ARM" ConfigPath="ARM\GCC.config" MsgFilter="{SPECFILE}: {SPECERROR}:{SPECMESSAGE}">
      <!-- Change locally Directories.IncDir to change include directrories separator ';' by " -I "-->
      <!-- Change locally Defines.Defines to change Defines separator ';' by " -D "-->
      <![CDATA[script
         {
         var includes = Tools.GetPropertyValue("", "Directories", "IncDir");
         includes =  "-I \"" + includes.replace(/;/g, "\" -I \"") + "\"";
         if(includes.length <= 3)
            includes  = "";
         Tools.SetPropertyValue("GCC", "General", "IncDir", includes);
         }
      ]]>
      <!-- do some local correction according to target STM3 specificities -->
      <![CDATA[script
         {
         var processor = Tools.GetPropertyValue("Target", "ProcessorARM", "Processor");
         //STM3
         if(processor.substr(0,4) == "STM3")
            {
            Tools.SetPropertyValue("Target", "ProcessorARM", "Thumb", "-mthumb");
            Tools.SetPropertyValue("Target", "ProcessorARM", "Interwork", " ");
            Tools.SetPropertyValue("GCC","Specific","CallStandard", " ");
            }
         }
      ]]>
      <!-- make sure output file and listing file directories exist before compiling -->
      <![CDATA[script
         {
         var outdir  = objFSO.GetParentFolderName(objFSO.GetAbsolutepathname(Tools.GetPropertyValue("NodeC", "Build",  "OutputFile")));
         var listdir = objFSO.GetParentFolderName(objFSO.GetAbsolutepathname(Tools.GetPropertyValue("NodeC", "Build", "ListingFile")));
         if(!objFSO.FolderExists(outdir))
           objFSO.CreateFolder(outdir);
         if(!objFSO.FolderExists(listdir))
           objFSO.CreateFolder(listdir);
         }
      ]]>
      <!-- Adjust the Processor Define value (remove CircleOS suffix) -->
      <![CDATA[script         
         {
         var proc_define = Tools.GetPropertyValue("Target", "ProcessorARM", "Processor");
         proc_define = proc_define.replace(/_CircleOS/, "");
         Tools.SetPropertyValue("GCC","Defines","ProcDefine", proc_define);
         }
      ]]>
      <!-- Compile and create dependencies file -->
      <![CDATA["$(Target.Tools.Execute)" -MD -D_$(GCC.Defines.ProcDefine)_ $(Target.ProcessorARM.ProcFamily) $(Target.ProcessorARM.ProcSubFamily) $(Target.ProcessorARM.Thumb) $(Target.ProcessorARM.Interwork) $(Target.ProcessorARM.Target) $(CmdInput) -o "$(NodeC.Build.OutputFile)" $(GCC.General.IncDir) -c $(GCC.Specific.CallStandard) $(GCC.Dialect.ANSI) $(GCC.Dialect.Traditional) $(GCC.Dialect.CharSign) $(GCC.Defines.Defines) $(GCC.DEBUG.DEBUGINFO) $(GCC.DEBUG.TEMP) $(GCC.CODE.ENUMS) $(GCC.CODE.DFLOAT) $(GCC.CODE.VEXTERNS) $(GCC.CODE.VPOINTERS) $(GCC.CODE.PACKSTRUCT) $(GCC.OPTIMIZE.Optimize) $(GCC.OPTIMIZE.IGNOREINLINE) $(GCC.OPTIMIZE.INLINEFUNC) $(GCC.OPTIMIZE.FUNCSECTIONS) $(GCC.WARNINGS.ANSISTRICT) $(GCC.WARNINGS.NOWARNINGS) $(GCC.WARNINGS.CONSWARNINGS) $(GCC.WARNINGS.SWITCHWARNINGS) $(GCC.WARNINGS.SHADOWARNINGS) $(GCC.WARNINGS.UNUSEDWARNINGS) $(GCC.MORE.MORE) -mlittle-endian]]>
      <!-- Make listing-->
      <![CDATA["$(RKitBin)\rexrdr.exe" "$(NodeC.Build.ListingFile)" 0 "$(RKitInst)arm-gcc\bin\arm-none-eabi-objdump.exe" --disassemble -all --source "$(NodeC.Build.OutputFile)"]]>
      <!-- arm-elf-size.exe to have code size info-->
      <![CDATA["$(RKitBin)\rexrdr.exe" "$(NodeC.Build.OutputFile).sizetmp" 0 "$(RKitInst)arm-gcc\bin\arm-none-eabi-size.exe" "$(NodeC.Build.OutputFile)"]]>
      <!-- make .dep file -->
      <![CDATA[script
         {
         var filename      =  Tools.GetPropertyValue("NodeC", "Build", "OutputFile");
         filename = objFSO.GetParentFolderName(filename) + "\\" + objFSO.GetBaseName(filename);
         filename = filename.replace(/\\/g, "\\\\");     // Replace "\" with "\\"
         GNUOutputManager( filename + ".d",  filename + ".o.sizetmp", filename + ".depxml");
         }
      ]]>
   </Tool>
   <Defs>
      <Set Header="GCC" Desc="GCC compiler"  Comment="Specifies the settings of the GNU optimizing C compiler.">
         <Section Header="General" Hidden="1">
            <Property Header="OutExt"  Type="PT_STRING" Value=".o" />
            <Property Header="ListExt" Type="PT_STRING" Value=".lst" />
            <Property Header="InExt"   Type="PT_STRING" Value="*.c" />
            <Property Header="IncDir"  Type="PT_STRING" Value="" />
         </Section>
         <Section Header="Specific" Desc="ARM Specific Options" Comment="Defines ARM specific options.">
            <Property Header="CallStandard" Major="1" Desc="ARM call conventions" Type="PT_CHOICE" Default="" Comment="Specifies whether the ARM procedure call conventions should be respected (-mapcs-frame)">
               <Enum Header="No" Value="" />
               <Enum Header="Yes" Value="-mapcs-frame" />
            </Property>
         </Section>
         <Section Header="Dialect" Desc="Dialect" Comment="C dialect to use">
            <Property Header="ANSI" Major="1" Desc="ANSI restricted" Type="PT_CHOICE" Default="" Comment="Restrict the compiler to ANSI standard C (-ansi)">
               <Enum Header="No" Value="" />
               <Enum Header="Yes" Value="-ansi" />
            </Property>
            <Property Header="Traditional" Major="1" Desc="Traditional C support" Type="PT_CHOICE" Default="" Comment="Support some aspects of traditional C compilers (-traditional)">
               <Enum Header="No" Value="" />
               <Enum Header="Yes" Value="-traditional" />
            </Property>
            <Property Header="CharSign" Major="1" Desc="Default 'char' type" Type="PT_CHOICE" Default="-fsigned-char" Comment="Specifies whether default type for 'char' is signed or unsigned (-fsigned-char)" >
               <Enum Header="signed" Value="-fsigned-char" />
               <Enum Header="unsigned" Value="-funsigned-char" />
            </Property>
         </Section>
         <Section Header="Defines" Desc="Defines" Comment="Define C preprocessor macros.">
            <Property Header="Defines" Major="1" Desc="Defines" Default="" Type="PT_EDITLIST" Comment="Add specific C preprocessor macro definitions on the command line (-d MACRO=value)" Pattern="-D %s "/>
            <Property Header="ProcDefine" Desc="Processor Define" Type="PT_STRING" Default="" Comment="" Hidden="1" />
         </Section>
         <Section Header="DEBUG" Desc="Compiler Output" Comment="Sets compiler output options.">
            <Property Header="DEBUGINFO" Major="1" Desc="Debugging Information" Type="PT_CHOICE" Default="-g" Comment="Generate debugging information in the object file (-g)">
               <Enum Header="Debug"        Value="-g"/>
               <Enum Header="No Debug"  Value=""/>
            </Property>
            <Property Header="TEMP" Major="1" Desc="Temp. files" Type="PT_CHOICE" Default="" Comment="Save temporary files (-save-temps)">
               <Enum Header="Don't save"   Value=""/>
               <Enum Header="Save"  Value="-save-temps"/>
            </Property>
         </Section>
         <Section Header="CODE" Desc="Code">
            <Property Header="ENUMS" Desc="Short enums" Type="PT_CHOICE" Default="" Comment="Allocate to an enum type only as many bytes as it needs (-fshort-enums)">
               <Enum Header="No" Value="" />
               <Enum Header="Yes" Value="-fshort-enums" />
            </Property>
            <Property Header="DFLOAT" Desc="Short doubles" Type="PT_CHOICE" Default="" Comment="Handle double as float (-fshort-double)">
               <Enum Header="No" Value="" />
               <Enum Header="Yes" Value="-fshort-double" />
            </Property>
            <Property Header="VPOINTERS" Desc="Volatile pointers" Type="PT_CHOICE" Default="" Comment="Consider pointers to be volatile (-fvolatile)">
               <Enum Header="No" Value="" />
               <Enum Header="Yes" Value="-fvolatile" />
            </Property>
            <Property Header="VEXTERNS" Desc="Volatile globals" Type="PT_CHOICE" Default="" Comment="Handle extern and global data as volatile (-fvolatile-global)" >
               <Enum Header="No" Value="" />
               <Enum Header="Yes" Value="-fvolatile-global" />
            </Property>
            <Property Header="PACKSTRUCT" Desc="Pack structure members" Type="PT_CHOICE" Default="" Comment="Pack all structure members, suppressing any holes (-fpack-struct)">
               <Enum Header="No" Value="" />
               <Enum Header="Yes" Value="-fpack-struct" />
            </Property>
         </Section>
         <Section Header="OPTIMIZE" Desc="Optimize">
            <Property Header="Optimize" Major="1" Desc="Optimization level" Type="PT_CHOICE" Default="-O1" Comment="Specifies the level of optimization for the file (-O)">
               <Enum Header="No optimization"    Value="" />
               <Enum Header="-O1"    Value="-O1" />
               <Enum Header="-O2"    Value="-O2" />
               <Enum Header="-O3"    Value="-O3" />
               <Enum Header="Size optimization" Value="-Os" />
            </Property>
            <Property Header="IGNOREINLINE" Major="1" Desc="Ignore Inline" Type="PT_CHOICE" Default="" Comment="Ignore the 'inline' keyword (-fno-inline)">
               <Enum Header="No" Value="" />
               <Enum Header="Yes" Value="-fno-inline" />
            </Property>
            <Property Header="INLINEFUNC" Major="1" Desc="Force Inline" Type="PT_CHOICE" Default="" Comment="Automatically inline all short functions into their callers (-finline-functions)">
               <Enum Header="No" Value="" />
               <Enum Header="Yes" Value="-finline-functions" />
            </Property>
            <Property Header="FUNCSECTIONS" Major="1" Desc="Per function sections" Type="PT_CHOICE" Default="-ffunction-sections" Comment="Use a separate section for each function (-ffunction-sections)">
               <Enum Header="No" Value="" />
               <Enum Header="Yes" Value="-ffunction-sections" />
            </Property>
         </Section>
         <Section Header="WARNINGS" Desc="Warnings">
            <Property Header="ANSISTRICT" Desc="Strict ANSI warnings" Type="PT_CHOICE" Default="" Comment="Issue strict ANSI warnings (-pedantic)">
               <Enum Header="No" Value="" />
               <Enum Header="Yes" Value="-pedantic" />
            </Property>
            <Property Header="NOWARNINGS" Desc="Inhibit warnings" Type="PT_CHOICE" Default="" Comment="Inhibit all warning messages (-w)" >
               <Enum Header="No" Value="" />
               <Enum Header="Yes" Value="-w" />
            </Property>
            <Property Header="CONSWARNINGS" Desc="All construction warnings" Type="PT_CHOICE" Default="" Comment="Enable all warnings (-Wall)" >
               <Enum Header="No" Value="" />
               <Enum Header="Yes" Value="-Wall" />
            </Property>
            <Property Header="SWITCHWARNINGS" Desc="'Switch' related warnings" Type="PT_CHOICE" Default="" Comment="Enables warnings about 'switch' statements lacking 'case' (-Wswitch)" >
               <Enum Header="No" Value="" />
               <Enum Header="Yes" Value="-Wswitch" />
            </Property>
            <Property Header="SHADOWARNINGS" Desc="Shadow variables warnings" Type="PT_CHOICE" Default="" Comment="Emits a warning whenever a local variable shadows another variable (-Wshadow)" >
               <Enum Header="No" Value="" />
               <Enum Header="Yes" Value="-Wshadow" />
            </Property>
            <Property Header="UNUSEDWARNINGS" Desc="Unused variables warnings" Type="PT_CHOICE" Default="" Comment="Emits a warning whenever a variable is unused (-Wunused)" >
               <Enum Header="No" Value="" />
               <Enum Header="Yes" Value="-Wunused" />
            </Property>
         </Section>
         <Section Header="More" Major="1" Desc="More" Comment="Defines specific command-line options.">
            <Property Header="More" Desc="More compiler options" Type="PT_EDITLIST" Comment="Specifies additional options to be added to GCC Compiler command line." Pattern="%s"/>
         </Section>
    </Set>
  </Defs>
</Config>
