5 using System.Collections.Generic;
8 using SiliconStudio.BuildEngine;
10 namespace SiliconStudio.Assets.Compiler
19 private readonly CompilerRegistry<IAssetCompiler> compilerRegistry;
20 private int latestPriority;
28 this.compilerRegistry = compilerRegistry;
40 foreach (var assetItem
in assetItems)
42 var itemBuildStep = CompileItem(context, compilationResult, assetItem);
43 if (itemBuildStep != null)
44 compilationResult.BuildSteps.Add(itemBuildStep);
60 compiler = compilerRegistry.GetCompiler(assetItem.Asset.GetType());
64 compilationResult.Error(
"Cannot find a compiler for asset [{0}] from path [{1}]", ex, assetItem.Id,
77 var resultPerAssetType = compiler.Compile(context, assetItem);
80 var handler = AssetCompiled;
84 resultPerAssetType.CopyTo(compilationResult);
86 if (resultPerAssetType.BuildSteps == null)
90 var assetAbsolutePath = assetItem.FullPath;
91 assetAbsolutePath = Path.GetFullPath(assetAbsolutePath);
92 var module = string.Format(
"{0}(1,1)", assetAbsolutePath);
95 SetModule(resultPerAssetType.BuildSteps, module);
98 if (resultPerAssetType.ShouldWaitForPreviousBuilds)
101 foreach (var buildStep
in resultPerAssetType.BuildSteps)
103 buildStep.Priority = latestPriority++;
107 return resultPerAssetType.BuildSteps;
111 compilationResult.Error(
"Unexpected exception while compiling asset [{0}] from path [{1}]", ex, assetItem.Id,
122 private void SetModule(
BuildStep buildStep,
string module)
124 if (buildStep.
Module == null)
125 buildStep.Module = module;
128 if (enumerableBuildStep != null && enumerableBuildStep.Steps != null)
130 foreach (var child
in enumerableBuildStep.Steps)
132 SetModule(child, module);
A BuildStep that can spawn multiple BuildStep. Input and output tracking and merging will be performe...
Result of a compilation of assets when using IAssetCompiler.Compile
ItemListCompiler(CompilerRegistry< IAssetCompiler > compilerRegistry)
Create an instance of ItemListCompiler using the provided compiler registry.
BuildStep CompileItem(CompilerContext context, AssetCompilerResult compilationResult, AssetItem assetItem)
Compile the required build step necessary to produce the desired output item.
string Module
Gets or sets the module associated with this build step, used when logging error/information.
The context used when compiling an asset in a Package.
An asset item part of a Package accessible through SiliconStudio.Assets.Package.Assets.
When embedded in a EnumerableBuildStep, this build step will force all previous computations to be fi...
The base class to compile a series of AssetItems using associated IAssetCompilers. An item list compiler only creates the build steps required to creates some output items. The result of a compilation has then to be executed by the build engine to effectively create the outputs items.
EventHandler< AssetCompiledArgs > AssetCompiled
Raised when a single asset has been compiled.
void Compile(CompilerContext context, IEnumerable< AssetItem > assetItems, AssetCompilerResult compilationResult)
Compile the required build steps necessary to produce the desired outputs items.
The class represents the argument of the ItemListCompiler.AssetCompiled event raised by the ItemListC...
Main interface for compiling an Asset.