/// <summary> /// Compile the current package and all child package recursively by generating a list of build steps /// </summary> private void RecursiveCompile(AssetCompilerResult result, AssetCompilerContext context, HashSet <Package> processed) { if (result == null) { throw new ArgumentNullException("result"); } if (context == null) { throw new ArgumentNullException("context"); } if (context.Package == null) { throw new ArgumentException("context.Package cannot be null", "context"); } if (processed.Contains(context.Package)) { return; } processed.Add(context.Package); var package = context.Package; GenerateRawImportBuildSteps(context, result); // 1. first recursively process all store packages foreach (var packageDependency in package.Meta.Dependencies) { var subPackage = session.Packages.Find(packageDependency); if (subPackage != null) { // Work on an immutable copy for the whole set of assets to compile var contextCopy = (AssetCompilerContext)context.Clone(); contextCopy.Package = subPackage; RecursiveCompile(result, contextCopy, processed); } else { result.Error("Unable to find package [{0}]", packageDependency); } } // 2. recursively process all local packages foreach (var subPackageReference in package.LocalDependencies) { var subPackage = session.Packages.Find(subPackageReference.Id); if (subPackage != null) { // Work on an immutable copy for the whole set of assets to compile var contextCopy = (AssetCompilerContext)context.Clone(); contextCopy.Package = subPackage; RecursiveCompile(result, contextCopy, processed); } else { result.Error("Unable to find package [{0}]", subPackageReference); } } result.Info("Compiling package [{0}]", package.FullPath); // Sort the items to build by build order var assets = package.Assets.ToList(); assets.Sort((item1, item2) => item1.Asset != null && item2.Asset != null ? item1.Asset.BuildOrder.CompareTo(item2.Asset.BuildOrder) : 0); // generate the build steps required to build the assets via base class Compile(context, assets, result); }
/// <summary> /// Compile the current package and all child package recursively by generating a list of build steps /// </summary> private void RecursiveCompile(AssetCompilerResult result, AssetCompilerContext context, HashSet<Package> processed) { if (result == null) throw new ArgumentNullException("result"); if (context == null) throw new ArgumentNullException("context"); if (context.Package == null) throw new ArgumentException("context.Package cannot be null", "context"); if (processed.Contains(context.Package)) { return; } processed.Add(context.Package); var package = context.Package; var session = package.Session; // 1. first recursively process all store packages foreach (var packageDependency in package.Meta.Dependencies) { var subPackage = session.Packages.Find(packageDependency); if (subPackage != null) { // Work on an immutable copy for the whole set of assets to compile var contextCopy = (AssetCompilerContext)context.Clone(); contextCopy.Package = subPackage; RecursiveCompile(result, contextCopy, processed); } else { result.Error("Unable to find package [{0}]", packageDependency); } } // 2. recursively process all local packages foreach (var subPackageReference in package.LocalDependencies) { var subPackage = session.Packages.Find(subPackageReference.Id); if (subPackage != null) { // Work on an immutable copy for the whole set of assets to compile var contextCopy = (AssetCompilerContext)context.Clone(); contextCopy.Package = subPackage; RecursiveCompile(result, contextCopy, processed); } else { result.Error("Unable to find package [{0}]", subPackageReference); } } result.Info("Compiling package [{0}]", package.FullPath); // Compile using all PackageCompiler foreach (var compiler in compilers) { var compilerResult = compiler.Compile(context); compilerResult.CopyTo(result); while (compilerResult.BuildSteps.Count > 0) { var step = compilerResult.BuildSteps[0]; compilerResult.BuildSteps.RemoveAt(0); result.BuildSteps.Add(step); } } }
/// <summary> /// Compile the current package and all child package recursively by generating a list of build steps /// </summary> private void RecursiveCompile(AssetCompilerResult result, AssetCompilerContext context, HashSet <Package> processed) { if (result == null) { throw new ArgumentNullException("result"); } if (context == null) { throw new ArgumentNullException("context"); } if (context.Package == null) { throw new ArgumentException("context.Package cannot be null", "context"); } if (processed.Contains(context.Package)) { return; } processed.Add(context.Package); var package = context.Package; var session = package.Session; // 1. first recursively process all store packages foreach (var packageDependency in package.Meta.Dependencies) { var subPackage = session.Packages.Find(packageDependency); if (subPackage != null) { // Work on an immutable copy for the whole set of assets to compile var contextCopy = (AssetCompilerContext)context.Clone(); contextCopy.Package = subPackage; RecursiveCompile(result, contextCopy, processed); } else { result.Error("Unable to find package [{0}]", packageDependency); } } // 2. recursively process all local packages foreach (var subPackageReference in package.LocalDependencies) { var subPackage = session.Packages.Find(subPackageReference.Id); if (subPackage != null) { // Work on an immutable copy for the whole set of assets to compile var contextCopy = (AssetCompilerContext)context.Clone(); contextCopy.Package = subPackage; RecursiveCompile(result, contextCopy, processed); } else { result.Error("Unable to find package [{0}]", subPackageReference); } } result.Info("Compiling package [{0}]", package.FullPath); // Compile using all PackageCompiler foreach (var compiler in compilers) { var compilerResult = compiler.Compile(context); compilerResult.CopyTo(result); while (compilerResult.BuildSteps.Count > 0) { var step = compilerResult.BuildSteps[0]; compilerResult.BuildSteps.RemoveAt(0); result.BuildSteps.Add(step); } } }