From a870290d77855a1a2c2a67b0a1184f9a168483e3 Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Sun, 12 Mar 2017 15:24:40 +0200 Subject: [PATCH] Moved the SN path logic to Utils.cake --- build.cake | 27 +-------------------------- cake/Utils.cake | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 26 deletions(-) diff --git a/build.cake b/build.cake index 5d1939bb..611a6351 100644 --- a/build.cake +++ b/build.cake @@ -20,6 +20,7 @@ var CakeToolPath = GetToolPath ("Cake/Cake.exe"); var NUnitConsoleToolPath = GetToolPath ("NUnit.ConsoleRunner/tools/nunit3-console.exe"); var GenApiToolPath = GetToolPath ("Microsoft.DotNet.BuildTools.GenAPI/tools/GenAPI.exe"); var MDocPath = GetToolPath ("mdoc/mdoc.exe"); +var SNToolPath = GetSNToolPath (EnvironmentVariable ("SN_EXE")); var VERSION_ASSEMBLY = "1.56.0.0"; var VERSION_FILE = "1.56.2.0"; @@ -39,32 +40,6 @@ var IS_ON_FINAL_CI = TARGET.ToUpper () == "CI"; string ANDROID_HOME = EnvironmentVariable ("ANDROID_HOME") ?? EnvironmentVariable ("HOME") + "/Library/Developer/Xamarin/android-sdk-macosx"; string ANDROID_SDK_ROOT = EnvironmentVariable ("ANDROID_SDK_ROOT") ?? ANDROID_HOME; string ANDROID_NDK_HOME = EnvironmentVariable ("ANDROID_NDK_HOME") ?? EnvironmentVariable ("HOME") + "/Library/Developer/Xamarin/android-ndk"; -string SNToolPath = EnvironmentVariable ("SN_EXE"); -if (string.IsNullOrEmpty (SNToolPath)) { - if (IsRunningOnLinux ()) { - SNToolPath = "/usr/lib/mono/4.5/sn.exe"; - } else if (IsRunningOnMac ()) { - SNToolPath = "/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.5/sn.exe"; - } else if (IsRunningOnWindows ()) { - // search through all the SDKs to find the latest - var snExes = new List (); - var arch = Environment.Is64BitOperatingSystem ? "x64" : ""; - var progFiles = (DirectoryPath)Environment.GetFolderPath (Environment.SpecialFolder.ProgramFilesX86); - var dirPath = progFiles.Combine ("Microsoft SDKs/Windows").FullPath + "/v*A"; - var dirs = GetDirectories (dirPath).OrderBy (d => { - var version = d.GetDirectoryName (); - return double.Parse (version.Substring (1, version.Length - 2)); - }); - foreach (var dir in dirs) { - var path = dir.FullPath + "/bin/*/" + arch + "/sn.exe"; - var files = GetFiles (path).Select (p => p.FullPath).ToList (); - files.Sort (); - snExes.AddRange (files); - } - - SNToolPath = snExes.LastOrDefault (); - } -} DirectoryPath ROOT_PATH = MakeAbsolute(Directory(".")); DirectoryPath DEPOT_PATH = MakeAbsolute(ROOT_PATH.Combine("externals/depot_tools")); diff --git a/cake/Utils.cake b/cake/Utils.cake index 7a3292f5..1e35c1f5 100644 --- a/cake/Utils.cake +++ b/cake/Utils.cake @@ -66,3 +66,33 @@ var IsRunningOnMac = new Func (() => { var IsRunningOnLinux = new Func (() => { return IsRunningOnUnix () && !IsRunningOnMac (); }); + +FilePath GetSNToolPath (string possible) +{ + if (string.IsNullOrEmpty (possible)) { + if (IsRunningOnLinux ()) { + possible = "/usr/lib/mono/4.5/sn.exe"; + } else if (IsRunningOnMac ()) { + possible = "/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.5/sn.exe"; + } else if (IsRunningOnWindows ()) { + // search through all the SDKs to find the latest + var snExes = new List (); + var arch = Environment.Is64BitOperatingSystem ? "x64" : ""; + var progFiles = (DirectoryPath)Environment.GetFolderPath (Environment.SpecialFolder.ProgramFilesX86); + var dirPath = progFiles.Combine ("Microsoft SDKs/Windows").FullPath + "/v*A"; + var dirs = GetDirectories (dirPath).OrderBy (d => { + var version = d.GetDirectoryName (); + return double.Parse (version.Substring (1, version.Length - 2)); + }); + foreach (var dir in dirs) { + var path = dir.FullPath + "/bin/*/" + arch + "/sn.exe"; + var files = GetFiles (path).Select (p => p.FullPath).ToList (); + files.Sort (); + snExes.AddRange (files); + } + + possible = snExes.LastOrDefault (); + } + } + return possible; +} \ No newline at end of file