Skip to content
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
7 changes: 7 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ jobs:
# default, so this needs no extra setup.
- name: Validate platform scripts (dist/platforms)
run: bash scripts/validate-platform-scripts.sh
# Which subtarget the default build script asks Unity for. Handing Unity
# StandaloneBuildSubtarget.Default made it reuse the subtarget persisted
# in the project's Library, so a cached Library from a Server build
# turned later Player builds into Server builds. Compiles the resolver
# against Unity stubs with the .NET SDK ubuntu-latest ships.
- name: Default build script subtarget tests
run: bash scripts/test-build-subtarget.sh
# Parsing those scripts isn't enough for the licensing steps: what
# matters is which Unity.Licensing.Client invocation each credential
# combination produces, and whether the seat is handed back on every
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,6 @@ public static void BuildProject()
// Gather values from project
var scenes = EditorBuildSettings.scenes.Where(scene => scene.enabled).Select(s => s.path).ToArray();

#if UNITY_2021_2_OR_NEWER
// Determine subtarget
StandaloneBuildSubtarget buildSubtarget;
if (!options.TryGetValue("standaloneBuildSubtarget", out var subtargetValue) || !Enum.TryParse(subtargetValue, out buildSubtarget)) {
buildSubtarget = default;
}
#endif

var target = (BuildTarget) Enum.Parse(typeof(BuildTarget), options["buildTarget"]);

// Define BuildPlayer Options
Expand All @@ -79,7 +71,7 @@ public static void BuildProject()
target = target,
options = buildOptions,
#if UNITY_2021_2_OR_NEWER
subtarget = (int) buildSubtarget
subtarget = BuildSubtarget.Resolve(target, options)
#endif
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#if UNITY_2021_2_OR_NEWER
using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

namespace UnityBuilderAction.Input
{
// Standalone targets build the Player unless -standaloneBuildSubtarget asks for something else.
// Handing Unity StandaloneBuildSubtarget.Default instead would make it reuse the subtarget
// persisted in the project's Library, so a Library that once built a Server keeps building
// Servers, even on a runner without the Dedicated Server module.
public static class BuildSubtarget
{
public static int Resolve(BuildTarget target, Dictionary<string, string> options)
{
options.TryGetValue("standaloneBuildSubtarget", out var requested);

if (BuildPipeline.GetBuildTargetGroup(target) != BuildTargetGroup.Standalone)
{
if (!string.IsNullOrEmpty(requested))
{
Debug.LogWarning($"Ignoring standaloneBuildSubtarget \"{requested}\": it only applies to standalone targets, not {target}.");
}

return 0;
}

if (string.IsNullOrEmpty(requested))
{
return (int) StandaloneBuildSubtarget.Player;
}

if (!Enum.TryParse(requested, true, out StandaloneBuildSubtarget subtarget)
|| !Enum.IsDefined(typeof(StandaloneBuildSubtarget), subtarget))
{
throw new ArgumentException($"Unknown standaloneBuildSubtarget \"{requested}\"; expected Player or Server.");
}

return (int) subtarget;
}
}
}
#endif

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
Expand Up @@ -89,14 +89,6 @@ public static void BuildProject()
// Gather values from project
var scenes = EditorBuildSettings.scenes.Where(scene => scene.enabled).Select(s => s.path).ToArray();

#if UNITY_2021_2_OR_NEWER
// Determine subtarget
StandaloneBuildSubtarget buildSubtarget;
if (!options.TryGetValue("standaloneBuildSubtarget", out var subtargetValue) || !Enum.TryParse(subtargetValue, out buildSubtarget)) {
buildSubtarget = default;
}
#endif

BuildTarget buildTarget = (BuildTarget) Enum.Parse(typeof(BuildTarget), options["buildTarget"]);

// Define BuildPlayerOptions
Expand All @@ -106,7 +98,7 @@ public static void BuildProject()
target = buildTarget,
options = buildOptions,
#if UNITY_2021_2_OR_NEWER
subtarget = (int) buildSubtarget
subtarget = BuildSubtarget.Resolve(buildTarget, options)
#endif
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#if UNITY_2021_2_OR_NEWER
using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

namespace UnityBuilderAction.Input
{
// Standalone targets build the Player unless -standaloneBuildSubtarget asks for something else.
// Handing Unity StandaloneBuildSubtarget.Default instead would make it reuse the subtarget
// persisted in the project's Library, so a Library that once built a Server keeps building
// Servers, even on a runner without the Dedicated Server module.
public static class BuildSubtarget
{
public static int Resolve(BuildTarget target, Dictionary<string, string> options)
{
options.TryGetValue("standaloneBuildSubtarget", out var requested);

if (BuildPipeline.GetBuildTargetGroup(target) != BuildTargetGroup.Standalone)
{
if (!string.IsNullOrEmpty(requested))
{
Debug.LogWarning($"Ignoring standaloneBuildSubtarget \"{requested}\": it only applies to standalone targets, not {target}.");
}

return 0;
}

if (string.IsNullOrEmpty(requested))
{
return (int) StandaloneBuildSubtarget.Player;
}

if (!Enum.TryParse(requested, true, out StandaloneBuildSubtarget subtarget)
|| !Enum.IsDefined(typeof(StandaloneBuildSubtarget), subtarget))
{
throw new ArgumentException($"Unknown standaloneBuildSubtarget \"{requested}\"; expected Player or Server.");
}

return (int) subtarget;
}
}
}
#endif

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
Expand Up @@ -89,14 +89,6 @@ public static void BuildProject()
// Gather values from project
var scenes = EditorBuildSettings.scenes.Where(scene => scene.enabled).Select(s => s.path).ToArray();

#if UNITY_2021_2_OR_NEWER
// Determine subtarget
StandaloneBuildSubtarget buildSubtarget;
if (!options.TryGetValue("standaloneBuildSubtarget", out var subtargetValue) || !Enum.TryParse(subtargetValue, out buildSubtarget)) {
buildSubtarget = default;
}
#endif

BuildTarget buildTarget = (BuildTarget) Enum.Parse(typeof(BuildTarget), options["buildTarget"]);

// Define BuildPlayerOptions
Expand All @@ -106,7 +98,7 @@ public static void BuildProject()
target = buildTarget,
options = buildOptions,
#if UNITY_2021_2_OR_NEWER
subtarget = (int) buildSubtarget
subtarget = BuildSubtarget.Resolve(buildTarget, options)
#endif
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#if UNITY_2021_2_OR_NEWER
using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

namespace UnityBuilderAction.Input
{
// Standalone targets build the Player unless -standaloneBuildSubtarget asks for something else.
// Handing Unity StandaloneBuildSubtarget.Default instead would make it reuse the subtarget
// persisted in the project's Library, so a Library that once built a Server keeps building
// Servers, even on a runner without the Dedicated Server module.
public static class BuildSubtarget
{
public static int Resolve(BuildTarget target, Dictionary<string, string> options)
{
options.TryGetValue("standaloneBuildSubtarget", out var requested);

if (BuildPipeline.GetBuildTargetGroup(target) != BuildTargetGroup.Standalone)
{
if (!string.IsNullOrEmpty(requested))
{
Debug.LogWarning($"Ignoring standaloneBuildSubtarget \"{requested}\": it only applies to standalone targets, not {target}.");
}

return 0;
}

if (string.IsNullOrEmpty(requested))
{
return (int) StandaloneBuildSubtarget.Player;
}

if (!Enum.TryParse(requested, true, out StandaloneBuildSubtarget subtarget)
|| !Enum.IsDefined(typeof(StandaloneBuildSubtarget), subtarget))
{
throw new ArgumentException($"Unknown standaloneBuildSubtarget \"{requested}\"; expected Player or Server.");
}

return (int) subtarget;
}
}
}
#endif

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

Loading
Loading