Chromium Code Reviews| Index: visual_studio/NativeClientVSAddIn/NaCl.Build.CPPTasks/SDKUtilities.cs |
| diff --git a/visual_studio/NativeClientVSAddIn/NaCl.Build.CPPTasks/SDKUtilities.cs b/visual_studio/NativeClientVSAddIn/NaCl.Build.CPPTasks/SDKUtilities.cs |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9ef12367f8ff408acd67b8ca83ce82c4dd990db0 |
| --- /dev/null |
| +++ b/visual_studio/NativeClientVSAddIn/NaCl.Build.CPPTasks/SDKUtilities.cs |
| @@ -0,0 +1,62 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +namespace NaCl.Build.CPPTasks |
| +{ |
| + using System; |
| + using System.IO; |
| + using System.Collections.Generic; |
| + |
| + /// <summary> |
| + /// TODO: Update summary. |
| + /// </summary> |
| + public class SDKUtilities |
| + { |
| + public const int MinPNaCLSDKVersion = 164956; |
| + |
| + /// <summary> |
| + /// Find python executable in user's PATH. |
| + /// </summary> |
| + public static bool FindPython() |
| + { |
| + string envvar = Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.Process); |
| + List<string> pathList = new List<string>(envvar.Split(';')); |
| + foreach (string path in pathList) |
| + { |
| + string testPath = Path.Combine(path, "python.bat"); |
| + if (File.Exists(testPath)) |
| + { |
| + return true; |
| + } |
| + testPath = Path.Combine(path, "python.exe"); |
| + if (File.Exists(testPath)) |
| + { |
| + return true; |
| + |
| + } |
| + } |
| + return false; |
| + } |
| + |
| + /// <summary> |
| + /// Retrieve the version and revsion of the current NaCl SDK located |
| + /// at $NACL_SDK_ROOT. |
| + /// </summary> |
| + 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
|
| + { |
| + // Determin version by parsing top level README file. |
|
binji
2012/10/31 06:36:22
sp: Determine
|
| + string[] lines = File.ReadAllLines(Path.Combine(root, "README")); |
| + int version = -1; |
| + revision = -1; |
| + foreach (var line in lines) |
| + { |
| + if (line.StartsWith("Revision")) |
| + revision = Convert.ToInt32(line.Split(':')[1]); |
| + if (line.StartsWith("Version")) |
| + version = Convert.ToInt32(line.Split(':')[1]); |
| + } |
| + return version; |
| + } |
| + } |
| +} |