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 | 4 |
5 namespace NaCl.Build.CPPTasks | 5 namespace NaCl.Build.CPPTasks |
6 { | 6 { |
7 using System; | 7 using System; |
8 using System.IO; | 8 using System.IO; |
9 using System.Collections.Generic; | 9 using System.Collections.Generic; |
10 | 10 |
11 /// <summary> | 11 /// <summary> |
12 /// TODO: Update summary. | 12 /// TODO: Update summary. |
13 /// </summary> | 13 /// </summary> |
14 public class SDKUtilities | 14 public class SDKUtilities |
15 { | 15 { |
16 // The first version of pepper with a known working PNaCl toolchain | 16 // The first version of pepper with a known working PNaCl toolchain |
17 public const int MinPNaCLSDKVersion = 166868; | 17 public const int MinPNaCLSDKVersion = 24; |
18 public const int MinPNaCLSDKRevision = 166868; | |
18 | 19 |
19 /// <summary> | 20 /// <summary> |
20 /// Find python executable in user's PATH. | 21 /// Find python executable in user's PATH. |
21 /// </summary> | 22 /// </summary> |
22 public static bool FindPython() | 23 public static bool FindPython() |
23 { | 24 { |
24 string envvar = Environment.GetEnvironmentVariable("Path", Environme ntVariableTarget.Process); | 25 string envvar = Environment.GetEnvironmentVariable("Path", Environme ntVariableTarget.Process); |
25 List<string> pathList = new List<string>(envvar.Split(';')); | 26 List<string> pathList = new List<string>(envvar.Split(';')); |
26 foreach (string path in pathList) | 27 foreach (string path in pathList) |
27 { | 28 { |
28 string testPath = Path.Combine(path, "python.bat"); | 29 string testPath = Path.Combine(path, "python.bat"); |
29 if (File.Exists(testPath)) | 30 if (File.Exists(testPath)) |
30 { | 31 { |
31 return true; | 32 return true; |
32 } | 33 } |
33 testPath = Path.Combine(path, "python.exe"); | 34 testPath = Path.Combine(path, "python.exe"); |
34 if (File.Exists(testPath)) | 35 if (File.Exists(testPath)) |
35 { | 36 { |
36 return true; | 37 return true; |
37 | 38 |
38 } | 39 } |
39 } | 40 } |
40 return false; | 41 return false; |
41 } | 42 } |
42 | 43 |
43 /// <summary> | 44 /// <summary> |
44 /// Retrieve the version and revsion of the current NaCl SDK located | 45 /// Retrieve the version and revsion of the given NaCl SDK root. |
45 /// at $NACL_SDK_ROOT. | |
46 /// </summary> | 46 /// </summary> |
47 public static int GetSDKVersion(string root, out int revision) | 47 public static int GetSDKVersion(string root, out int revision) |
48 { | 48 { |
49 // Determine version by parsing top level README file. | 49 // Determine version by parsing top level README file. |
50 string[] lines = File.ReadAllLines(Path.Combine(root, "README")); | 50 string[] lines = File.ReadAllLines(Path.Combine(root, "README")); |
51 int version = -1; | 51 int version = -1; |
52 revision = -1; | 52 revision = -1; |
53 foreach (var line in lines) | 53 foreach (var line in lines) |
54 { | 54 { |
55 if (line.StartsWith("Revision")) | 55 if (line.StartsWith("Revision")) |
56 revision = Convert.ToInt32(line.Split(':')[1]); | 56 revision = Convert.ToInt32(line.Split(':')[1]); |
57 if (line.StartsWith("Version")) | 57 if (line.StartsWith("Version")) |
58 version = Convert.ToInt32(line.Split(':')[1]); | 58 version = Convert.ToInt32(line.Split(':')[1]); |
59 } | 59 } |
60 return version; | 60 return version; |
61 } | 61 } |
62 | |
63 /// <summary> | |
64 /// Retrun true if the NaCl SDK at the given location supports | |
65 /// the PNaCl toolchain. | |
66 /// </summary> | |
67 public static bool SupportsPNaCl(string root) | |
68 { | |
69 int revision; | |
70 int version = SDKUtilities.GetSDKVersion(root, out revision); | |
71 if (version > SDKUtilities.MinPNaCLSDKVersion) | |
72 return true; | |
73 if (version == SDKUtilities.MinPNaCLSDKVersion && revision >= SDKUti lities.MinPNaCLSDKRevision) | |
noelallen1
2012/12/08 00:50:23
wrap
| |
74 return true; | |
75 return false; | |
76 } | |
62 } | 77 } |
63 } | 78 } |
OLD | NEW |