Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indirect build scheme overrides #16

Merged
merged 10 commits into from
Jan 17, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ public static void PreBuild()
// TODO: System.Commandline ライクな実装に仕上げたいが後回し
RunCommand(context =>
{
var configurations = BuildConfigurationUtility.ResolveConfigurations(
context.BaseScheme?.PreBuildConfigurations ?? Enumerable.Empty<IBuildConfiguration>(),
context.CurrentScheme.PreBuildConfigurations);
var configurations =
BuildSchemeUtility.EnumerateComposedConfigurations<IPreBuildContext>(context
.InheritanceTreeFromLeafToRoot);

var preBuildTasks = configurations
.Select(c => CreateBuildTask(c, context))
Expand All @@ -68,9 +68,9 @@ public static void Build()
{
var internalPrepareTasks = CreateInternalPrepareTasks(context);

var configurations = BuildConfigurationUtility.ResolveConfigurations(
context.BaseScheme?.PostBuildConfigurations ?? Enumerable.Empty<IBuildConfiguration>(),
context.CurrentScheme.PostBuildConfigurations);
var configurations =
BuildSchemeUtility.EnumerateComposedConfigurations<IPostBuildContext>(context
.InheritanceTreeFromLeafToRoot);

var postBuildTasks = configurations
.Select(c => CreateBuildTask(c, context))
Expand Down Expand Up @@ -142,11 +142,13 @@ private static int InvokeCommand(Action<Context> command)
}
}

internal static BuildScheme LoadScheme(CommandLineParser parser)
internal static BuildScheme LoadScheme(CommandLineParser parser, IEnumerable<BuildScheme> allSchemes = null)
{
var name = parser.ParseFirst(SchemeOption);

var scheme = BuildSchemeLoader.LoadAll<BuildScheme>().FirstOrDefault(s => s.Name == name);
allSchemes ??= BuildSchemeLoader.LoadAll<BuildScheme>();

var scheme = allSchemes.FirstOrDefault(s => s.Name == name);
if (scheme == null)
{
throw new CommandLineArgumentException($"No such scheme found: {name}");
Expand All @@ -155,18 +157,6 @@ internal static BuildScheme LoadScheme(CommandLineParser parser)
return scheme;
}

internal static BuildScheme LoadBaseScheme(BuildScheme scheme)
{
if (string.IsNullOrEmpty(scheme.BaseSchemeName))
return null;

var baseScheme = BuildSchemeLoader.LoadAll<BuildScheme>().FirstOrDefault(s => s.Name == scheme.BaseSchemeName);
if (baseScheme == null)
throw new CommandLineArgumentException($"No such base scheme found: {scheme.BaseSchemeName}");

return baseScheme;
}

internal static List<OverrideProperty> ParseOverrideProperties(
CommandLineParser parser,
IDictionary<string, string> aliases = null)
Expand Down Expand Up @@ -204,7 +194,7 @@ internal class Context
{
public CommandLineParser CommandLineParser { get; }
public IBuildScheme CurrentScheme { get; }
public IBuildScheme BaseScheme { get; }
public IEnumerable<IBuildScheme> InheritanceTreeFromLeafToRoot { get; }
public BuildPropertyResolver BuildPropertyResolver { get; }

public BuildTaskBuilderProvider TaskBuilderProvider { get; }
Expand All @@ -215,25 +205,26 @@ internal class Context
public static Context Create(ILogger logger)
{
var parser = CommandLineParser.Create();
var scheme = LoadScheme(parser);
var baseScheme = LoadBaseScheme(scheme);
var allSchemes = BuildSchemeLoader.LoadAll<BuildScheme>();
var scheme = LoadScheme(parser, allSchemes);
var tree = BuildSchemeUtility.EnumerateSchemeTreeFromLeafToRoot(scheme, allSchemes);
var resolver = BuildPropertyResolver.CreateDefault(ParseOverrideProperties(parser, OverrideAliases));
var provider = BuildTaskBuilderProvider.CreateDefault();

return new Context(parser, scheme, baseScheme, provider, resolver, logger);
return new Context(parser, scheme, tree, provider, resolver, logger);
}

private Context(
CommandLineParser parser,
IBuildScheme scheme,
IBuildScheme baseScheme,
IEnumerable<IBuildScheme> inheritanceTreeFromLeafToRoot,
BuildTaskBuilderProvider provider,
BuildPropertyResolver resolver,
ILogger logger)
{
CommandLineParser = parser;
CurrentScheme = scheme;
BaseScheme = baseScheme;
InheritanceTreeFromLeafToRoot = inheritanceTreeFromLeafToRoot;
BuildPropertyResolver = resolver;
TaskBuilderProvider = provider;
Logger = logger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ ListView.hide-empty .unity-list-view__empty-label {
}

Label.left-entry {
padding-left: 18px;
}

.right-pane-container {
Expand Down Expand Up @@ -73,3 +72,8 @@ Label.configuration-name {
margin-bottom: 1px;
margin-left: 4px;
}


LeftPaneListEntryView {
flex-grow: 1;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
<uie:ToolbarButton text="Save" parse-escape-sequences="true" display-tooltip-when-elided="true" />
<uie:ToolbarMenu tabindex="-1" parse-escape-sequences="true" display-tooltip-when-elided="true" text="Menu" />
</uie:Toolbar>
<ui:ListView show-alternating-row-backgrounds="ContentOnly" class="hide-size hide-empty" style="flex-grow: 1;" />
<BuildMagic.Window.Editor.Elements.LeftPaneTreeView show-alternating-row-backgrounds="All" reorderable="true" view-data-key="LeftPane_LeftPaneTreeView" />
</ui:UXML>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
<ui:VisualElement style="flex-direction: row; flex-grow: 1; align-self: flex-start;">
<ui:VisualElement name="auto-mark" class="auto-mark" />
<ui:VisualElement style="flex-direction: row; flex-grow: 1; align-self: stretch; align-items: center;">
<ui:Label parse-escape-sequences="true" display-tooltip-when-elided="true" name="name-label" text="Name" class="left-entry" style="-unity-text-align: middle-left;" />
<ui:Label parse-escape-sequences="true" display-tooltip-when-elided="true" name="auto-mark" text="primary" style="-unity-text-align: middle-left; border-top-left-radius: 6px; border-top-right-radius: 6px; border-bottom-right-radius: 6px; border-bottom-left-radius: 6px; background-color: rgba(127, 127, 127, 0.5); padding-top: 1px; padding-right: 5px; padding-bottom: 1px; padding-left: 5px; font-size: 10px; margin-left: 4px;" />
</ui:VisualElement>
</ui:UXML>
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,13 @@
</ui:VisualElement>
<ui:ScrollView>
<ui:Foldout text="Pre-build" name="pre-build-configuration-foldout" class="configuration-list-foldout">
<ui:ListView name="pre-build-configuration-list" reorderable="true" virtualization-method="DynamicHeight" reorder-mode="Animated" show-bound-collection-size="false" show-foldout-header="false" header-title="Pre Build Configuration" class="hide-size hide-empty configuration-list" />
<ui:BindableElement class="derived">
<ui:ListView name="pre-build-configuration-list" reorderable="false" virtualization-method="DynamicHeight" reorder-mode="Animated" show-bound-collection-size="false" show-foldout-header="true" header-title="Derived" class="hide-size hide-empty configuration-list" />
</ui:BindableElement>
<BuildMagic.Window.Editor.Elements.ConfigurationListView configuration-type="PreBuild" class="configuration-list-view-root" />
</ui:Foldout>
<ui:Foldout text="Internal Prepare" name="internal-prepare-configuration-foldout" class="configuration-list-foldout">
<ui:ListView name="internal-prepare-configuration-list" reorderable="true" virtualization-method="DynamicHeight" reorder-mode="Animated" show-bound-collection-size="false" header-title="Build Player Settings" show-foldout-header="false" class="hide-size hide-empty configuration-list" />
<ui:BindableElement class="derived">
<ui:ListView name="internal-prepare-configuration-list" reorderable="false" virtualization-method="DynamicHeight" reorder-mode="Animated" show-bound-collection-size="false" header-title="Derived" show-foldout-header="true" class="hide-size hide-empty configuration-list" />
</ui:BindableElement>
<BuildMagic.Window.Editor.Elements.ConfigurationListView configuration-type="InternalPrepare" class="configuration-list-view-root" />
</ui:Foldout>
<ui:Foldout text="Post-build" name="post-build-configuration-foldout" class="configuration-list-foldout">
<ui:ListView name="post-build-configuration-list" reorderable="true" virtualization-method="DynamicHeight" reorder-mode="Animated" show-bound-collection-size="false" show-foldout-header="false" header-title="Post Build Configuration" class="hide-size hide-empty configuration-list" />
<ui:BindableElement class="derived">
<ui:ListView name="post-build-configuration-list" reorderable="false" virtualization-method="DynamicHeight" reorder-mode="Animated" show-bound-collection-size="false" show-foldout-header="true" header-title="Derived" class="hide-size hide-empty configuration-list" />
</ui:BindableElement>
<BuildMagic.Window.Editor.Elements.ConfigurationListView configuration-type="PostBuild" class="configuration-list-view-root" />
</ui:Foldout>
</ui:ScrollView>
</ui:BindableElement>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
<BuildMagic.Window.Editor.Elements.TwoPaneSplitView>
<BuildMagic.Window.Editor.Elements.TwoPaneSplitView view-data-key="BuildMagicWindow-TwoPaneSplitView">
<BuildMagic.Window.Editor.Elements.LeftPaneView />
<BuildMagic.Window.Editor.Elements.RightPaneView />
</BuildMagic.Window.Editor.Elements.TwoPaneSplitView>
Expand Down
Loading