Skip to content

Commit

Permalink
Merge pull request #887 from StephenHodgson/HTK-IconGenUpdate
Browse files Browse the repository at this point in the history
Editor Utility Tools Update
  • Loading branch information
StephenHodgson committed Sep 2, 2017
2 parents beaae2c + 2e5b2b1 commit 813d94b
Show file tree
Hide file tree
Showing 39 changed files with 955 additions and 888 deletions.
8 changes: 0 additions & 8 deletions Assets/HoloToolkit-UnitTests/Editor/Input.meta

This file was deleted.

3 changes: 0 additions & 3 deletions Assets/HoloToolkit-UnitTests/Input.meta

This file was deleted.

136 changes: 78 additions & 58 deletions Assets/HoloToolkit/BuildAndDeploy/Editor/BuildDeployPortal.cs

Large diffs are not rendered by default.

81 changes: 28 additions & 53 deletions Assets/HoloToolkit/BuildAndDeploy/Editor/BuildDeployPrefs.cs
@@ -1,31 +1,28 @@
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
//

using System.IO;
using UnityEditor;
using UnityEngine;

namespace HoloToolkit.Unity
{
public static class BuildDeployPrefs
{
// Constants
private const string EditorPrefs_BuildDir = "BuildDeployWindow_BuildDir";
private const string EditorPrefs_BuildConfig = "BuildDeployWindow_BuildConfig";
private const string EditorPrefs_ForceRebuild = "BuildDeployWindow_ForceBuild";
private const string EditorPrefs_IncrementBuildVersion = "BuildDeployWindow_IncrementBuildVersion";
private const string EditorPrefs_MSBuildVer = "BuildDeployWindow_MSBuildVer";
private const string EditorPrefs_TargetIPs = "BuildDeployWindow_DestIPs";
private const string EditorPrefs_DeviceUser = "BuildDeployWindow_DeviceUser";
private const string EditorPrefs_DevicePwd = "BuildDeployWindow_DevicePwd";
private const string EditorPrefs_FullReinstall = "BuildDeployWindow_FullReinstall";
private const string EditorPrefs_BuildDir = "_BuildDeployWindow_BuildDir";
private const string EditorPrefs_BuildConfig = "_BuildDeployWindow_BuildConfig";
private const string EditorPrefs_ForceRebuild = "_BuildDeployWindow_ForceBuild";
private const string EditorPrefs_IncrementBuildVersion = "_BuildDeployWindow_IncrementBuildVersion";
private const string EditorPrefs_MSBuildVer = "_BuildDeployWindow_MSBuildVer";
private const string EditorPrefs_TargetIPs = "_BuildDeployWindow_DestIPs";
private const string EditorPrefs_DeviceUser = "_BuildDeployWindow_DeviceUser";
private const string EditorPrefs_DevicePwd = "_BuildDeployWindow_DevicePwd";
private const string EditorPrefs_FullReinstall = "_BuildDeployWindow_FullReinstall";

public static string BuildDirectory
{
get { return GetEditorPref(EditorPrefs_BuildDir, "WindowsStoreApp"); }
set { EditorPrefs.SetString(EditorPrefs_BuildDir, value); }
get { return EditorPrefsUtility.GetEditorPref(EditorPrefs_BuildDir, "UWP"); }
set { EditorPrefsUtility.SetEditorPref(EditorPrefs_BuildDir, value); }
}

public static string AbsoluteBuildDirectory
Expand All @@ -35,72 +32,50 @@ public static string AbsoluteBuildDirectory

public static string MsBuildVersion
{
get { return GetEditorPref(EditorPrefs_MSBuildVer, BuildDeployTools.DefaultMSBuildVersion); }
set { EditorPrefs.SetString(EditorPrefs_MSBuildVer, value); }
get { return EditorPrefsUtility.GetEditorPref(EditorPrefs_MSBuildVer, BuildDeployTools.DefaultMSBuildVersion); }
set { EditorPrefsUtility.SetEditorPref(EditorPrefs_MSBuildVer, value); }
}

public static string BuildConfig
{
get { return GetEditorPref(EditorPrefs_BuildConfig, "Debug"); }
set { EditorPrefs.SetString(EditorPrefs_BuildConfig, value); }
get { return EditorPrefsUtility.GetEditorPref(EditorPrefs_BuildConfig, "Debug"); }
set { EditorPrefsUtility.SetEditorPref(EditorPrefs_BuildConfig, value); }
}

public static bool ForceRebuild
{
get { return GetEditorPref(EditorPrefs_ForceRebuild, false); }
set { EditorPrefs.SetBool(EditorPrefs_ForceRebuild, value); }
get { return EditorPrefsUtility.GetEditorPref(EditorPrefs_ForceRebuild, false); }
set { EditorPrefsUtility.SetEditorPref(EditorPrefs_ForceRebuild, value); }
}

public static bool IncrementBuildVersion
{
get { return GetEditorPref(EditorPrefs_IncrementBuildVersion, true); }
set { EditorPrefs.SetBool(EditorPrefs_IncrementBuildVersion, value); }
get { return EditorPrefsUtility.GetEditorPref(EditorPrefs_IncrementBuildVersion, true); }
set { EditorPrefsUtility.SetEditorPref(EditorPrefs_IncrementBuildVersion, value); }
}

public static string TargetIPs
{
get { return GetEditorPref(EditorPrefs_TargetIPs, "127.0.0.1"); }
set { EditorPrefs.SetString(EditorPrefs_TargetIPs, value); }
get { return EditorPrefsUtility.GetEditorPref(EditorPrefs_TargetIPs, "127.0.0.1"); }
set { EditorPrefsUtility.SetEditorPref(EditorPrefs_TargetIPs, value); }
}

public static string DeviceUser
{
get { return GetEditorPref(EditorPrefs_DeviceUser, ""); }
set { EditorPrefs.SetString(EditorPrefs_DeviceUser, value); }
get { return EditorPrefsUtility.GetEditorPref(EditorPrefs_DeviceUser, ""); }
set { EditorPrefsUtility.SetEditorPref(EditorPrefs_DeviceUser, value); }
}

public static string DevicePassword
{
get { return GetEditorPref(EditorPrefs_DevicePwd, ""); }
set { EditorPrefs.SetString(EditorPrefs_DevicePwd, value); }
get { return EditorPrefsUtility.GetEditorPref(EditorPrefs_DevicePwd, ""); }
set { EditorPrefsUtility.SetEditorPref(EditorPrefs_DevicePwd, value); }
}

public static bool FullReinstall
{
get { return GetEditorPref(EditorPrefs_FullReinstall, true); }
set { EditorPrefs.SetBool(EditorPrefs_FullReinstall, value); }
}

private static string GetEditorPref(string key, string defaultValue)
{
if (EditorPrefs.HasKey(key))
{
return EditorPrefs.GetString(key);
}

EditorPrefs.SetString(key, defaultValue);
return defaultValue;
}

private static bool GetEditorPref(string key, bool defaultValue)
{
if (EditorPrefs.HasKey(key))
{
return EditorPrefs.GetBool(key);
}

EditorPrefs.SetBool(key, defaultValue);
return defaultValue;
get { return EditorPrefsUtility.GetEditorPref(EditorPrefs_FullReinstall, true); }
set { EditorPrefsUtility.SetEditorPref(EditorPrefs_FullReinstall, value); }
}
}
}
50 changes: 29 additions & 21 deletions Assets/HoloToolkit/BuildAndDeploy/Editor/BuildDeployTools.cs
Expand Up @@ -4,11 +4,14 @@
//

using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Xml.Linq;
using Microsoft.Win32;
using UnityEditor;
using UnityEngine;
using System.Xml.Linq;
using Debug = UnityEngine.Debug;

namespace HoloToolkit.Unity
{
Expand Down Expand Up @@ -73,8 +76,8 @@ public static string CalcMSBuildPath(string msBuildVersion)
{
if (msBuildVersion.Equals("14.0"))
{
using (Microsoft.Win32.RegistryKey key =
Microsoft.Win32.Registry.LocalMachine.OpenSubKey(
using (RegistryKey key =
Registry.LocalMachine.OpenSubKey(
string.Format(@"Software\Microsoft\MSBuild\ToolsVersions\{0}", msBuildVersion)))
{
if (key == null)
Expand All @@ -88,37 +91,42 @@ public static string CalcMSBuildPath(string msBuildVersion)
}

// For MSBuild 15+ we should to use vswhere to give us the correct instance
string output = @"/C cd ""%ProgramFiles(x86)%\Microsoft Visual Studio\Installer"" && vswhere -version " + msBuildVersion + " -products * -requires Microsoft.Component.MSBuild -property installationPath";
string output = @"/C vswhere -version " + msBuildVersion + " -products * -requires Microsoft.Component.MSBuild -property installationPath";

var vswherePInfo = new System.Diagnostics.ProcessStartInfo
// get the right program files path based on whether the pc is x86 or x64
string programFiles = @"C:\Program Files\";
if (Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE", EnvironmentVariableTarget.Machine) == "AMD64")
{
programFiles = @"C:\Program Files (x86)\";
}

var vswherePInfo = new ProcessStartInfo
{
FileName = "cmd.exe",
CreateNoWindow = true,
UseShellExecute = false,
RedirectStandardOutput = true,
Arguments = output
RedirectStandardError = false,
Arguments = output,
WorkingDirectory = programFiles + @"Microsoft Visual Studio\Installer"
};

using (var vswhereP = new System.Diagnostics.Process())
using (var vswhereP = new Process())
{
vswhereP.StartInfo = vswherePInfo;
vswhereP.Start();
output = vswhereP.StandardOutput.ReadToEnd();
vswhereP.WaitForExit();
vswhereP.Close();
vswhereP.Dispose();
}

string externalScriptingEditorPath = EditorPrefs.GetString("kScriptsDefaultApp");
string[] paths = output.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);

for (int i = 0; i < paths.Length; i++)
// if there are multiple 2017 installs,
// prefer enterprise, then pro, then community
string bestPath = paths.OrderBy(p => p.ToLower().Contains("enterprise")).ThenBy(p => p.ToLower().Contains("professional")).First();
if (File.Exists(bestPath + @"\MSBuild\" + msBuildVersion + @"\Bin\MSBuild.exe"))
{
paths[i] = paths[i].Replace(Environment.NewLine, "");
if (externalScriptingEditorPath.Contains(paths[i]))
{
return paths[i] + @"\MSBuild\" + msBuildVersion + @"\Bin\MSBuild.exe";
}
return bestPath + @"\MSBuild\" + msBuildVersion + @"\Bin\MSBuild.exe";
}

Debug.LogError("Unable to find a valid path to Visual Studio Instance!");
Expand All @@ -127,15 +135,15 @@ public static string CalcMSBuildPath(string msBuildVersion)

public static bool RestoreNugetPackages(string nugetPath, string storePath)
{
var nugetPInfo = new System.Diagnostics.ProcessStartInfo
var nugetPInfo = new ProcessStartInfo
{
FileName = nugetPath,
CreateNoWindow = true,
UseShellExecute = false,
Arguments = "restore \"" + storePath + "/project.json\""
};

using (var nugetP = new System.Diagnostics.Process())
using (var nugetP = new Process())
{
nugetP.StartInfo = nugetPInfo;
nugetP.Start();
Expand Down Expand Up @@ -205,7 +213,7 @@ public static bool BuildAppxFromSLN(string productName, string msBuildVersion, b
}

// Now do the actual build
var pInfo = new System.Diagnostics.ProcessStartInfo
var pInfo = new ProcessStartInfo
{
FileName = vs,
CreateNoWindow = false,
Expand All @@ -218,7 +226,7 @@ public static bool BuildAppxFromSLN(string productName, string msBuildVersion, b
// Uncomment out to debug by copying into command window
//Debug.Log("\"" + vs + "\"" + " " + pInfo.Arguments);

var process = new System.Diagnostics.Process { StartInfo = pInfo };
var process = new Process { StartInfo = pInfo };

try
{
Expand All @@ -237,7 +245,7 @@ public static bool BuildAppxFromSLN(string productName, string msBuildVersion, b
showDialog &&
!EditorUtility.DisplayDialog("Build AppX", "AppX Build Successful!", "OK", "Open Project Folder"))
{
System.Diagnostics.Process.Start("explorer.exe", "/select," + storePath);
Process.Start("explorer.exe", "/select," + storePath);
}

if (process.ExitCode != 0)
Expand Down
14 changes: 6 additions & 8 deletions Assets/HoloToolkit/BuildAndDeploy/Editor/BuildDeployWindow.cs
Expand Up @@ -110,12 +110,10 @@ private bool HoloLensUsbConnected
[MenuItem("HoloToolkit/Build Window", false, 0)]
public static void OpenWindow()
{
var window = GetWindow<BuildDeployWindow>("Build Window");

if (window != null)
{
window.Show();
}
// Dock it next to the Scene View.
var window = GetWindow<BuildDeployWindow>(typeof(SceneView));
window.titleContent = new GUIContent("Build Window");
window.Show();
}

private void OnEnable()
Expand Down Expand Up @@ -563,7 +561,7 @@ private void OnGUI()

if (GUILayout.Button("Open APPX Packages Location", GUILayout.Width(buttonWidth_Full)))
{
Process.Start("explorer.exe", "/open," + Path.GetFullPath(curBuildDirectory + "/" + PlayerSettings.productName + "/AppPackages"));
Process.Start("explorer.exe", "/f /open," + Path.GetFullPath(curBuildDirectory + "/" + PlayerSettings.productName + "/AppPackages"));
}

GUI.enabled = true;
Expand Down Expand Up @@ -770,7 +768,7 @@ private void InstallAppOnDevicesList(string buildPath, string[] targetList)
EditorUtility.ClearProgressBar();
}

private bool InstallApp(string buildPath, string targetDevice)
private static bool InstallApp(string buildPath, string targetDevice)
{
// Get the appx path
FileInfo[] files = new DirectoryInfo(buildPath).GetFiles("*.appx");
Expand Down
Expand Up @@ -92,7 +92,7 @@ public static void PerformBuild(BuildInfo buildInfo)
if (buildInfo.HasAnySymbols(BuildSymbolRelease))
{
//Unity automatically adds the DEBUG symbol if the BuildOptions.Development flag is
//specified. In order to have debug symbols and the RELEASE symbole we have to
//specified. In order to have debug symbols and the RELEASE symbols we have to
//inject the symbol Unity relies on to enable the /debug+ flag of csc.exe which is "DEVELOPMENT_BUILD"
buildInfo.AppendSymbols("DEVELOPMENT_BUILD");
}
Expand Down
Expand Up @@ -9,7 +9,7 @@ namespace HoloToolkit.Unity
{
public static class RoomMeshExporter
{
private const string ExportDirectoryKey = "ExportDirectory";
private const string ExportDirectoryKey = "_ExportDirectory";
private const string ExportDirectoryDefault = "MeshExport";
private const string ExportDialogErrorTitle = "Export Error";
private const string WavefrontFileExtension = ".obj";
Expand All @@ -18,7 +18,7 @@ public static string ExportDirectory
{
get
{
return EditorPrefs.GetString(ExportDirectoryKey, ExportDirectoryDefault);
return EditorPrefsUtility.GetEditorPref(ExportDirectoryKey, ExportDirectoryDefault);
}
set
{
Expand All @@ -27,7 +27,7 @@ public static string ExportDirectory
value = ExportDirectoryDefault;
}

EditorPrefs.SetString(ExportDirectoryKey, value);
EditorPrefsUtility.SetEditorPref(ExportDirectoryKey, value);
}
}

Expand Down
9 changes: 0 additions & 9 deletions Assets/HoloToolkit/Utilities/Editor.meta

This file was deleted.

0 comments on commit 813d94b

Please sign in to comment.