| OLD | NEW | 
|---|
| 1 using System; | 1 using System; | 
| 2 using System.Collections.Generic; | 2 using System.Collections.Generic; | 
| 3 using System.Linq; | 3 using System.Linq; | 
| 4 using System.Text; | 4 using System.Text; | 
|  | 5 using System.IO; | 
| 5 | 6 | 
| 6 using Microsoft.Build.Framework; | 7 using Microsoft.Build.Framework; | 
| 7 using System.Xaml; | 8 using System.Xaml; | 
| 8 using Microsoft.Build.Framework.XamlTypes; | 9 using Microsoft.Build.Framework.XamlTypes; | 
| 9 using Microsoft.Build.Utilities; | 10 using Microsoft.Build.Utilities; | 
| 10 | 11 | 
| 11 namespace NaCl.Build.CPPTasks | 12 namespace NaCl.Build.CPPTasks | 
| 12 { | 13 { | 
| 13     class XamlParser | 14     class XamlParser | 
| 14     { | 15     { | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
| 32 | 33 | 
| 33             InitFunctionMap(); | 34             InitFunctionMap(); | 
| 34         } | 35         } | 
| 35 | 36 | 
| 36         private void InitFunctionMap() | 37         private void InitFunctionMap() | 
| 37         { | 38         { | 
| 38             m_typeFunctionMap = new Dictionary<Type, Action<CommandLineBuilder, 
     BaseProperty, string>> | 39             m_typeFunctionMap = new Dictionary<Type, Action<CommandLineBuilder, 
     BaseProperty, string>> | 
| 39             { | 40             { | 
| 40                 { typeof(StringListProperty), GenerateArgumentStringList }, | 41                 { typeof(StringListProperty), GenerateArgumentStringList }, | 
| 41                 { typeof(StringProperty), GenerateArgumentString }, | 42                 { typeof(StringProperty), GenerateArgumentString }, | 
| 42                 { typeof(IntProperty), GenerateArgumentString }, | 43                 { typeof(IntProperty), GenerateArgumentInt }, | 
| 43                 { typeof(BoolProperty), GenerateArgumentBool }, | 44                 { typeof(BoolProperty), GenerateArgumentBool }, | 
| 44                 { typeof(EnumProperty), GenerateArgumentEnum } | 45                 { typeof(EnumProperty), GenerateArgumentEnum } | 
| 45             }; | 46             }; | 
| 46         } | 47         } | 
| 47 | 48 | 
| 48         public string Parse(ITaskItem taskItem) | 49         public string Parse(ITaskItem taskItem, bool fullOutputName) | 
| 49         { | 50         { | 
| 50             CommandLineBuilder builder = new CommandLineBuilder(); | 51             CommandLineBuilder builder = new CommandLineBuilder(); | 
| 51 | 52 | 
| 52             foreach (string name in taskItem.MetadataNames) | 53             foreach (string name in taskItem.MetadataNames) | 
| 53             { | 54             { | 
| 54                 string value = taskItem.GetMetadata(name); | 55                 string value = taskItem.GetMetadata(name); | 
|  | 56                 if (fullOutputName && name == "ObjectFileName") | 
|  | 57                 { | 
|  | 58                     if ((File.GetAttributes(value) & FileAttributes.Directory) !
     = 0) | 
|  | 59                     { | 
|  | 60                         value = Path.Combine(value, Path.GetFileName(taskItem.It
     emSpec)); | 
|  | 61                         value = Path.ChangeExtension(value, ".obj"); | 
|  | 62                     } | 
|  | 63                 } | 
| 55                 AppendArgumentForProperty(builder, name, value); | 64                 AppendArgumentForProperty(builder, name, value); | 
| 56             } | 65             } | 
| 57 | 66 | 
| 58             string result = builder.ToString(); | 67             string result = builder.ToString(); | 
| 59             result = result.Replace('\\', '/'); // posix paths | 68             result = result.Replace('\\', '/'); // posix paths | 
| 60             return result; | 69             return result; | 
| 61         } | 70         } | 
| 62 | 71 | 
| 63         private string AppendArgumentForProperty(CommandLineBuilder builder, str
     ing name, string value) | 72         private string AppendArgumentForProperty(CommandLineBuilder builder, str
     ing name, string value) | 
| 64         { | 73         { | 
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 119             } | 128             } | 
| 120         } | 129         } | 
| 121 | 130 | 
| 122         private void GenerateArgumentString(CommandLineBuilder builder, BaseProp
     erty property, string value) | 131         private void GenerateArgumentString(CommandLineBuilder builder, BaseProp
     erty property, string value) | 
| 123         { | 132         { | 
| 124             // could cache this SubType test off in property wrapper or somewher
     e if performance were an issue | 133             // could cache this SubType test off in property wrapper or somewher
     e if performance were an issue | 
| 125             StringProperty casted = (StringProperty)property; | 134             StringProperty casted = (StringProperty)property; | 
| 126             AppendStringValue(builder, property, casted.Subtype, value); | 135             AppendStringValue(builder, property, casted.Subtype, value); | 
| 127         } | 136         } | 
| 128 | 137 | 
|  | 138         private void GenerateArgumentInt(CommandLineBuilder builder, BasePropert
     y property, string value) | 
|  | 139         { | 
|  | 140             // Currently we only have one Int property and it doesn't correspond
      to a | 
|  | 141             // command line arguemnt (ProcessorNumber) so we ignore it here. | 
|  | 142         } | 
|  | 143 | 
| 129         private void GenerateArgumentBool(CommandLineBuilder builder, BaseProper
     ty property, string value) | 144         private void GenerateArgumentBool(CommandLineBuilder builder, BaseProper
     ty property, string value) | 
| 130         { | 145         { | 
| 131             if (value == "true") | 146             if (value == "true") | 
| 132             { | 147             { | 
| 133                 builder.AppendSwitchUnquotedIfNotNull(m_parsedBuildRule.SwitchPr
     efix, property.Switch); | 148                 builder.AppendSwitchUnquotedIfNotNull(m_parsedBuildRule.SwitchPr
     efix, property.Switch); | 
| 134             } | 149             } | 
| 135             else if (value == "false" && ((BoolProperty)property).ReverseSwitch 
     != null) | 150             else if (value == "false" && ((BoolProperty)property).ReverseSwitch 
     != null) | 
| 136             { | 151             { | 
| 137                 builder.AppendSwitchUnquotedIfNotNull(m_parsedBuildRule.SwitchPr
     efix, ((BoolProperty)property).ReverseSwitch); | 152                 builder.AppendSwitchUnquotedIfNotNull(m_parsedBuildRule.SwitchPr
     efix, ((BoolProperty)property).ReverseSwitch); | 
| 138             } | 153             } | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
| 151         } // class | 166         } // class | 
| 152 | 167 | 
| 153         private Rule m_parsedBuildRule; | 168         private Rule m_parsedBuildRule; | 
| 154         private Dictionary<string, PropertyWrapper> ToolProperties { get; set; } | 169         private Dictionary<string, PropertyWrapper> ToolProperties { get; set; } | 
| 155 | 170 | 
| 156         // function mapping for easy property function calling | 171         // function mapping for easy property function calling | 
| 157         private Dictionary<Type, Action<CommandLineBuilder, BaseProperty, string
     >> m_typeFunctionMap; | 172         private Dictionary<Type, Action<CommandLineBuilder, BaseProperty, string
     >> m_typeFunctionMap; | 
| 158     } // XamlParser | 173     } // XamlParser | 
| 159 } // namespace NaCl.Build.CPPTasks | 174 } // namespace NaCl.Build.CPPTasks | 
| 160 | 175 | 
| OLD | NEW | 
|---|