Skip to content
This repository has been archived by the owner on May 13, 2022. It is now read-only.

Commit

Permalink
Dev/updated platform definition (#129)
Browse files Browse the repository at this point in the history
* Migrated uwp build pipeline scripts

* Converted build into to scriptable object

* updated proper versioning and bundle identifiers

* bumped version and updated dependencies for new build pipeline

* updated package dependencies for preview

* updated bundle version
  • Loading branch information
StephenHodgson authored May 10, 2021
1 parent ba46380 commit 4b35b81
Show file tree
Hide file tree
Showing 10 changed files with 705 additions and 2 deletions.
8 changes: 8 additions & 0 deletions Editor/BuildPipeline.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

411 changes: 411 additions & 0 deletions Editor/BuildPipeline/UwpAppxBuildTools.cs

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions Editor/BuildPipeline/UwpAppxBuildTools.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

118 changes: 118 additions & 0 deletions Editor/BuildPipeline/UwpBuildDeployPreferences.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
using System;
using System.IO;
using UnityEngine;
using XRTK.Editor.Utilities;
using XRTK.Utilities.WindowsDevicePortal.DataStructures;

namespace XRTK.Editor.BuildPipeline
{
public static class UwpBuildDeployPreferences
{
public static Version MIN_SDK_VERSION = new Version("10.0.17763.0");
private const string EDITOR_PREF_BUILD_CONFIG = "BuildDeployWindow_BuildConfig";
private const string EDITOR_PREF_FORCE_REBUILD = "BuildDeployWindow_ForceRebuild";
private const string EDITOR_PREF_CONNECT_INFOS = "BuildDeployWindow_DeviceConnections";
private const string EDITOR_PREF_FULL_REINSTALL = "BuildDeployWindow_FullReinstall";
private const string EDITOR_PREF_USE_SSL = "BuildDeployWindow_UseSSL";
private const string EDITOR_PREF_PROCESS_ALL = "BuildDeployWindow_ProcessAll";
private const string EDITOR_PREF_APP_ICON_SETTINGS_PATH = "ProjectSettings/Xrtk_MixedRealityIconPath.json";

/// <summary>
/// The current Build Configuration. (Debug, Release, or Master)
/// </summary>
public static string BuildConfig
{
get => EditorPreferences.Get(EDITOR_PREF_BUILD_CONFIG, "master");
set => EditorPreferences.Set(EDITOR_PREF_BUILD_CONFIG, value.ToLower());
}

/// <summary>
/// Current setting to force rebuilding the appx.
/// </summary>
public static bool ForceRebuild
{
get => EditorPreferences.Get(EDITOR_PREF_FORCE_REBUILD, false);
set => EditorPreferences.Set(EDITOR_PREF_FORCE_REBUILD, value);
}

/// <summary>
/// Current setting to fully uninstall and reinstall the appx.
/// </summary>
public static bool FullReinstall
{
get => EditorPreferences.Get(EDITOR_PREF_FULL_REINSTALL, true);
set => EditorPreferences.Set(EDITOR_PREF_FULL_REINSTALL, value);
}

private static string appIconPath;

/// <summary>
/// The path to the 3d app icon .glb asset.
/// </summary>
public static string MixedRealityAppIconPath
{
get
{
if (!string.IsNullOrEmpty(appIconPath))
{
return appIconPath;
}

var projectSettingsPath = Path.GetFullPath(EDITOR_PREF_APP_ICON_SETTINGS_PATH);

if (!File.Exists(projectSettingsPath))
{
var appIconAsset = new MixedRealityAppIcon { MixedRealityAppIconPath = string.Empty };
JsonUtility.ToJson(appIconAsset);
return appIconAsset.MixedRealityAppIconPath;
}

var data = File.ReadAllText(projectSettingsPath);
return JsonUtility.FromJson<MixedRealityAppIcon>(data).MixedRealityAppIconPath;
}
set
{
var projectSettingsPath = Path.GetFullPath(EDITOR_PREF_APP_ICON_SETTINGS_PATH);

if (!string.IsNullOrWhiteSpace(value))
{
Debug.Assert(value.EndsWith(".glb"), "3d App Icon must be a .glb asset");
}

appIconPath = value;
File.WriteAllText(projectSettingsPath, JsonUtility.ToJson(new MixedRealityAppIcon { MixedRealityAppIconPath = value }));
}
}

/// <summary>
/// The current device portal connections.
/// </summary>
public static string DevicePortalConnections
{
get => EditorPreferences.Get(
EDITOR_PREF_CONNECT_INFOS,
JsonUtility.ToJson(
new DevicePortalConnections(
new DeviceInfo("127.0.0.1", string.Empty, string.Empty, "Local Machine"))));
set => EditorPreferences.Set(EDITOR_PREF_CONNECT_INFOS, value);
}

/// <summary>
/// Current setting to use Single Socket Layer connections to the device portal.
/// </summary>
public static bool UseSSL
{
get => EditorPreferences.Get(EDITOR_PREF_USE_SSL, true);
set => EditorPreferences.Set(EDITOR_PREF_USE_SSL, value);
}

/// <summary>
/// Current setting to target all the devices registered to the build window.
/// </summary>
public static bool TargetAllConnections
{
get => EditorPreferences.Get(EDITOR_PREF_PROCESS_ALL, false);
set => EditorPreferences.Set(EDITOR_PREF_PROCESS_ALL, value);
}
}
}
11 changes: 11 additions & 0 deletions Editor/BuildPipeline/UwpBuildDeployPreferences.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

107 changes: 107 additions & 0 deletions Editor/BuildPipeline/UwpBuildInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
// Copyright (c) XRTK. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using System;
using System.Linq;
using UnityEditor;
using UnityEditor.Build.Reporting;
using UnityEngine;
using XRTK.Attributes;
using XRTK.Definitions.Platforms;
using XRTK.Services;

namespace XRTK.Editor.BuildPipeline
{
[RuntimePlatform(typeof(UniversalWindowsPlatform))]
public class UwpBuildInfo : BuildInfo
{
protected override void Awake()
{
base.Awake();
Version = PlayerSettings.WSA.packageVersion;
SolutionName = $"{PlayerSettings.productName}\\{PlayerSettings.productName}.sln";
BuildTargetFamilies = GetFamilies();
}

/// <inheritdoc />
public override BuildTarget BuildTarget => BuildTarget.WSAPlayer;

/// <inheritdoc />
public override Version Version { get; set; }

/// <summary>
/// The name of the Visual Studio .sln file generated.
/// </summary>
public string SolutionName { get; private set; }

/// <summary>
/// Build the appx bundle after building Unity Player?
/// </summary>
public bool BuildAppx { get; set; }

/// <summary>
/// Force rebuilding the appx bundle?
/// </summary>
public bool RebuildAppx { get; set; }

public string UwpSdk => EditorUserBuildSettings.wsaUWPSDK;

public string MinSdk => EditorUserBuildSettings.wsaMinUWPSDK;

public PlayerSettings.WSATargetFamily[] BuildTargetFamilies { get; private set; }

private static PlayerSettings.WSATargetFamily[] GetFamilies()
{
var values = (PlayerSettings.WSATargetFamily[])Enum.GetValues(typeof(PlayerSettings.WSATargetFamily));
return values.Where(PlayerSettings.WSA.GetTargetDeviceFamily).ToArray();
}

/// <inheritdoc />
public override void OnPostProcessBuild(BuildReport buildReport)
{
if (!MixedRealityToolkit.ActivePlatforms.Contains(BuildPlatform) ||
EditorUserBuildSettings.activeBuildTarget != BuildTarget)
{
return;
}

if (buildReport.summary.result == BuildResult.Failed)
{
if (!Application.isBatchMode)
{
EditorUtility.DisplayDialog($"{PlayerSettings.productName} Build {buildReport.summary.result}!", "See console for details", "OK");
}
}
else
{
if (BuildAppx ||
!Application.isBatchMode &&
!EditorUtility.DisplayDialog(PlayerSettings.productName, "Build Complete", "OK", "Build AppX"))
{
UwpAppxBuildTools.BuildAppx(this);
}
}
}

/// <inheritdoc />
public override void ParseCommandLineArgs()
{
base.ParseCommandLineArgs();

string[] arguments = Environment.GetCommandLineArgs();

for (int i = 0; i < arguments.Length; ++i)
{
switch (arguments[i])
{
case "-buildAppx":
BuildAppx = true;
break;
case "-rebuildAppx":
RebuildAppx = true;
break;
}
}
}
}
}
11 changes: 11 additions & 0 deletions Editor/BuildPipeline/UwpBuildInfo.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "XRTK.WindowsMixedReality.Editor.BuildPipeline",
"references": [
"GUID:f3241d040533491e8a1e2714b27c3111",
"GUID:e67d30660ec243e4836aac191d3f36fb",
"GUID:258402e6b12e10c43925784eabc239e5"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"mixed",
"reality"
],
"version": "0.2.8",
"version": "0.2.9",
"unity": "2019.4",
"license": "MIT",
"repository": {
Expand All @@ -19,7 +19,7 @@
},
"author": "XRTK Team (https://github.com/XRTK)",
"dependencies": {
"com.xrtk.core": "0.2.13",
"com.xrtk.core": "0.2.14-preview.2",
"com.unity.xr.windowsmr.metro": "4.2.3"
},
"profiles": [
Expand Down

0 comments on commit 4b35b81

Please sign in to comment.