This repository has been archived by the owner on May 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dev/updated platform definition (#104)
* 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
1 parent
2f9584c
commit 90c369a
Showing
7 changed files
with
191 additions
and
12 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
Editor/BuildPipeline/XRTK.Lumin.Editor.BuildPipeline.asmdef
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
7 changes: 7 additions & 0 deletions
7
Editor/BuildPipeline/XRTK.Lumin.Editor.BuildPipeline.asmdef.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters