| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 using System.Collections.Generic; | 4 using System.Collections.Generic; |
| 5 using System.Linq; | 5 using System.Linq; |
| 6 using System.Text; | 6 using System.Text; |
| 7 using System.Collections; | 7 using System.Collections; |
| 8 using System.IO; | 8 using System.IO; |
| 9 using System.Reflection; | 9 using System.Reflection; |
| 10 using System.Resources; | 10 using System.Resources; |
| 11 using System.Text.RegularExpressions; | 11 using System.Text.RegularExpressions; |
| 12 using System.Diagnostics; | 12 using System.Diagnostics; |
| 13 | 13 |
| 14 using Microsoft.Build.Framework; | 14 using Microsoft.Build.Framework; |
| 15 using Microsoft.Build.CPPTasks; | 15 using Microsoft.Build.CPPTasks; |
| 16 using Microsoft.Build.Utilities; | 16 using Microsoft.Build.Utilities; |
| 17 | 17 |
| 18 namespace NaCl.Build.CPPTasks | 18 namespace NaCl.Build.CPPTasks |
| 19 { | 19 { |
| 20 public class NaClLib : TrackedVCToolTask | 20 public class NaClLib : NaClToolTask |
| 21 { | 21 { |
| 22 public bool BuildingInIDE { get; set; } | |
| 23 | |
| 24 [Required] | 22 [Required] |
| 25 public string LibrarianToolPath { get; set; } | 23 public string LibrarianToolPath { get; set; } |
| 26 | 24 |
| 27 [Required] | 25 [Required] |
| 28 public string PropertiesFile { get; set; } | 26 public string PropertiesFile { get; set; } |
| 29 | 27 |
| 30 [Required] | |
| 31 public virtual string OutputFile { get; set; } | |
| 32 | |
| 33 [Required] | |
| 34 public string OutputCommandLine { get; set; } | |
| 35 | |
| 36 [Required] | |
| 37 public virtual ITaskItem[] Sources { get; set; } | |
| 38 | |
| 39 public NaClLib() | 28 public NaClLib() |
| 40 : base(new ResourceManager("NaCl.Build.CPPTasks.Properties.Resources
", Assembly.GetExecutingAssembly())) | 29 : base(new ResourceManager("NaCl.Build.CPPTasks.Properties.Resources
", Assembly.GetExecutingAssembly())) |
| 41 { | 30 { |
| 42 this.EnvironmentVariables = new string[] { "CYGWIN=nodosfilewarning",
"LC_CTYPE=C" }; | 31 this.EnvironmentVariables = new string[] { "CYGWIN=nodosfilewarning",
"LC_CTYPE=C" }; |
| 43 } | 32 } |
| 44 | 33 |
| 45 protected override string GenerateResponseFileCommands() | 34 protected override string GenerateResponseFileCommands() |
| 46 { | 35 { |
| 47 StringBuilder responseFileCmds = new StringBuilder(GCCUtilities.s_Co
mmandLineLength); | 36 StringBuilder responseFileCmds = new StringBuilder(GCCUtilities.s_Co
mmandLineLength); |
| 48 responseFileCmds.Append("rcs "); | 37 responseFileCmds.Append("rcs "); |
| 49 responseFileCmds.Append(GCCUtilities.ConvertPathWindowsToPosix(Outpu
tFile)); | 38 responseFileCmds.Append(GCCUtilities.ConvertPathWindowsToPosix(Outpu
tFile)); |
| 50 | 39 |
| 51 foreach (ITaskItem item in Sources) | 40 foreach (ITaskItem item in Sources) |
| 52 { | 41 { |
| 53 responseFileCmds.Append(" "); | 42 responseFileCmds.Append(" "); |
| 54 responseFileCmds.Append(GCCUtilities.ConvertPathWindowsToPosix(i
tem.ToString())); | 43 responseFileCmds.Append(GCCUtilities.ConvertPathWindowsToPosix(i
tem.ToString())); |
| 55 } | 44 } |
| 56 return responseFileCmds.ToString(); | 45 return responseFileCmds.ToString(); |
| 57 } | 46 } |
| 58 | 47 |
| 48 public override bool Execute() |
| 49 { |
| 50 if (!Setup()) |
| 51 return false; |
| 52 |
| 53 return base.Execute(); |
| 54 } |
| 55 |
| 59 protected override int ExecuteTool(string pathToTool, string responseFil
eCommands, string commandLineCommands) | 56 protected override int ExecuteTool(string pathToTool, string responseFil
eCommands, string commandLineCommands) |
| 60 { | 57 { |
| 61 if (OutputCommandLine == "true") | 58 if (OutputCommandLine) |
| 62 { | |
| 63 Log.LogMessage(MessageImportance.High, pathToTool + " " + respo
nseFileCommands); | 59 Log.LogMessage(MessageImportance.High, pathToTool + " " + respo
nseFileCommands); |
| 64 } | |
| 65 | 60 |
| 66 return base.ExecuteTool(pathToTool, responseFileCommands, commandLin
eCommands); | 61 return base.ExecuteTool(pathToTool, responseFileCommands, commandLin
eCommands); |
| 67 } | 62 } |
| 68 | 63 |
| 69 | |
| 70 | |
| 71 public virtual string PlatformToolset | |
| 72 { | |
| 73 get | |
| 74 { | |
| 75 return "GCC"; | |
| 76 } | |
| 77 } | |
| 78 | |
| 79 protected override bool MaintainCompositeRootingMarkers | |
| 80 { | |
| 81 get | |
| 82 { | |
| 83 return true; | |
| 84 } | |
| 85 } | |
| 86 | |
| 87 protected override ITaskItem[] TrackedInputFiles | |
| 88 { | |
| 89 get | |
| 90 { | |
| 91 return Sources; | |
| 92 } | |
| 93 } | |
| 94 | |
| 95 | |
| 96 protected override Encoding ResponseFileEncoding | 64 protected override Encoding ResponseFileEncoding |
| 97 { | 65 { |
| 98 get | 66 get |
| 99 { | 67 { |
| 100 return Encoding.ASCII; | 68 return Encoding.ASCII; |
| 101 } | 69 } |
| 102 } | 70 } |
| 103 | 71 |
| 104 protected override string ToolName | 72 protected override string ToolName |
| 105 { | 73 { |
| 106 get | 74 get |
| 107 { | 75 { |
| 108 return LibrarianToolPath; | 76 return LibrarianToolPath; |
| 109 } | 77 } |
| 110 } | 78 } |
| 111 | |
| 112 protected override string TrackerIntermediateDirectory | |
| 113 { | |
| 114 get | |
| 115 { | |
| 116 if (this.TrackerLogDirectory != null) | |
| 117 { | |
| 118 return this.TrackerLogDirectory; | |
| 119 } | |
| 120 else | |
| 121 { | |
| 122 return string.Empty; | |
| 123 } | |
| 124 } | |
| 125 } | |
| 126 | |
| 127 protected override string CommandTLogName | |
| 128 { | |
| 129 get | |
| 130 { | |
| 131 return "default.link.command.tlog"; | |
| 132 } | |
| 133 } | |
| 134 | |
| 135 protected override string[] ReadTLogNames | |
| 136 { | |
| 137 get | |
| 138 { | |
| 139 return new string[] | |
| 140 { | |
| 141 "default.link.read.tlog" | |
| 142 }; | |
| 143 } | |
| 144 } | |
| 145 | |
| 146 protected override string[] WriteTLogNames | |
| 147 { | |
| 148 get | |
| 149 { | |
| 150 return new string[] | |
| 151 { | |
| 152 "default.link.write.tlog" | |
| 153 }; | |
| 154 } | |
| 155 } | |
| 156 | |
| 157 public string TrackerLogDirectory { get; set; } | |
| 158 } | 79 } |
| 159 | |
| 160 | |
| 161 } | 80 } |
| OLD | NEW |