Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
## [0.0.8-preview] - 2018-03-27
- Test rename & meta file cleanup
- Added documentation for shared classes / structs
- Updated inconsistent interface / class names
- Added missing parameter to IBuildParameters
- Ran spell check
- Moved IWriteOperation to Interfaces
- Update IWriteOperation properties to PascalCase
- Added IWriteOperation documentation
  • Loading branch information
Unity Technologies committed Mar 26, 2018
1 parent 55813ab commit 979bfea
Show file tree
Hide file tree
Showing 80 changed files with 1,908 additions and 1,197 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ All notable changes to this package will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [0.0.8-preview] - 2018-03-27
- Test rename & meta file cleanup
- Added documentation for shared classes / structs
- Updated inconsistent interface / class names
- Added missing parameter to IBuildParameters
- Ran spell check
- Moved IWriteOperation to Interfaces
- Update IWriteOperation properties to PascalCase
- Added IWriteOperation documentation

## [0.0.6-preview] - 2018-03-20
- doc updates

Expand Down
61 changes: 7 additions & 54 deletions Editor/ContentPipeline.cs
Original file line number Diff line number Diff line change
@@ -1,64 +1,26 @@
using System.Diagnostics;
using UnityEditor.Build.Interfaces;
using UnityEditor.Build.Utilities;
using UnityEditor.Build.Pipeline.Interfaces;
using UnityEditor.Build.Pipeline.Utilities;

namespace UnityEditor.Build.AssetBundle
namespace UnityEditor.Build.Pipeline.Content
{
public static class ContentPipeline
{
public const string kTempBuildPath = "Temp/ContentBuildData";

public static BuildCallbacks BuildCallbacks = new BuildCallbacks();

public static ReturnCodes BuildContentPacks(IBuildParameters buildParameters, IBuildContent buildContent, out IBuildResults result)
public static ReturnCodes BuildAssetBundles(IBuildParameters buildParameters, IBundleBuildContent buildContent, out IBundleBuildResults result)
{
var buildTimer = new Stopwatch();
buildTimer.Start();

ReturnCodes exitCode;
result = new BuildBuildResults();

using (var progressTracker = new ProgressTracker())
{
using (var buildCleanup = new BuildStateCleanup(buildParameters.TempOutputFolder))
{
var buildContext = new BuildContext(buildParameters, buildContent, result, progressTracker);
buildContext.SetContextObject(new PrefabPackedIdentifiers());
buildContext.SetContextObject(new BuildDependencyData());
buildContext.SetContextObject(new BuildWriteData());
buildContext.SetContextObject(BuildCallbacks);

var pipeline = DefaultBuildTasks.Create(DefaultBuildTasks.Presets.AutopackReleaseContent, buildParameters.ScriptInfo == null);
exitCode = BuildTasksRunner.Validate(pipeline, buildContext);
if (exitCode >= ReturnCodes.Success)
exitCode = BuildTasksRunner.Run(pipeline, buildContext);
}
}

buildTimer.Stop();
if (exitCode >= ReturnCodes.Success)
BuildLogger.Log("Build Content successful in: {0:c}", buildTimer.Elapsed);
else if (exitCode == ReturnCodes.Canceled)
BuildLogger.LogWarning("Build Content canceled in: {0:c}", buildTimer.Elapsed);
else
BuildLogger.LogError("Build Content failed in: {0:c}. Error: {1}.", buildTimer.Elapsed, exitCode);

return exitCode;
}

public static ReturnCodes BuildAssetBundles(IBuildParameters buildParameters, IBundleContent bundleContent, out IBundleBuildResults result)
{
var buildTimer = new Stopwatch();
buildTimer.Start();

ReturnCodes exitCode;
result = new BundleBuildResults();

using (var progressTracker = new ProgressTracker())
{
using (var buildCleanup = new BuildStateCleanup(buildParameters.TempOutputFolder))
{
var buildContext = new BuildContext(buildParameters, bundleContent, result, progressTracker);
var buildContext = new BuildContext(buildParameters, buildContent, result, progressTracker);
buildContext.SetContextObject(new BuildCache());
buildContext.SetContextObject(new Unity5PackedIdentifiers());
buildContext.SetContextObject(new BuildDependencyData());
buildContext.SetContextObject(new BundleWriteData());
Expand All @@ -70,16 +32,7 @@ public static ReturnCodes BuildAssetBundles(IBuildParameters buildParameters, IB
exitCode = BuildTasksRunner.Run(pipeline, buildContext);
}
}

buildTimer.Stop();
if (exitCode >= ReturnCodes.Success)
BuildLogger.Log("Build Asset Bundles successful in: {0:c}", buildTimer.Elapsed);
else if (exitCode == ReturnCodes.Canceled)
BuildLogger.LogWarning("Build Asset Bundles canceled in: {0:c}", buildTimer.Elapsed);
else
BuildLogger.LogError("Build Asset Bundles failed in: {0:c}. Error: {1}.", buildTimer.Elapsed, exitCode);

return exitCode;
}
}
}
}
115 changes: 115 additions & 0 deletions Editor/Interfaces/IBuildCache.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
using UnityEditor.Build.Content;
using UnityEditor.Build.Pipeline.Utilities;

namespace UnityEditor.Build.Pipeline.Interfaces
{
/// <summary>
/// Base interface for the Build Caching
/// </summary>
public interface IBuildCache : IContextObject
{
/// <summary>
/// Returns the relative directory path where dependency data can be cached for a specified cacheEntry.
/// </summary>
/// <param name="cacheEntry">Valid CacheEntry to get directory path.</param>
/// <returns>Relative directory path.</returns>
string GetDependencyCacheDirectory(CacheEntry cacheEntry);

/// <summary>
/// Returns the relative directory path where artifact data can be cached for a specified cacheEntry.
/// </summary>
/// <param name="cacheEntry">Valid CacheEntry to get directory path.</param>
/// <returns>Relative directory path.</returns>
string GetArtifactCacheDirectory(CacheEntry cacheEntry);

/// <summary>
/// Gets a CacheEntry for an asset identified by its GUID.
/// </summary>
/// <param name="asset">GUID identifier for an asset from the Asset Database</param>
/// <returns>CacheEntry representing current asset.</returns>
CacheEntry GetCacheEntry(GUID asset);

/// <summary>
/// Validates a cacheEntry and its dependencies.
/// </summary>
/// <param name="cacheEntry">The entry in the cache to validate.</param>
/// <returns><c>true</c> if the cacheEntry is valid; otherwise, <c>false</c>.</returns>
bool IsCacheEntryValid(CacheEntry cacheEntry);

/// <summary>
/// Tries to load from the cache generated dependency and usage data for a specified Assets's cacheEntry.
/// </summary>
/// <param name="cacheEntry">The entry to load dependency data.</param>
/// <param name="info">The Asset's generated dependency data to load. Parameter will not be chanced if data was unable to be loaded.</param>
/// <param name="usage">The Asset's generated usage data to load. Parameter will not be chanced if data was unable to be loaded.</param>
/// <returns><c>true</c> if the cache was able to load the specified data; otherwise, <c>false</c>.</returns>
bool TryLoadFromCache(CacheEntry cacheEntry, ref AssetLoadInfo info, ref BuildUsageTagSet usage);

/// <summary>
/// Tries to load from the cache generated dependency and usage data for a specified Scene's cacheEntry.
/// </summary>
/// <param name="cacheEntry">The entry to load dependency data.</param>
/// <param name="info">The Scene's generated dependency data to load.</param>
/// <param name="usage">The Scene's generated usage data to load.</param>
/// <returns><c>true</c> if the cache was able to load the specified data; otherwise, <c>false</c>.</returns>
bool TryLoadFromCache(CacheEntry cacheEntry, ref SceneDependencyInfo info, ref BuildUsageTagSet usage);

/// <summary>
/// Tries to load from the cache generated data for a specified cacheEntry.
/// </summary>
/// <typeparam name="T">The type of results data to load.</typeparam>
/// <param name="cacheEntry">The entry to load data.</param>
/// <param name="results">The generated data to load.</param>
/// <returns><c>true</c> if the cache was able to load the specified data; otherwise, <c>false</c>.</returns>
bool TryLoadFromCache<T>(CacheEntry cacheEntry, ref T results);

/// <summary>
/// Tries to load from the cache generated data for a specified cacheEntry.
/// </summary>
/// <typeparam name="T1">The first type of results data to load.</typeparam>
/// <typeparam name="T2">The second type of results data to cache.</typeparam>
/// <param name="cacheEntry">The entry to load data.</param>
/// <param name="results1">The first generated data to load.</param>
/// <param name="results2">The second generated data to load.</param>
/// <returns><c>true</c> if the cache was able to load the specified data; otherwise, <c>false</c>.</returns>
bool TryLoadFromCache<T1, T2>(CacheEntry cacheEntry, ref T1 results1, ref T2 results2);

/// <summary>
/// Tries to cache an Asset's cacheEntry and its generated dependency and usage data.
/// </summary>
/// <param name="cacheEntry">The entry for caching dependency data.</param>
/// <param name="info">The Asset's generated dependency data to cache.</param>
/// <param name="usage">The Asset's generated usage data to cache.</param>
/// <returns><c>true</c> if the cache was able to save the specified data; otherwise, <c>false</c>.</returns>
bool TrySaveToCache(CacheEntry cacheEntry, AssetLoadInfo info, BuildUsageTagSet usage);

/// <summary>
/// Tries to cache a Scene's cacheEntry and its generated dependency and usage data.
/// </summary>
/// <param name="cacheEntry">The entry for caching dependency data.</param>
/// <param name="info">The Scene's generated dependency data to cache.</param>
/// <param name="usage">The Scene's generated usage data to cache.</param>
/// <returns><c>true</c> if the cache was able to save the specified data; otherwise, <c>false</c>.</returns>
bool TrySaveToCache(CacheEntry cacheEntry, SceneDependencyInfo info, BuildUsageTagSet usage);

/// <summary>
/// Tries to cache generated data for the specified cacheEntry.
/// </summary>
/// <typeparam name="T">The type of results data to cache.</typeparam>
/// <param name="cacheEntry">The entry for caching data.</param>
/// <param name="results">The generated data to cache.</param>
/// <returns><c>true</c> if the cache was able to save the specified data; otherwise, <c>false</c>.</returns>
bool TrySaveToCache<T>(CacheEntry cacheEntry, T results);

/// <summary>
/// Tries to cache generated data for the specified cacheEntry.
/// </summary>
/// <typeparam name="T1">The first type of results data to cache.</typeparam>
/// <typeparam name="T2">The second type of results data to cache.</typeparam>
/// <param name="cacheEntry">The entry for caching data.</param>
/// <param name="results1">The first generated data to cache.</param>
/// <param name="results2">The second generated data to cache.</param>
/// <returns><c>true</c> if the cache was able to save the specified data; otherwise, <c>false</c>.</returns>
bool TrySaveToCache<T1, T2>(CacheEntry cacheEntry, T1 results1, T2 results2);
}
}

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

26 changes: 23 additions & 3 deletions Editor/Interfaces/IBuildContent.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,36 @@
using System.Collections.Generic;

namespace UnityEditor.Build.Interfaces
namespace UnityEditor.Build.Pipeline.Interfaces
{
/// <summary>
/// Base interface for feeding Assets to the Scriptable Build Pipeline.
/// </summary>
public interface IBuildContent : IContextObject
{
/// <summary>
/// List of Assets to include.
/// </summary>
List<GUID> Assets { get; }

/// <summary>
/// List of Scenes to include.
/// </summary>
List<GUID> Scenes { get; }
}

public interface IBundleContent : IBuildContent

/// <summary>
/// Base interface for feeding Assets with explicit Asset Bundle layout to the Scriptable Build Pipeline.
/// </summary>
public interface IBundleBuildContent : IBuildContent
{
/// <summary>
/// Specific layout of asset bundles to assets or scenes.
/// </summary>
Dictionary<string, List<GUID>> BundleLayout { get; }

/// <summary>
/// Custom loading identifiers to use for Assets or Scenes.
/// </summary>
Dictionary<GUID, string> Addresses { get; }
}
}
91 changes: 87 additions & 4 deletions Editor/Interfaces/IBuildContext.cs
Original file line number Diff line number Diff line change
@@ -1,40 +1,123 @@
using System;

namespace UnityEditor.Build.Interfaces
namespace UnityEditor.Build.Pipeline.Interfaces
{
/// <summary>
/// Base interface for all objects that can be stored in <see cref="IBuildContext"/>.
/// </summary>
public interface IContextObject { }

/// <summary>
/// Base interface that handles processing the callbacks after script building step.
/// </summary>
public interface IScriptsCallback : IContextObject
{
/// <summary>
/// Processes all the callbacks after script building step.
/// </summary>
/// <param name="buildParameters">Parameters passed into the build pipeline.</param>
/// <param name="buildResults">Results from the script building step.</param>
/// <returns>Return code from processing the callbacks.</returns>
ReturnCodes PostScripts(IBuildParameters buildParameters, IBuildResults buildResults);
}


/// <summary>
/// Base interface for handling running the callbacks after dependency calculation step.
/// </summary>
public interface IDependencyCallback : IContextObject
{
/// <summary>
/// Processes all the callbacks after dependency calculation step.
/// </summary>
/// <param name="buildParameters">Parameters passed into the build pipeline.</param>
/// <param name="dependencyData">Results from the dependency calculation step.</param>
/// <returns>Return code from processing the callbacks.</returns>
ReturnCodes PostDependency(IBuildParameters buildParameters, IDependencyData dependencyData);
}


/// <summary>
/// Base interface for handling running the callbacks after packing step.
/// </summary>
public interface IPackingCallback : IContextObject
{
/// <summary>
/// Processes all the callbacks after packing step.
/// </summary>
/// <param name="buildParameters">Parameters passed into the build pipeline.</param>
/// <param name="dependencyData">Results from the dependency calculation step.</param>
/// <param name="writeData">Results from the packing step.</param>
/// <returns>Return code from processing the callbacks.</returns>
ReturnCodes PostPacking(IBuildParameters buildParameters, IDependencyData dependencyData, IWriteData writeData);
}


/// <summary>
/// Base interface for handling running the callbacks after writing step.
/// </summary>
public interface IWritingCallback : IContextObject
{
/// <summary>
/// Processes all the callbacks after writing step.
/// </summary>
/// <param name="buildParameters">Parameters passed into the build pipeline.</param>
/// <param name="dependencyData">Results from the dependency calculation step.</param>
/// <param name="writeData">Results from the packing step.</param>
/// <param name="buildResults">Results from the writing step.</param>
/// <returns>Return code from processing the callbacks.</returns>
ReturnCodes PostWriting(IBuildParameters buildParameters, IDependencyData dependencyData, IWriteData writeData, IBuildResults buildResults);
}

/// <summary>
/// Base interface for build data container system
/// </summary>
public interface IBuildContext
{
/// <summary>
/// Checks the build context for existence of a data that is of the specified type.
/// </summary>
/// <typeparam name="T">Type of data to check for existence.</typeparam>
/// <returns><c>true</c> if the context contains specified type of data; otherwise, <c>false</c>.</returns>
bool ContainsContextObject<T>() where T : IContextObject;

/// <summary>
/// Checks the build context for existence of a data that is of the specified type.
/// </summary>
/// <param name="type">Type of data to check for existence.</param>
/// <returns><c>true</c> if the context contains specified type of data; otherwise, <c>false</c>.</returns>
bool ContainsContextObject(Type type);

/// <summary>
/// Gets the data of the specified type contained in the build context.
/// </summary>
/// <typeparam name="T">Type of data to return.</typeparam>
/// <returns>The type of data specified.</returns>
T GetContextObject<T>() where T : IContextObject;

/// <summary>
/// Gets the data of the specified type contained in the build context.
/// </summary>
/// <param name="type">Type of data to return.</param>
/// <returns>The type of data specified.</returns>
IContextObject GetContextObject(Type type);

/// <summary>
/// Adds the data of the specified type to the build context.
/// </summary>
/// <typeparam name="T">Type of data to add.</typeparam>
/// <param name="contextObject">Object holding the data to add.</param>
void SetContextObject<T>(IContextObject contextObject) where T : IContextObject;

/// <summary>
/// Adds the data to the build context. Type will be inferred using Reflection.
/// </summary>
/// <param name="contextObject">Object holding the data to add.</param>
void SetContextObject(IContextObject contextObject);

/// <summary>
/// Tries to get the data of the specified type contained in the build context.
/// </summary>
/// <typeparam name="T">Type of data to return.</typeparam>
/// <param name="contextObject">The object holding the data to be returned if found.</param>
/// <returns><c>true</c> if the context was able to returned the specified data; otherwise, <c>false</c>.</returns>
bool TryGetContextObject<T>(out T contextObject) where T : IContextObject;
}
}
Loading

0 comments on commit 979bfea

Please sign in to comment.