Skip to content

Commit 4ff9658

Browse files
Merge pull request #1059 from StephenHodgson/MRTK-ForwardCompatibility2
Mrtk forward compatibility
2 parents 38e7ada + c213ffe commit 4ff9658

File tree

10 files changed

+344
-216
lines changed

10 files changed

+344
-216
lines changed

Assets/HoloToolkit/BuildAndDeploy/Editor/BuildDeployPrefs.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public static class BuildDeployPrefs
1111
// Constants
1212
private const string EditorPrefs_BuildDir = "_BuildDeployWindow_BuildDir";
1313
private const string EditorPrefs_BuildConfig = "_BuildDeployWindow_BuildConfig";
14+
private const string EditorPrefs_BuildPlatform = "_BuildDeployWindow_BuildPlatform";
1415
private const string EditorPrefs_ForceRebuild = "_BuildDeployWindow_ForceBuild";
1516
private const string EditorPrefs_IncrementBuildVersion = "_BuildDeployWindow_IncrementBuildVersion";
1617
private const string EditorPrefs_MSBuildVer = "_BuildDeployWindow_MSBuildVer";
@@ -42,6 +43,12 @@ public static string BuildConfig
4243
set { EditorPrefsUtility.SetEditorPref(EditorPrefs_BuildConfig, value); }
4344
}
4445

46+
public static string BuildPlatform
47+
{
48+
get { return EditorPrefsUtility.GetEditorPref(EditorPrefs_BuildPlatform, "Any CPU"); }
49+
set { EditorPrefsUtility.SetEditorPref(EditorPrefs_BuildPlatform, value); }
50+
}
51+
4552
public static bool ForceRebuild
4653
{
4754
get { return EditorPrefsUtility.GetEditorPref(EditorPrefs_ForceRebuild, false); }

Assets/HoloToolkit/BuildAndDeploy/Editor/BuildDeployTools.cs

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,26 @@ public class BuildDeployTools
2222
{
2323
public static readonly string DefaultMSBuildVersion = "14.0";
2424

25+
public static bool CanBuild()
26+
{
27+
if (PlayerSettings.GetScriptingBackend(BuildTargetGroup.WSA) == ScriptingImplementation.IL2CPP && IsIl2CppAvailable())
28+
{
29+
return true;
30+
}
31+
32+
return PlayerSettings.GetScriptingBackend(BuildTargetGroup.WSA) == ScriptingImplementation.WinRTDotNET && IsDotNetAvailable();
33+
}
34+
35+
public static bool IsDotNetAvailable()
36+
{
37+
return Directory.Exists(EditorApplication.applicationContentsPath + "\\PlaybackEngines\\MetroSupport\\Managed\\UAP");
38+
}
39+
40+
public static bool IsIl2CppAvailable()
41+
{
42+
return Directory.Exists(EditorApplication.applicationContentsPath + "\\PlaybackEngines\\MetroSupport\\Managed\\il2cpp");
43+
}
44+
2545
public static bool BuildSLN(string buildDirectory, bool showDialog = true)
2646
{
2747
// Use BuildSLNUtilities to create the SLN
@@ -55,6 +75,7 @@ public static bool BuildSLN(string buildDirectory, bool showDialog = true)
5575
BuildDeployPrefs.MsBuildVersion,
5676
BuildDeployPrefs.ForceRebuild,
5777
BuildDeployPrefs.BuildConfig,
78+
BuildDeployPrefs.BuildPlatform,
5879
BuildDeployPrefs.BuildDirectory,
5980
BuildDeployPrefs.IncrementBuildVersion);
6081
}
@@ -82,7 +103,7 @@ public static string CalcMSBuildPath(string msBuildVersion)
82103
{
83104
if (key != null)
84105
{
85-
var msBuildBinFolder = (string) key.GetValue("MSBuildToolsPath");
106+
var msBuildBinFolder = (string)key.GetValue("MSBuildToolsPath");
86107
return Path.Combine(msBuildBinFolder, "msbuild.exe");
87108
}
88109
}
@@ -158,7 +179,7 @@ public static bool RestoreNugetPackages(string nugetPath, string storePath)
158179
return File.Exists(storePath + "\\project.lock.json");
159180
}
160181

161-
public static bool BuildAppxFromSLN(string productName, string msBuildVersion, bool forceRebuildAppx, string buildConfig, string buildDirectory, bool incrementVersion, bool showDialog = true)
182+
public static bool BuildAppxFromSLN(string productName, string msBuildVersion, bool forceRebuildAppx, string buildConfig, string buildPlatform, string buildDirectory, bool incrementVersion, bool showDialog = true)
162183
{
163184
EditorUtility.DisplayProgressBar("Build AppX", "Building AppX Package...", 0);
164185
string slnFilename = Path.Combine(buildDirectory, PlayerSettings.productName + ".sln");
@@ -220,10 +241,11 @@ public static bool BuildAppxFromSLN(string productName, string msBuildVersion, b
220241
{
221242
FileName = vs,
222243
CreateNoWindow = false,
223-
Arguments = string.Format("\"{0}\" /t:{2} /p:Configuration={1} /p:Platform=x86 /verbosity:m",
244+
Arguments = string.Format("\"{0}\" /t:{1} /p:Configuration={2} /p:Platform={3} /verbosity:m",
224245
solutionProjectPath,
246+
forceRebuildAppx ? "Rebuild" : "Build",
225247
buildConfig,
226-
forceRebuildAppx ? "Rebuild" : "Build")
248+
buildPlatform)
227249
};
228250

229251
// Uncomment out to debug by copying into command window

Assets/HoloToolkit/BuildAndDeploy/Editor/BuildDeployWindow.cs

Lines changed: 95 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,21 @@ namespace HoloToolkit.Unity
2323
public class BuildDeployWindow : EditorWindow
2424
{
2525
private const float GUISectionOffset = 10.0f;
26-
private const string GUIHorizSpacer = " ";
26+
private const string GUIHorizontalSpacer = " ";
2727
private const float UpdateBuildsPeriod = 1.0f;
2828

29+
private enum BuildPlatformEnum
30+
{
31+
AnyCPU = 0,
32+
x86 = 1,
33+
x64 = 2
34+
}
35+
2936
private enum BuildConfigEnum
3037
{
31-
DEBUG = 0,
32-
RELEASE = 1,
33-
MASTER = 2
38+
Debug = 0,
39+
Release = 1,
40+
Master = 2
3441
}
3542

3643
#region Properties
@@ -107,7 +114,7 @@ private bool HoloLensUsbConnected
107114

108115
#region Methods
109116

110-
[MenuItem("HoloToolkit/Build Window", false, 0)]
117+
[MenuItem("Mixed Reality Toolkit/Build Window", false, 0)]
111118
public static void OpenWindow()
112119
{
113120
// Dock it next to the Scene View.
@@ -213,17 +220,28 @@ private void OnGUI()
213220
EditorGUILayout.BeginHorizontal();
214221
GUILayout.FlexibleSpace();
215222
EditorGUILayout.EndHorizontal();
223+
EditorGUILayout.BeginHorizontal();
216224

217225
// Build directory (and save setting, if it's changed)
218226
string curBuildDirectory = BuildDeployPrefs.BuildDirectory;
219-
string newBuildDirectory = EditorGUILayout.TextField(GUIHorizSpacer + "Build directory", curBuildDirectory);
227+
string newBuildDirectory = EditorGUILayout.TextField(new GUIContent(GUIHorizontalSpacer + "Build Directory", "It's recommended to use UWP"), curBuildDirectory);
220228

221229
if (newBuildDirectory != curBuildDirectory)
222230
{
223231
BuildDeployPrefs.BuildDirectory = newBuildDirectory;
224232
curBuildDirectory = newBuildDirectory;
225233
}
226234

235+
GUI.enabled = Directory.Exists(BuildDeployPrefs.AbsoluteBuildDirectory);
236+
237+
if (GUILayout.Button("Open Build Directory"))
238+
{
239+
Process.Start(BuildDeployPrefs.AbsoluteBuildDirectory);
240+
}
241+
242+
GUI.enabled = true;
243+
EditorGUILayout.EndHorizontal();
244+
227245
// Build SLN button
228246
using (new EditorGUILayout.HorizontalScope())
229247
{
@@ -246,7 +264,7 @@ private void OnGUI()
246264

247265
GUI.enabled = ShouldOpenSLNBeEnabled;
248266

249-
if (GUILayout.Button("Open SLN", GUILayout.Width(buttonWidth_Quarter)))
267+
if (GUILayout.Button("Open Project Solution", GUILayout.Width(buttonWidth_Quarter)))
250268
{
251269
// Open SLN
252270
string slnFilename = Path.Combine(curBuildDirectory, PlayerSettings.productName + ".sln");
@@ -256,7 +274,7 @@ private void OnGUI()
256274
var slnFile = new FileInfo(slnFilename);
257275
Process.Start(slnFile.FullName);
258276
}
259-
else if (EditorUtility.DisplayDialog("Solution Not Found", "We couldn't find the solution. Would you like to Build it?", "Yes, Build", "No"))
277+
else if (EditorUtility.DisplayDialog("Solution Not Found", "We couldn't find the Project's Solution. Would you like to Build the project now?", "Yes, Build", "No"))
260278
{
261279
// Build SLN
262280
EditorApplication.delayCall += () => { BuildDeployTools.BuildSLN(curBuildDirectory); };
@@ -265,7 +283,7 @@ private void OnGUI()
265283

266284
GUI.enabled = ShouldBuildSLNBeEnabled;
267285

268-
if (GUILayout.Button("Build Visual Studio SLN", GUILayout.Width(buttonWidth_Half)))
286+
if (GUILayout.Button("Build Unity Project", GUILayout.Width(buttonWidth_Half)))
269287
{
270288
// Build SLN
271289
EditorApplication.delayCall += () => { BuildDeployTools.BuildSLN(curBuildDirectory); };
@@ -278,6 +296,8 @@ private void OnGUI()
278296
GUILayout.BeginVertical();
279297
GUILayout.Label("APPX");
280298

299+
GUILayout.BeginHorizontal();
300+
281301
// SDK and MS Build Version(and save setting, if it's changed)
282302
string curMSBuildVer = BuildDeployPrefs.MsBuildVersion;
283303
string currentSDKVersion = EditorUserBuildSettings.wsaUWPSDK;
@@ -305,7 +325,7 @@ private void OnGUI()
305325
}
306326
}
307327

308-
currentSDKVersionIndex = EditorGUILayout.Popup(GUIHorizSpacer + "SDK Version", currentSDKVersionIndex, windowsSdkPaths);
328+
currentSDKVersionIndex = EditorGUILayout.Popup(GUIHorizontalSpacer + "SDK Version", currentSDKVersionIndex, windowsSdkPaths);
309329

310330
string newSDKVersion = windowsSdkPaths[currentSDKVersionIndex];
311331

@@ -315,41 +335,86 @@ private void OnGUI()
315335
}
316336

317337
string newMSBuildVer = currentSDKVersionIndex <= defaultMSBuildVersionIndex ? BuildDeployTools.DefaultMSBuildVersion : "15.0";
318-
EditorGUILayout.LabelField(GUIHorizSpacer + "MS Build Version", newMSBuildVer);
338+
EditorGUILayout.LabelField(GUIHorizontalSpacer + "MS Build Version", newMSBuildVer);
319339

320340
if (!newMSBuildVer.Equals(curMSBuildVer))
321341
{
322342
BuildDeployPrefs.MsBuildVersion = newMSBuildVer;
323343
curMSBuildVer = newMSBuildVer;
324344
}
325345

346+
GUILayout.EndHorizontal();
347+
GUILayout.BeginHorizontal();
348+
326349
// Build config (and save setting, if it's changed)
327350
string curBuildConfigString = BuildDeployPrefs.BuildConfig;
328351

329352
BuildConfigEnum buildConfigOption;
330353
if (curBuildConfigString.ToLower().Equals("master"))
331354
{
332-
buildConfigOption = BuildConfigEnum.MASTER;
355+
buildConfigOption = BuildConfigEnum.Master;
333356
}
334357
else if (curBuildConfigString.ToLower().Equals("release"))
335358
{
336-
buildConfigOption = BuildConfigEnum.RELEASE;
359+
buildConfigOption = BuildConfigEnum.Release;
337360
}
338361
else
339362
{
340-
buildConfigOption = BuildConfigEnum.DEBUG;
363+
buildConfigOption = BuildConfigEnum.Debug;
341364
}
342365

343-
buildConfigOption = (BuildConfigEnum)EditorGUILayout.EnumPopup(GUIHorizSpacer + "Build Configuration", buildConfigOption);
366+
buildConfigOption = (BuildConfigEnum)EditorGUILayout.EnumPopup(GUIHorizontalSpacer + "Build Configuration", buildConfigOption);
344367

345-
string newBuildConfig = buildConfigOption.ToString();
368+
string buildConfigString = buildConfigOption.ToString();
346369

347-
if (newBuildConfig != curBuildConfigString)
370+
if (buildConfigString != curBuildConfigString)
348371
{
349-
BuildDeployPrefs.BuildConfig = newBuildConfig;
350-
curBuildConfigString = newBuildConfig;
372+
BuildDeployPrefs.BuildConfig = buildConfigString;
373+
curBuildConfigString = buildConfigString;
351374
}
352375

376+
// Build Platform (and save setting, if it's changed)
377+
string curBuildPlatformString = BuildDeployPrefs.BuildPlatform;
378+
BuildPlatformEnum buildPlatformOption;
379+
380+
if (curBuildPlatformString.ToLower().Equals("x86"))
381+
{
382+
buildPlatformOption = BuildPlatformEnum.x86;
383+
}
384+
else if (curBuildPlatformString.ToLower().Equals("x64"))
385+
{
386+
buildPlatformOption = BuildPlatformEnum.x64;
387+
}
388+
else
389+
{
390+
buildPlatformOption = BuildPlatformEnum.AnyCPU;
391+
}
392+
393+
buildPlatformOption = (BuildPlatformEnum)EditorGUILayout.EnumPopup(GUIHorizontalSpacer + "Build Platform", buildPlatformOption);
394+
395+
string newBuildPlatformString;
396+
397+
switch (buildPlatformOption)
398+
{
399+
case BuildPlatformEnum.AnyCPU:
400+
newBuildPlatformString = "Any CPU";
401+
break;
402+
case BuildPlatformEnum.x86:
403+
case BuildPlatformEnum.x64:
404+
newBuildPlatformString = buildPlatformOption.ToString();
405+
break;
406+
default:
407+
throw new ArgumentOutOfRangeException();
408+
}
409+
410+
if (newBuildPlatformString != curBuildPlatformString)
411+
{
412+
BuildDeployPrefs.BuildPlatform = newBuildPlatformString;
413+
curBuildPlatformString = newBuildPlatformString;
414+
}
415+
416+
GUILayout.EndHorizontal();
417+
353418
// Build APPX button
354419
using (new EditorGUILayout.HorizontalScope())
355420
{
@@ -371,7 +436,7 @@ private void OnGUI()
371436
// Increment version
372437
EditorGUIUtility.labelWidth = 110;
373438
bool curIncrementVersion = BuildDeployPrefs.IncrementBuildVersion;
374-
bool newIncrementVersion = EditorGUILayout.Toggle("Increment version", curIncrementVersion);
439+
bool newIncrementVersion = EditorGUILayout.Toggle("Increment Version", curIncrementVersion);
375440

376441
if (newIncrementVersion != curIncrementVersion)
377442
{
@@ -385,7 +450,7 @@ private void OnGUI()
385450
// Build APPX
386451
GUI.enabled = ShouldBuildAppxBeEnabled;
387452

388-
if (GUILayout.Button("Build APPX from SLN", GUILayout.Width(buttonWidth_Half)))
453+
if (GUILayout.Button("Build APPX", GUILayout.Width(buttonWidth_Half)))
389454
{
390455
// Open SLN
391456
string slnFilename = Path.Combine(curBuildDirectory, PlayerSettings.productName + ".sln");
@@ -399,6 +464,7 @@ private void OnGUI()
399464
curMSBuildVer,
400465
curForceRebuildAppx,
401466
curBuildConfigString,
467+
curBuildPlatformString,
402468
curBuildDirectory,
403469
curIncrementVersion);
404470
}
@@ -426,7 +492,7 @@ private void OnGUI()
426492
if (!LocalIPsOnly)
427493
{
428494
string newTargetIPs = EditorGUILayout.TextField(
429-
new GUIContent(GUIHorizSpacer + "IP Address(es)", "IP(s) of target devices (e.g. 127.0.0.1;10.11.12.13)"),
495+
new GUIContent(GUIHorizontalSpacer + "IP Address(es)", "IP(s) of target devices (e.g. 127.0.0.1 | 10.11.12.13)"),
430496
curTargetIps);
431497

432498
if (newTargetIPs != curTargetIps)
@@ -466,7 +532,7 @@ private void OnGUI()
466532
GUI.enabled = false;
467533
}
468534

469-
var selectedAddressIndex = EditorGUILayout.Popup(GUIHorizSpacer + "IP Address", previouslySavedAddress, addressesToPresent.ToArray());
535+
var selectedAddressIndex = EditorGUILayout.Popup(GUIHorizontalSpacer + "IP Address", previouslySavedAddress, addressesToPresent.ToArray());
470536

471537
if (GUILayout.Button(locatorIsSearching ? "Searching" : "Refresh", GUILayout.Width(buttonWidth_Quarter)))
472538
{
@@ -486,12 +552,12 @@ private void OnGUI()
486552

487553
// Username/Password (and save seeings, if changed)
488554
string curUsername = BuildDeployPrefs.DeviceUser;
489-
string newUsername = EditorGUILayout.TextField(GUIHorizSpacer + "Username", curUsername);
555+
string newUsername = EditorGUILayout.TextField(GUIHorizontalSpacer + "Username", curUsername);
490556
string curPassword = BuildDeployPrefs.DevicePassword;
491-
string newPassword = EditorGUILayout.PasswordField(GUIHorizSpacer + "Password", curPassword);
557+
string newPassword = EditorGUILayout.PasswordField(GUIHorizontalSpacer + "Password", curPassword);
492558
bool curFullReinstall = BuildDeployPrefs.FullReinstall;
493559
bool newFullReinstall = EditorGUILayout.Toggle(
494-
new GUIContent(GUIHorizSpacer + "Uninstall first", "Uninstall application before installing"), curFullReinstall);
560+
new GUIContent(GUIHorizontalSpacer + "Uninstall First", "Uninstall application before installing"), curFullReinstall);
495561

496562
if (newUsername != curUsername ||
497563
newPassword != curPassword ||
@@ -505,7 +571,7 @@ private void OnGUI()
505571
// Build list (with install buttons)
506572
if (builds.Count == 0)
507573
{
508-
GUILayout.Label(GUIHorizSpacer + "*** No builds found in build directory", EditorStyles.boldLabel);
574+
GUILayout.Label(GUIHorizontalSpacer + "*** No builds found in build directory", EditorStyles.boldLabel);
509575
}
510576
else
511577
{
@@ -652,6 +718,7 @@ private void BuildAll(bool install = true)
652718
BuildDeployPrefs.MsBuildVersion,
653719
BuildDeployPrefs.ForceRebuild,
654720
BuildDeployPrefs.BuildConfig,
721+
BuildDeployPrefs.BuildPlatform,
655722
BuildDeployPrefs.BuildDirectory,
656723
BuildDeployPrefs.IncrementBuildVersion,
657724
showDialog: !install))
@@ -726,7 +793,7 @@ private string CalcPackageFamilyName()
726793
}
727794

728795
Debug.LogError("Unable to find PackageFamilyName in manifest file (" + manifest + ")");
729-
return "";
796+
return string.Empty;
730797
}
731798

732799
private void InstallAppOnDevicesList(string buildPath, string[] targetList)

0 commit comments

Comments
 (0)