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; | 4 using System; |
5 using System.Collections.Generic; | 5 using System.Collections.Generic; |
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.Windows.Forms; | 11 using System.Windows.Forms; |
12 using Microsoft.Build.Framework; | 12 using Microsoft.Build.Framework; |
13 using Microsoft.Win32; | 13 using Microsoft.Win32; |
14 using Microsoft.Build.Utilities; | 14 using Microsoft.Build.Utilities; |
15 using System.Collections.Specialized; | 15 using System.Collections.Specialized; |
16 | 16 |
17 using System.Diagnostics; | 17 using System.Diagnostics; |
18 | 18 |
19 namespace NaCl.Build.CPPTasks | 19 namespace NaCl.Build.CPPTasks |
20 { | 20 { |
21 public abstract class NaClToolTask : ToolTask | 21 public abstract class NaClToolTask : ToolTask |
22 { | 22 { |
Sam Clegg
2012/11/12 20:10:36
Almost all the changes to this file come from the
| |
23 protected NaClToolTask(ResourceManager taskResources) : base(taskResourc es) { } | 23 protected NaClToolTask(ResourceManager taskResources) : base(taskResourc es) { } |
24 public bool BuildingInIDE { get; set; } | |
24 protected ITaskItem[] excludedInputPaths; | 25 protected ITaskItem[] excludedInputPaths; |
25 private ITaskItem[] tlogReadFiles; | 26 private ITaskItem[] tlogReadFiles; |
26 private ITaskItem tlogCommandFile; | 27 private ITaskItem tlogCommandFile; |
27 private ITaskItem[] tlogWriteFiles; | 28 private ITaskItem[] tlogWriteFiles; |
28 private CanonicalTrackedInputFiles trackedInputFiles; | 29 private CanonicalTrackedInputFiles trackedInputFiles; |
29 private bool skippedExecution; | 30 private bool skippedExecution; |
30 private bool minimalRebuildFromTracking; | 31 private bool minimalRebuildFromTracking; |
31 private bool trackFileAccess; | 32 private bool trackFileAccess; |
32 protected ITaskItem[] compileSourceList; | 33 protected ITaskItem[] compileSourceList; |
33 protected XamlParser xamlParser; | 34 protected XamlParser xamlParser; |
34 | 35 |
35 protected abstract CanonicalTrackedOutputFiles OutputWriteTLog(ITaskItem [] compiledSources); | |
36 protected abstract void OutputReadTLog(ITaskItem[] compiledSources, Cano nicalTrackedOutputFiles outputs); | |
37 protected abstract void OutputCommandTLog(ITaskItem[] compiledSources); | |
38 | |
39 [Required] | 36 [Required] |
40 public string TrackerLogDirectory { get; set; } | 37 public string TrackerLogDirectory { get; set; } |
41 | 38 |
42 [Required] | 39 [Required] |
43 public virtual ITaskItem[] Sources { get; set; } | 40 public virtual ITaskItem[] Sources { get; set; } |
44 | 41 |
42 [Required] | |
43 public bool OutputCommandLine { get; set; } | |
44 | |
45 [Required] | |
46 public string Platform { get; set; } | |
47 | |
48 public virtual string OutputFile { get; set; } | |
45 | 49 |
46 // Override default StandardOutputLoggingImportance so that we see the s tdout from the | 50 // Override default StandardOutputLoggingImportance so that we see the s tdout from the |
47 // toolchain from within visual studio. | 51 // toolchain from within visual studio. |
48 protected override MessageImportance StandardOutputLoggingImportance | 52 protected override MessageImportance StandardOutputLoggingImportance |
49 { | 53 { |
50 get { return MessageImportance.Normal; } | 54 get { return MessageImportance.Normal; } |
51 } | 55 } |
52 | 56 |
53 protected bool ForcedRebuildRequired() | 57 protected bool ForcedRebuildRequired() |
54 { | 58 { |
(...skipping 25 matching lines...) Expand all Loading... | |
80 protected override bool SkipTaskExecution() | 84 protected override bool SkipTaskExecution() |
81 { | 85 { |
82 return this.skippedExecution; | 86 return this.skippedExecution; |
83 } | 87 } |
84 | 88 |
85 protected string BaseTool() | 89 protected string BaseTool() |
86 { | 90 { |
87 return Path.GetFileNameWithoutExtension(ToolName); | 91 return Path.GetFileNameWithoutExtension(ToolName); |
88 } | 92 } |
89 | 93 |
94 protected bool IsPNaCl() | |
95 { | |
96 return Platform.Equals("pnacl", StringComparison.OrdinalIgnoreCase); | |
97 } | |
98 | |
90 protected bool Setup() | 99 protected bool Setup() |
91 { | 100 { |
92 this.SkippedExecution = false; | 101 this.SkippedExecution = false; |
93 | 102 |
94 if (!ValidateParameters()) | 103 if (!ValidateParameters()) |
95 { | 104 { |
96 return false; | 105 return false; |
97 } | 106 } |
98 | 107 |
108 if (IsPNaCl()) | |
109 { | |
110 if (!SDKUtilities.FindPython()) | |
111 { | |
112 Log.LogError("PNaCl linking requires python in your executab le path."); | |
113 return false; | |
114 } | |
115 } | |
116 | |
99 if (this.TrackFileAccess || this.MinimalRebuildFromTracking) | 117 if (this.TrackFileAccess || this.MinimalRebuildFromTracking) |
100 { | 118 { |
101 this.SetTrackerLogPaths(); | 119 this.SetTrackerLogPaths(); |
102 } | 120 } |
103 | 121 |
104 if (this.ForcedRebuildRequired() || this.MinimalRebuildFromTracking == false) | 122 if (this.ForcedRebuildRequired() || this.MinimalRebuildFromTracking == false) |
105 { | 123 { |
106 if (this.Sources == null || this.Sources.Length == 0) | 124 if (this.Sources == null || this.Sources.Length == 0) |
107 { | 125 { |
108 this.SkippedExecution = true; | 126 this.SkippedExecution = true; |
109 } | 127 } |
110 } | 128 } |
111 | 129 |
112 return true; | 130 return true; |
113 } | 131 } |
114 | 132 |
133 protected virtual CanonicalTrackedOutputFiles OutputWriteTLog(ITaskItem[ ] inputs) | |
134 { | |
135 string path = Path.Combine(TlogDirectory, WriteTLogFilename); | |
136 TaskItem item = new TaskItem(path); | |
137 CanonicalTrackedOutputFiles trackedFiles = | |
138 new CanonicalTrackedOutputFiles(new TaskItem[] { item }); | |
139 | |
140 foreach (ITaskItem sourceItem in Sources) | |
141 { | |
142 //remove this entry associated with compiled source which is abo ut to be recomputed | |
143 trackedFiles.RemoveEntriesForSource(sourceItem); | |
144 | |
145 //add entry with updated information | |
146 string upper = Path.GetFullPath(sourceItem.ItemSpec).ToUpperInva riant(); | |
147 trackedFiles.AddComputedOutputForSourceRoot(upper, OutputFile); | |
148 } | |
149 | |
150 //output tlog | |
151 trackedFiles.SaveTlog(); | |
152 | |
153 return trackedFiles; | |
154 } | |
155 | |
156 protected virtual void OutputReadTLog(ITaskItem[] compiledSources, Canon icalTrackedOutputFiles outputs) | |
binji
2012/11/12 21:27:02
nit: wrap at 100
Sam Clegg
2012/11/12 21:56:22
Done.
| |
157 { | |
158 string trackerPath = Path.GetFullPath(TlogDirectory + ReadTLogFilena mes[0]); | |
159 | |
160 using (StreamWriter writer = new StreamWriter(trackerPath, false, En coding.Unicode)) | |
161 { | |
162 string sourcePath = ""; | |
163 foreach (ITaskItem source in Sources) | |
164 { | |
165 if (sourcePath != "") | |
166 sourcePath += "|"; | |
167 sourcePath += Path.GetFullPath(source.ItemSpec).ToUpperInvar iant(); | |
168 } | |
169 | |
170 writer.WriteLine("^" + sourcePath); | |
171 foreach (ITaskItem source in Sources) | |
172 { | |
173 writer.WriteLine(Path.GetFullPath(source.ItemSpec).ToUpperIn variant()); | |
174 } | |
175 writer.WriteLine(Path.GetFullPath(OutputFile).ToUpperInvariant() ); | |
176 } | |
177 } | |
178 | |
179 protected virtual void OutputCommandTLog(ITaskItem[] compiledSources) | |
180 { | |
181 using (StreamWriter writer = new StreamWriter(TLogCommandFile.GetMet adata("FullPath"), false, Encoding.Unicode)) | |
binji
2012/11/12 21:27:02
nit: wrap at 100
Sam Clegg
2012/11/12 21:56:22
Done.
| |
182 { | |
183 string cmds = GenerateResponseFileCommands(); | |
184 string sourcePath = ""; | |
185 foreach (ITaskItem source in Sources) | |
186 { | |
187 if (sourcePath != "") | |
188 sourcePath += "|"; | |
189 sourcePath += Path.GetFullPath(source.ItemSpec).ToUpperInvar iant(); | |
190 } | |
191 | |
192 writer.WriteLine("^" + sourcePath); | |
193 writer.WriteLine(cmds); | |
194 } | |
195 } | |
196 | |
115 public override bool Execute() | 197 public override bool Execute() |
116 { | 198 { |
117 bool returnResult = base.Execute(); | 199 bool returnResult = base.Execute(); |
118 | 200 |
119 // Update tracker log files if execution occurred | 201 // Update tracker log files if execution occurred |
120 //if (this.skippedExecution == false) | 202 //if (this.skippedExecution == false) |
121 { | 203 { |
122 CanonicalTrackedOutputFiles outputs = OutputWriteTLog(compileSou rceList); | 204 CanonicalTrackedOutputFiles outputs = OutputWriteTLog(compileSou rceList); |
123 OutputReadTLog(compileSourceList, outputs); | 205 OutputReadTLog(compileSourceList, outputs); |
124 OutputCommandTLog(compileSourceList); | 206 OutputCommandTLog(compileSourceList); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
287 } | 369 } |
288 } | 370 } |
289 | 371 |
290 protected virtual string WriteTLogFilename | 372 protected virtual string WriteTLogFilename |
291 { | 373 { |
292 get | 374 get |
293 { | 375 { |
294 return BaseTool() + ".compile.write.1.tlog"; | 376 return BaseTool() + ".compile.write.1.tlog"; |
295 } | 377 } |
296 } | 378 } |
379 | |
380 public virtual string PlatformToolset | |
381 { | |
382 get | |
383 { | |
384 return "GCC"; | |
385 } | |
386 } | |
387 | |
388 protected override string GenerateFullPathToTool() | |
389 { | |
390 return this.ToolName; | |
391 } | |
297 } | 392 } |
298 } | 393 } |
OLD | NEW |