<?xml version="1.0" encoding="UTF-8"?>
<Config>
   <Tool Header="AS" Desc="ARM Assembler" ExitFail="0" SourceFilter="*.s" TargetFilter="ARM" ConfigPath="ARM\AS.config" MsgFilter="{SPECFILE}:{SPECERROR}:{SPECMESSAGE}">
      <!-- Change localy Directories.IncDir to change include directrories separator ';' by " -I "-->
      <![CDATA[script
         {
         var includes = Tools.GetPropertyValue("", "Directories", "IncDir");
         includes =  "-I \"" + includes.replace(/;/g, "\" -I \"") + "\"";
         Tools.SetPropertyValue("AS", "General", "IncDir", includes);
         }
      ]]>
      <!-- do some local correction according to target STM3 specificities -->
      <![CDATA[script
         {
         var processor = Tools.GetPropertyValue("Target", "ProcessorARM", "Processor");
         //STM3
         if( (processor.charAt(0) == "S") && (processor.charAt(1) == "T") && (processor.charAt(2) == "M") && (processor.charAt(3) == "3") )
            {
            Tools.SetPropertyValue("Target", "ProcessorARM", "Thumb", "-mthumb");
            Tools.SetPropertyValue("Target", "ProcessorARM", "Interwork", " ");
            }
         }
      ]]>
     <!-- make sure output file and listing file directories exist before assembling -->
     <![CDATA[script
        {
        var outdir  = objFSO.GetParentFolderName(objFSO.GetAbsolutepathname(Tools.GetPropertyValue("NodeASM", "Build", "OutputFile")));
        var listdir = objFSO.GetParentFolderName(objFSO.GetAbsolutepathname(Tools.GetPropertyValue("NodeASM", "Build", "ListingFile")));
        if(!objFSO.FolderExists(outdir))
           objFSO.CreateFolder(outdir);
        if(!objFSO.FolderExists(listdir))
           objFSO.CreateFolder(listdir);
        }
     ]]>
      <!-- Assemble and create dependencies file -->
      <![CDATA["$(Target.Tools.Execute)" -MD -D_$(Target.ProcessorARM.Processor)_ $(Target.ProcessorARM.ProcSubFamily) $(Target.ProcessorARM.Target) $(CmdInput) -o "$(NodeASM.Build.OutputFile)" $(AS.General.IncDir) -c -Wa,-EL $(AS.Options.Debug) $(AS.Options.LocalLabel) $(AS.Options.Warnings) $(Target.ProcessorARM.Thumb) $(AS.Options.More)]]>
      <!-- Make listing-->
      <![CDATA["$(RKitBin)\rexrdr.exe" "$(NodeASM.Build.ListingFile)" 0 "$(RKitInst)arm-gcc\bin\arm-none-eabi-objdump.exe" --disassemble -all --source "$(NodeASM.Build.OutputFile)"]]>
      <!-- arm-elf-size.exe to have code size info-->
      <![CDATA["$(RKitBin)\rexrdr.exe" "$(NodeASM.Build.OutputFile).sizetmp" 0 "$(RKitInst)arm-gcc\bin\arm-none-eabi-size.exe" "$(NodeASM.Build.OutputFile)"]]>
      <!-- make .dep file -->
      <![CDATA[script
         {
         var filename      =  Tools.GetPropertyValue("NodeASM", "Build", "OutputFile");
         filename = filename.replace(/\\/g, "\\\\");     // Replace "\" with "\\"
         filename = filename.replace(".o", "");
         GNUOutputManager( filename + ".d",  filename + ".o.sizetmp", filename + ".depxml");
         }
      ]]>
   </Tool>
   <Defs>
      <Set Header="AS" Desc="AS assembler" Comment="Specifies assembler settings.">
         <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=".s"/>
            <Property Header="InFilter" Type="PT_STRING" Value="*.s"/>
            <Property Header="IncDir" Type="PT_STRING" Value=""/>
         </Section>
         <Section Header="Options" Desc="Assembler options" Comment="Specifies the GNU assembler settings.">
            <Property Header="Debug" Desc="Debug" Type="PT_CHOICE" Default="" Comment="Include debug information (-gdwarf2)">
               <Enum Header="No" Value=""/>
               <Enum Header="Yes" Value="-Wa,-gdwarf2"/>
            </Property>
            <Property Header="LocalLabel" Desc="Local Label C" Type="PT_CHOICE" Default="" Comment="Include local Labels (-L)">
               <Enum Header="No" Value=""/>
               <Enum Header="Yes" Value="-Wa,-L"/>
            </Property>
            <Property Header="Warnings" Desc="Warnings" Type="PT_CHOICE" Default="" Comment="Activates warnings (-W)">
               <Enum Header="No" Value=""/>
               <Enum Header="Yes" Value="-Wa,-W"/>
            </Property>
            <Property Header="More" Desc="Additional options" Type="PT_EDITLIST" Comment="Defines specific command-line options." Pattern="%s"/>
         </Section>
      </Set>
   </Defs>
</Config>
