Skip to content

Commit

Permalink
fix: compatibility fixes & view models classes refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-yaremenko committed Apr 7, 2023
1 parent 4bd2cc3 commit d8d3e8c
Show file tree
Hide file tree
Showing 15 changed files with 84 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ static void SaveBuildMetadata(BuildMetadata buildMetadata, BuildTarget buildTarg
var buildNumber = 0;
if (versionsSheet == null)
{
spreadsheet.CreateGoogleSheet(sheetName);
spreadsheet.CreateGoogleSheet(new GoogleSheet.SheetProperties
{
Title = sheetName
});
spreadsheet.AppendGoogleCell(rangeAppend, s_Headers);
if (spreadsheet.SyncErrorMassage != null)
{
Expand Down
2 changes: 1 addition & 1 deletion com.stansassets.build/BuildPipeline/Core/BuildProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static void RunBuildTask(IBuildContext buildContext, IBuildTask task)
}
}

public static IBuildTasksContainer GenerateBuildStepsContainer()
public static IBuildTasksContainer GenerateBuildTasksContainer()
{
var tasksProvider = CreateBuildTasksProvider();
return tasksProvider.GetBuildTasks(new UserEditorBuildSettings());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace StansAssets.Build.Pipeline
{
class DefaultBuildTasksProvider : IBuildTasksProvider
{
public IBuildTasksContainer GetBuildSteps(IUserEditorBuildSettings buildSettings)
public IBuildTasksContainer GetBuildTasks(IUserEditorBuildSettings buildSettings)
{
var tasksContainer = new BuildTasksContainer();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
namespace StansAssets.Build.Pipeline
{
/// <summary>
/// Provides build steps.
/// Provides build tasks.
/// </summary>
public interface IBuildTasksContainer
{
/// <summary>
/// Pre process build steps. Order matters.
/// Pre process build tasks. Order matters.
/// </summary>
IReadOnlyList<IBuildTask> PreBuildTasks { get; }

/// <summary>
/// Post process build steps. Order matters.
/// Post process build tasks. Order matters.
/// </summary>
IReadOnlyList<IBuildTask> PostBuildTasks { get; }

/// <summary>
/// Scene process build steps. Order matters.
/// Scene process build tasks. Order matters.
/// </summary>
IReadOnlyList<IScenePostProcessTask> ScenePostProcessTasks { get; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ namespace StansAssets.Build.Pipeline
/// </summary>
public interface IBuildTasksProvider
{
IBuildTasksContainer GetBuildSteps(IUserEditorBuildSettings buildSettings);
IBuildTasksContainer GetBuildTasks(IUserEditorBuildSettings buildSettings);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace StansAssets.Build.Pipeline
{
/// <summary>
/// Represents a single async build step.
/// Represents a single async build task.
/// </summary>
public interface IAsyncBuildTask : IBuildTask
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ namespace StansAssets.Build.Pipeline
/// </summary>
public class BuildTasksContainer : IBuildTasksContainer
{
readonly List<IBuildTask> m_PreBuildSteps;
readonly List<IBuildTask> m_PostBuildSteps;
readonly List<IScenePostProcessTask> m_ScenePostProcessStepsTasks;
readonly List<IBuildTask> m_PreBuildTasks;
readonly List<IBuildTask> m_PostBuildTasks;
readonly List<IScenePostProcessTask> m_ScenePostProcessTasks;

public IReadOnlyList<IBuildTask> PreBuildTasks => m_PreBuildTasks;
public IReadOnlyList<IBuildTask> PostBuildTasks => m_PostBuildTasks;
Expand All @@ -18,9 +18,9 @@ public class BuildTasksContainer : IBuildTasksContainer
public BuildTasksContainer()
{

m_PreBuildSteps = new List<IBuildTask>();
m_PostBuildSteps = new List<IBuildTask>();
m_ScenePostProcessStepsTasks = new List<IScenePostProcessTask>();
m_PreBuildTasks = new List<IBuildTask>();
m_PostBuildTasks = new List<IBuildTask>();
m_ScenePostProcessTasks = new List<IScenePostProcessTask>();
}

/// <summary>
Expand All @@ -33,7 +33,7 @@ public void AddPreProcessTask(IBuildTask task)
}

/// <summary>
/// Registers a post process build step.
/// Registers a post process build task.
/// </summary>
/// <param name="task">Task to be registered.</param>
public void AddPostProcessTask(IBuildTask task)
Expand All @@ -42,7 +42,7 @@ public void AddPostProcessTask(IBuildTask task)
}

/// <summary>
/// Registers a post process scene step.
/// Registers a post process scene task.
/// </summary>
/// <param name="task">Task to be registered.</param>
public void AddScenePostProcessTask(IScenePostProcessTask task)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ namespace StansAssets.Build.Pipeline
[UsedImplicitly]
class BuildPipelineTab : BaseTab, IBuildSystemWindowTab
{
const string k_PreProcessStageBaseName = "preProcessSteps";
const string k_SceneProcessStageBaseName = "sceneProcessSteps";
const string k_PostProcessStageBaseName = "postProcessSteps";
const string k_PreProcessStageBaseName = "preProcessTasks";
const string k_SceneProcessStageBaseName = "sceneProcessTasks";
const string k_PostProcessStageBaseName = "postProcessTasks";

readonly Label m_TasksProviderName;

Expand All @@ -26,19 +26,19 @@ class BuildPipelineTab : BaseTab, IBuildSystemWindowTab
public BuildPipelineTab()
: base($"{BuildPipelineSettings.WindowTabsPath}/{nameof(BuildPipelineTab)}/{nameof(BuildPipelineTab)}")
{
m_StepsProviderName = this.Q<Label>("providerName");
m_StepsProviderName.AddToClassList("list-build-entity");
m_TasksProviderName = this.Q<Label>("providerName");
m_TasksProviderName.AddToClassList("list-build-entity");

var unityBuildStepsProvider = new UnityBuildStepsViewModelProvider();
var buildStepsProvider = new DefaultBuildStepsViewModelProvider();
var unityBuildTasksProvider = new UnityBuildTasksViewModelProvider();
var buildTasksProvider = new DefaultBuildTasksViewModelProvider();

SetBuildSteps(unityBuildStepsProvider.GetBuildSteps(), buildStepsProvider.GetBuildSteps());
SetBuildSteps(unityBuildTasksProvider.GetBuildSteps(), buildTasksProvider.GetBuildSteps());
SetProvider(BuildProcessor.GetProviderName());
}

void SetProvider(string providerName)
{
m_StepsProviderName.text = providerName;
m_TasksProviderName.text = providerName;
}

void SetBuildSteps(IBuildStepsViewModelContainer unityBuildStepsContainer, IBuildStepsViewModelContainer buildStepsContainer)
Expand Down Expand Up @@ -83,7 +83,7 @@ static void AddBuildSteps(VisualElement container, IEnumerable<BuildStepViewMode

if (!buildSteps.Any())
{
var label = new Label { text = "No Build Steps Defined" };
var label = new Label { text = "No Build Tasks Defined" };
label.AddToClassList("item-build-entity");
label.AddToClassList("italic");
container.Add(label);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
margin: 3px;
}

.steps-provider {
.tasks-provider {
height: 20px;
-unity-text-align: middle-left;
padding-left: 5px;
}

.steps-help-box {
.tasks-help-box {
padding-left: 5px;
padding-right: 5px;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@

<sa:SettingsBlock label="Build Pipeline">
<sa:HelpBox type="Info"
class="steps-help-box"
text="The actual execution order of steps with the same callback order may differ during the build process."/>
class="tasks-help-box"
text="The actual execution order of tasks with the same callback order may differ during the build process."/>

<ui:Label text="Preprocess Stage" name="labelBuildStep" class="label-build-entity"/>
<ui:VisualElement name="preProcessStepsBefore" class="list-unity-build-entity"/>
<ui:VisualElement name="preProcessSteps" class="list-build-entity"/>
<ui:VisualElement name="preProcessStepsAfter" class="list-unity-build-entity"/>
<ui:Label text="Preprocess Stage" name="labelBuildTask" class="label-build-entity"/>
<ui:VisualElement name="preProcessTasksBefore" class="list-unity-build-entity"/>
<ui:VisualElement name="preProcessTasks" class="list-build-entity"/>
<ui:VisualElement name="preProcessTasksAfter" class="list-unity-build-entity"/>

<ui:Label text="Scenes Process Stage" name="labelBuildTask" class="label-build-entity"/>
<ui:VisualElement name="sceneProcessStepsBefore" class="list-unity-build-entity"/>
<ui:VisualElement name="sceneProcessSteps" class="list-build-entity"/>
<ui:VisualElement name="sceneProcessStepsAfter" class="list-unity-build-entity"/>
<ui:VisualElement name="sceneProcessTasksBefore" class="list-unity-build-entity"/>
<ui:VisualElement name="sceneProcessTasks" class="list-build-entity"/>
<ui:VisualElement name="sceneProcessTasksAfter" class="list-unity-build-entity"/>

<ui:Label text="Postprocess Stage" name="labelBuildTask" class="label-build-entity"/>
<ui:VisualElement name="postProcessStepsBefore" class="list-unity-build-entity"/>
<ui:VisualElement name="postProcessSteps" class="list-build-entity"/>
<ui:VisualElement name="postProcessStepsAfter" class="list-unity-build-entity"/>
<ui:VisualElement name="postProcessTasksBefore" class="list-unity-build-entity"/>
<ui:VisualElement name="postProcessTasks" class="list-build-entity"/>
<ui:VisualElement name="postProcessTasksAfter" class="list-unity-build-entity"/>
</sa:SettingsBlock>

<sa:SettingsBlock label="Tasks Provider">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
using StansAssets.Build.Pipeline;

namespace StansAssets.Build.Pipeline
{
public class DefaultBuildStepsViewModelProvider : IBuildStepsViewModelProvider
{
public IBuildStepsViewModelContainer GetBuildSteps()
{
var provider = new DefaultBuildTasksProvider();
var container = new BuildStepsViewModelSortedContainer();
var callbackOrder = BuildProcessor.GetCallbackOrder();

var buildSteps = provider.GetBuildSteps(new UserEditorBuildSettings());

foreach (var preBuildStep in buildSteps.PreBuildTasks)
{
var step = new BuildStepViewModel(preBuildStep.GetType().FullName, callbackOrder);
container.AddPreBuildStep(step);
}

foreach (var sceneProcessStep in buildSteps.ScenePostProcessTasks)
{
var step = new BuildStepViewModel(sceneProcessStep.GetType().FullName, callbackOrder);
container.AddSceneProcessStep(step);
}

foreach (var postBuildStep in buildSteps.PostBuildTasks)
{
var step = new BuildStepViewModel(postBuildStep.GetType().FullName, callbackOrder);
container.AddSceneProcessStep(step);
}

return container;
}
}
}
using StansAssets.Build.Pipeline;

namespace StansAssets.Build.Pipeline
{
public class DefaultBuildTasksViewModelProvider : IBuildStepsViewModelProvider
{
public IBuildStepsViewModelContainer GetBuildSteps()
{
var provider = new DefaultBuildTasksProvider();
var container = new BuildStepsViewModelSortedContainer();
var callbackOrder = BuildProcessor.GetCallbackOrder();

var buildSteps = provider.GetBuildTasks(new UserEditorBuildSettings());

foreach (var preBuildStep in buildSteps.PreBuildTasks)
{
var step = new BuildStepViewModel(preBuildStep.GetType().FullName, callbackOrder);
container.AddPreBuildStep(step);
}

foreach (var sceneProcessStep in buildSteps.ScenePostProcessTasks)
{
var step = new BuildStepViewModel(sceneProcessStep.GetType().FullName, callbackOrder);
container.AddSceneProcessStep(step);
}

foreach (var postBuildStep in buildSteps.PostBuildTasks)
{
var step = new BuildStepViewModel(postBuildStep.GetType().FullName, callbackOrder);
container.AddSceneProcessStep(step);
}

return container;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
{
public interface IBuildStepsViewModelProvider
{
public IBuildStepsViewModelContainer GetBuildSteps();
IBuildStepsViewModelContainer GetBuildSteps();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@

namespace StansAssets.Build.Pipeline
{
public class UnityBuildStepsViewModelProvider : IBuildStepsViewModelProvider
public class UnityBuildTasksViewModelProvider : IBuildStepsViewModelProvider
{
public IBuildStepsViewModelContainer GetBuildSteps()
{
var stepsContainer = new BuildStepsViewModelSortedContainer();

CollectPreProcessSteps(stepsContainer);
CollectPreProcessTasks(stepsContainer);

return stepsContainer;
}

static void CollectPreProcessSteps(BuildStepsViewModelSortedContainer sortedContainer)
static void CollectPreProcessTasks(BuildStepsViewModelSortedContainer sortedContainer)
{
var preBuildStepsWithReport = CollectUnityBuildStepsWithReport<IPreprocessBuildWithReport>();
var sceneProcessStepsWithReport = CollectUnityBuildStepsWithReport<IProcessSceneWithReport>();
Expand Down

0 comments on commit d8d3e8c

Please sign in to comment.