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 | 5 |
6 using System.IO; | 6 using System.IO; |
7 using System.Text.RegularExpressions; | 7 using System.Text.RegularExpressions; |
8 | 8 |
9 namespace NaCl.Build.CPPTasks | 9 namespace NaCl.Build.CPPTasks |
10 { | 10 { |
11 class GCCUtilities | 11 class GCCUtilities |
12 { | 12 { |
13 public const int s_CommandLineLength = 256; | 13 public const int s_CommandLineLength = 256; |
14 | 14 |
15 /// <summary> | |
16 /// Find python executable in user's PATH. | |
17 /// </summary> | |
18 public static bool FindPython() | |
19 { | |
20 string envvar = Environment.GetEnvironmentVariable("Path", Environme
ntVariableTarget.Process); | |
21 List<string> pathList = new List<string>(envvar.Split(';')); | |
22 foreach (string path in pathList) | |
23 { | |
24 string testPath = Path.Combine(path, "python.bat"); | |
25 if (File.Exists(testPath)) | |
26 { | |
27 return true; | |
28 } | |
29 testPath = Path.Combine(path, "python.exe"); | |
30 if (File.Exists(testPath)) | |
31 { | |
32 return true; | |
33 | |
34 } | |
35 } | |
36 return false; | |
37 } | |
38 | |
39 public static string ConvertPathWindowsToPosix(string path) | 15 public static string ConvertPathWindowsToPosix(string path) |
40 { | 16 { |
41 return path.Replace('\\', '/'); | 17 return path.Replace('\\', '/'); |
42 } | 18 } |
43 | 19 |
44 public static string ConvertPathPosixToWindows(string path) | 20 public static string ConvertPathPosixToWindows(string path) |
45 { | 21 { |
46 path = path.Replace('/', '\\'); | 22 path = path.Replace('/', '\\'); |
47 // also make double backslashes a single slash | 23 // also make double backslashes a single slash |
48 // TODO: speed this up by iterating instead of two replaces | 24 // TODO: speed this up by iterating instead of two replaces |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 }, | 92 }, |
117 new GCCRegexLineConverter | 93 new GCCRegexLineConverter |
118 { | 94 { |
119 OutputExpression = new Regex(@"^\s*(.?.?[^:]*.*?):(.?.?[^:]
*.*?):([1-9]\d*):(.*$)"), | 95 OutputExpression = new Regex(@"^\s*(.?.?[^:]*.*?):(.?.?[^:]
*.*?):([1-9]\d*):(.*$)"), |
120 FilenameIdentifier = @"$2", | 96 FilenameIdentifier = @"$2", |
121 RemainderIdentifier = @"($3):'$1' $4" | 97 RemainderIdentifier = @"($3):'$1' $4" |
122 } | 98 } |
123 }; | 99 }; |
124 } // GCCUtilities | 100 } // GCCUtilities |
125 } // namespace | 101 } // namespace |
OLD | NEW |