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 (#104)
Browse files Browse the repository at this point in the history
* updatd platform definition for new build system

* moved build pipeline scripts specific to Lumin platform

* Added platform attribute to lumin build info

* Moved the pre process build step for lumin from unity player buld tools

* updated lumin build info

* updated processor logs a bit

* added version code

* bumped package version

* updated package with preview version
  • Loading branch information
StephenHodgson authored May 10, 2021
1 parent e0ade19 commit 62e6c68
Show file tree
Hide file tree
Showing 9 changed files with 194 additions and 15 deletions.
8 changes: 8 additions & 0 deletions XRTK.Lumin/Packages/com.xrtk.lumin/Editor/BuildPipeline.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,136 @@
// Copyright (c) XRTK. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using UnityEditor;
using UnityEditor.Build.Reporting;
using UnityEngine;
using XRTK.Attributes;
using XRTK.Definitions.Platforms;
using XRTK.Extensions;
using XRTK.Services;
using Debug = UnityEngine.Debug;

namespace XRTK.Editor.BuildPipeline
{
[RuntimePlatform(typeof(LuminPlatform))]
public class LuminBuildInfo : BuildInfo
{
/// <inheritdoc />
public override BuildTarget BuildTarget => BuildTarget.Lumin;

/// <inheritdoc />
public override bool Install => true;

/// <inheritdoc />
public override string ExecutableFileExtension => ".mpk";

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

if (MixedRealityToolkit.ActivePlatforms.Contains(BuildPlatform))
{
Debug.Log($"{nameof(LuminBuildInfo)}.{nameof(OnPreProcessBuild)}");
}

if (VersionCode.HasValue)
{
PlayerSettings.Lumin.versionCode = VersionCode.Value;
}
else
{
// Usually version codes are unique and not tied to the usual semver versions
// see https://developer.android.com/studio/publish/versioning#appversioning
// versionCode - A positive integer used as an internal version number.
// This number is used only to determine whether one version is more recent than another,
// with higher numbers indicating more recent versions. The Android system uses the
// versionCode value to protect against downgrades by preventing users from installing
// an APK with a lower versionCode than the version currently installed on their device.
PlayerSettings.Lumin.versionCode++;
}

var mabuPath = $"{Directory.GetParent(Application.dataPath)}\\Library\\Mabu";

if (IsCommandLine &&
Directory.Exists(mabuPath))
{
Directory.Delete(mabuPath, true);
}
}

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

if (MixedRealityToolkit.ActivePlatforms.Contains(BuildPlatform))
{
Debug.Log($"{nameof(LuminBuildInfo)}.{nameof(OnPostProcessBuild)}");
}

if (Install && !Application.isBatchMode)
{
InstallOnDevice();
}
}

private async void InstallOnDevice()
{
var canInstall = false;

try
{
var deviceResult = await new Process().RunAsync("mldb devices", false);

if (deviceResult.ExitCode == 0)
{
foreach (var deviceId in deviceResult.Output)
{
if (!string.IsNullOrWhiteSpace(deviceId))
{
Debug.Log(deviceId);

if (!deviceId.Contains("List"))
{
canInstall = true;
}
}
}
}
}
catch (Exception e)
{
Debug.Log(e);
}

if (!canInstall)
{
Debug.Log("No devices found, skipping installation");
return;
}

try
{
await new Process().RunAsync($"mldb install -u \"{OutputDirectory}\"", true);
}
catch (Exception e)
{
Debug.Log(e);
}
}
}
}

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,20 @@
{
"name": "XRTK.Lumin.Editor.BuildPipeline",
"references": [
"GUID:f3241d040533491e8a1e2714b27c3111",
"GUID:e67d30660ec243e4836aac191d3f36fb",
"GUID:258402e6b12e10c43925784eabc239e5",
"GUID:49d8940ef8dc2f044abcf0447091dced"
],
"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.

17 changes: 7 additions & 10 deletions XRTK.Lumin/Packages/com.xrtk.lumin/Runtime/LuminPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,14 @@ public override bool IsAvailable
}
}

#if UNITY_EDITOR

/// <inheritdoc />
public override bool IsBuildTargetAvailable
public override UnityEditor.BuildTarget[] ValidBuildTargets { get; } =
{
get
{
#if UNITY_EDITOR
return UnityEditor.EditorUserBuildSettings.activeBuildTarget == UnityEditor.BuildTarget.Lumin;
#else
return false;
#endif
}
}
UnityEditor.BuildTarget.Lumin
};

#endif // UNITY_EDITOR
}
}
4 changes: 2 additions & 2 deletions XRTK.Lumin/Packages/com.xrtk.lumin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"reality",
"lumin"
],
"version": "0.2.6",
"version": "0.2.7",
"unity": "2019.4",
"license": "MIT",
"repository": {
Expand All @@ -22,7 +22,7 @@
},
"author": "XRTK Team (https://github.com/XRTK)",
"dependencies": {
"com.xrtk.core": "0.2.13"
"com.xrtk.core": "0.2.14-preview.2"
},
"profiles": [
{
Expand Down
4 changes: 2 additions & 2 deletions XRTK.Lumin/Packages/packages-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
"url": "https://packages.unity.com"
},
"com.xrtk.core": {
"version": "0.2.13",
"version": "0.2.14-preview.2",
"depth": 1,
"source": "registry",
"dependencies": {
Expand All @@ -145,7 +145,7 @@
"depth": 0,
"source": "embedded",
"dependencies": {
"com.xrtk.core": "0.2.13"
"com.xrtk.core": "0.2.14-preview.2"
}
},
"com.unity.modules.ai": {
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ variables:
isReleaseBuild: $[ and( eq(variables['Build.SourceBranchName'], 'main'), or( eq(variables['build.reason'], 'BatchedCI'), eq(variables['build.reason'], 'Manual') ) ) ]
isPreviewBuild: $[ and( eq(variables['System.PullRequest.TargetBranch'], 'main'), eq(variables['build.reason'], 'PullRequest') ) ]

name: $(package.name) ${{ coalesce( variables['date'], '$(System.PullRequest.PullRequestNumber)', '$(Date:yyyyMMdd)' ) }}$(Rev:.r)
name: ${{ coalesce( variables['package.name'], variables['project.name'] ) }} ${{ coalesce( variables['date'], '$(System.PullRequest.PullRequestNumber)', '$(Date:yyyyMMdd)' ) }}$(Rev:.r)

pr:
autoCancel: true
Expand Down

0 comments on commit 62e6c68

Please sign in to comment.