Skip to content
This repository was archived by the owner on Jan 18, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
- Updated the `MobileWorkerConnector` to use the KCP network protocol by default.
- Changed the `mobile_launch.json` config to use the new Runtime.
- Updated all the launch configs to use the new Runtime.
- Changed the way builds are processed in the Unity Editor. If you don't have build support for a particular target, that specific build target will be skipped rather than the whole build process cancelled.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we drop the first sentence and just say something like "Changed the Unity Editor building process to skip builds with missing targets"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be cheeky and change it in #705 so I don't have to rerun CI here 😛

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless people have code concerns


### Fixed

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Improbable.Gdk.BuildSystem;
using Improbable.Gdk.BuildSystem.Configuration;
using UnityEditor;
using UnityEngine;
Expand Down Expand Up @@ -52,6 +53,25 @@ public static BuildTarget[] GetBuildTargetsMissingBuildSupport(params BuildTarge
.ToArray();
}

public static string[] FilterWorkerTypes(BuildEnvironment environment, string[] desiredWorkerTypes)
{
return desiredWorkerTypes.Where(wantedWorkerType =>
{
var buildTargetsForWorker =
WorkerBuilder.GetBuildTargetsForWorkerForEnvironment(wantedWorkerType, environment);
var buildTargetsMissingBuildSupport = GetBuildTargetsMissingBuildSupport(buildTargetsForWorker);

if (buildTargetsMissingBuildSupport.Length > 0)
{
Debug.LogError(ConstructMissingSupportMessage(wantedWorkerType,
environment, buildTargetsMissingBuildSupport));
return false;
}

return true;
}).ToArray();
}

public static string ConstructMissingSupportMessage(string workerType, BuildEnvironment environment,
BuildTarget[] buildTargetsMissingBuildSupport)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,18 @@ public static void Build()
CommandLineUtility.GetCommandLineValue(commandLine, BuildWorkerTypes,
"UnityClient,UnityGameLogic");

var wantedWorkerTypes = workerTypesArg.Split(',');
foreach (var wantedWorkerType in wantedWorkerTypes)
{
var buildTargetsForWorker = GetBuildTargetsForWorkerForEnvironment(wantedWorkerType, buildEnvironment);
var buildTargetsMissingBuildSupport = BuildSupportChecker.GetBuildTargetsMissingBuildSupport(buildTargetsForWorker);
var desiredWorkerTypes = workerTypesArg.Split(',');
var filteredWorkerTypes = BuildSupportChecker.FilterWorkerTypes(buildEnvironment, desiredWorkerTypes);

if (buildTargetsMissingBuildSupport.Length > 0)
{
throw new BuildFailedException(BuildSupportChecker.ConstructMissingSupportMessage(wantedWorkerType, buildEnvironment, buildTargetsMissingBuildSupport));
}
if (desiredWorkerTypes.Length != filteredWorkerTypes.Length)
{
throw new BuildFailedException(
"Unable to complete build. Missing build support. Check logs for specific errors.");
}

ScriptingImplementation scriptingBackend;
var wantedScriptingBackend = CommandLineUtility.GetCommandLineValue(commandLine, "scriptingBackend", "mono");
var wantedScriptingBackend =
CommandLineUtility.GetCommandLineValue(commandLine, "scriptingBackend", "mono");
switch (wantedScriptingBackend)
{
case "mono":
Expand All @@ -81,7 +79,7 @@ public static void Build()

LocalLaunch.BuildConfig();

foreach (var wantedWorkerType in wantedWorkerTypes)
foreach (var wantedWorkerType in filteredWorkerTypes)
{
BuildWorkerForEnvironment(wantedWorkerType, buildEnvironment, scriptingBackend);
}
Expand All @@ -98,9 +96,11 @@ public static void Build()
}
}

public static BuildTarget[] GetBuildTargetsForWorkerForEnvironment(string workerType, BuildEnvironment targetEnvironment)
public static BuildTarget[] GetBuildTargetsForWorkerForEnvironment(string workerType,
BuildEnvironment targetEnvironment)
{
var environmentConfig = SpatialOSBuildConfiguration.GetInstance().GetEnvironmentConfigForWorker(workerType, targetEnvironment);
var environmentConfig = SpatialOSBuildConfiguration.GetInstance()
.GetEnvironmentConfigForWorker(workerType, targetEnvironment);
if (environmentConfig == null)
{
return new BuildTarget[0];
Expand All @@ -109,10 +109,12 @@ public static BuildTarget[] GetBuildTargetsForWorkerForEnvironment(string worker
return GetUnityBuildTargets(environmentConfig.BuildPlatforms);
}

public static void BuildWorkerForEnvironment(string workerType, BuildEnvironment targetEnvironment, ScriptingImplementation? scriptingBackend = null)
public static void BuildWorkerForEnvironment(string workerType, BuildEnvironment targetEnvironment,
ScriptingImplementation? scriptingBackend = null)
{
var spatialOSBuildConfiguration = SpatialOSBuildConfiguration.GetInstance();
var environmentConfig = spatialOSBuildConfiguration.GetEnvironmentConfigForWorker(workerType, targetEnvironment);
var environmentConfig =
spatialOSBuildConfiguration.GetEnvironmentConfigForWorker(workerType, targetEnvironment);
if (environmentConfig == null)
{
Debug.LogWarning($"Skipping build for {workerType}.");
Expand Down Expand Up @@ -149,7 +151,6 @@ public static void BuildWorkerForEnvironment(string workerType, BuildEnvironment
{
PlayerSettings.SetScriptingBackend(buildTargetGroup, activeScriptingBackend);
}

}
}

Expand Down Expand Up @@ -222,7 +223,8 @@ internal static SpatialBuildPlatforms GetCurrentBuildPlatform()
private static void BuildWorkerForTarget(string workerType, BuildTarget buildTarget,
BuildOptions buildOptions, BuildEnvironment targetEnvironment)
{
Debug.Log($"Building \"{buildTarget}\" for worker platform: \"{workerType}\", environment: \"{targetEnvironment}\"");
Debug.Log(
$"Building \"{buildTarget}\" for worker platform: \"{workerType}\", environment: \"{targetEnvironment}\"");

var spatialOSBuildConfiguration = SpatialOSBuildConfiguration.GetInstance();
var workerBuildData = new WorkerBuildData(workerType, buildTarget);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#>
<#= generatedHeader #>

using System.Linq;
using Improbable.Gdk.BuildSystem;
using Improbable.Gdk.BuildSystem.Configuration;
using Improbable.Gdk.Tools;
Expand Down Expand Up @@ -90,23 +91,30 @@ var workerType = workerTypeList[i];
// Delaying build by a frame to ensure the editor has re-rendered the UI to avoid odd glitches.
EditorApplication.delayCall += () =>
{
if (!CheckWorkersCanBuildForEnvironment(environment, workerTypes))
{
DisplayBuildFailureDialog();

return;
}
var filteredWorkerTypes = BuildSupportChecker.FilterWorkerTypes(environment, workerTypes);

try
{
LocalLaunch.BuildConfig();

foreach (var workerType in workerTypes)
foreach (var workerType in filteredWorkerTypes)
{
WorkerBuilder.BuildWorkerForEnvironment(workerType, environment);
}

Debug.LogFormat("Completed build for {0} target", environment);
if (workerTypes.Length == filteredWorkerTypes.Length)
{
Debug.Log($"Completed build for {environment} target.");
}
else
{
var missingWorkerTypes = string.Join(" ", workerTypes.Except(filteredWorkerTypes));
var completedWorkerTypes = string.Join(" ", workerTypes.Intersect(filteredWorkerTypes));
Debug.LogWarning(
$"Completed build for {environment} target.\n"
+ $"Completed builds for: {completedWorkerTypes}\n"
+ $"Skipped builds for: {missingWorkerTypes}. See above for more information.");
}
}
catch (System.Exception)
{
Expand Down