OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 namespace NaCl.Build.CPPTasks | |
6 { | |
7 using System; | |
8 using System.IO; | |
9 using System.Collections.Generic; | |
10 | |
11 /// <summary> | |
12 /// TODO: Update summary. | |
13 /// </summary> | |
14 public class SDKUtilities | |
15 { | |
16 public const int MinPNaCLSDKVersion = 164956; | |
17 | |
18 /// <summary> | |
19 /// Find python executable in user's PATH. | |
20 /// </summary> | |
21 public static bool FindPython() | |
22 { | |
23 string envvar = Environment.GetEnvironmentVariable("Path", Environme ntVariableTarget.Process); | |
24 List<string> pathList = new List<string>(envvar.Split(';')); | |
25 foreach (string path in pathList) | |
26 { | |
27 string testPath = Path.Combine(path, "python.bat"); | |
28 if (File.Exists(testPath)) | |
29 { | |
30 return true; | |
31 } | |
32 testPath = Path.Combine(path, "python.exe"); | |
33 if (File.Exists(testPath)) | |
34 { | |
35 return true; | |
36 | |
37 } | |
38 } | |
39 return false; | |
40 } | |
41 | |
42 /// <summary> | |
43 /// Retrieve the version and revsion of the current NaCl SDK located | |
44 /// at $NACL_SDK_ROOT. | |
45 /// </summary> | |
46 public static int GetSDKVersion(string root, out int revision) | |
binji
2012/10/31 06:36:22
seems a little strange to me to have a return valu
| |
47 { | |
48 // Determin version by parsing top level README file. | |
binji
2012/10/31 06:36:22
sp: Determine
| |
49 string[] lines = File.ReadAllLines(Path.Combine(root, "README")); | |
50 int version = -1; | |
51 revision = -1; | |
52 foreach (var line in lines) | |
53 { | |
54 if (line.StartsWith("Revision")) | |
55 revision = Convert.ToInt32(line.Split(':')[1]); | |
56 if (line.StartsWith("Version")) | |
57 version = Convert.ToInt32(line.Split(':')[1]); | |
58 } | |
59 return version; | |
60 } | |
61 } | |
62 } | |
OLD | NEW |