Esempio n. 1
0
        /// <summary>
        /// Build the specified data with the provided builderInput.  This is the public entry point.
        ///  Child class overrides should use <see cref="BuildDataImplementation{TResult}"/>
        /// </summary>
        /// <typeparam name="TResult">The type of data to build.</typeparam>
        /// <param name="builderInput">The builderInput object used in the build.</param>
        /// <returns>The build data result.</returns>
        public TResult BuildData <TResult>(AddressablesDataBuilderInput builderInput) where TResult : IDataBuilderResult
        {
            if (!CanBuildData <TResult>())
            {
                var message = "Data builder " + Name + " cannot build requested type: " + typeof(TResult);
                Debug.LogError(message);
                return(AddressableAssetBuildResult.CreateResult <TResult>(null, 0, message));
            }

            BuildLog log = new BuildLog();

            m_Log = log;
            AddressablesRuntimeProperties.ClearCachedPropertyValues();

            TResult result;

            // Append the file registry to the results
            using (log.ScopedStep(LogLevel.Info, $"Building {this.Name}"))
            {
                result = BuildDataImplementation <TResult>(builderInput);
                if (result != null)
                {
                    result.FileRegistry = builderInput.Registry;
                }
            }

            var perfOutputDirectory = Path.GetDirectoryName(Application.dataPath) + "/Library/com.unity.addressables";

            File.WriteAllText(Path.Combine(perfOutputDirectory, "AddressablesBuildTEP.json"), log.FormatAsTraceEventProfiler());
            File.WriteAllText(Path.Combine(perfOutputDirectory, "AddressablesBuildLog.txt"), log.FormatAsText());

            return(result);
        }
Esempio n. 2
0
 /// <summary>
 /// Adds details to the active build step
 /// </summary>
 /// <param name="log">The build log.</param>
 /// <param name="level">The log level of this entry.</param>
 /// <param name="msg">The message to add.</param>
 public static void AddEntrySafe(this IBuildLogger log, LogLevel level, string msg)
 {
     if (log != null)
     {
         log.AddEntry(level, msg);
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TaskSetupEngine"/> class.
        /// </summary>
        /// <param name="buildLogger">The build logger.</param>
        /// <param name="paths">The paths to setup the task.</param>
        /// <exception cref="ArgumentNullException"><paramref name="paths"/> is <c>null</c>.</exception>
        /// <exception cref="InvalidOperationException">The <see cref="TaskContext"/>.Default.TaskService delivered no valid ITaskService.</exception>
        public TaskSetupEngine(
            IBuildLogger buildLogger,
            IEnumerable <PathDataType> paths)
        {
            if (buildLogger == null)
            {
                throw new ArgumentNullException("buildLogger");
            }
            if (paths == null)
            {
                throw new ArgumentNullException("paths");
            }

            // this.taskService = taskService;
            this.taskService = TaskContext.Default.TaskService;
            if (this.taskService == null)
            {
                throw new InvalidOperationException("The TaskContext.Default.TaskService delivered no valid ITaskService.");
            }

            this.Paths       = paths;
            this.buildLogger = buildLogger;

            this.buildLogger.LogBuildMessage(this, GetType().Name, "Initialized");
        }
Esempio n. 4
0
 public BuilderInformation(string mainAssemlyPath, IBuildLogger buildLogger)
 {
     OutputFiles = new List <OutputFile> {
         new OutputFile(mainAssemlyPath, OutputFileType.MainAssembly)
     };
     BuildLogger = buildLogger;
 }
Esempio n. 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TaskSetupEngine"/> class.
        /// </summary>
        /// <param name="buildLogger">The build logger.</param>
        /// <param name="paths">The paths to setup the task.</param>
        /// <exception cref="ArgumentNullException"><paramref name="paths"/> is <c>null</c>.</exception>
        /// <exception cref="InvalidOperationException">The <see cref="TaskContext"/>.Default.TaskService delivered no valid ITaskService.</exception>
        public TaskSetupEngine(
            IBuildLogger buildLogger,
            IEnumerable<PathDataType> paths)
        {
            if (buildLogger == null)
            {
                throw new ArgumentNullException("buildLogger");
            }
            if (paths == null)
            {
                throw new ArgumentNullException("paths");
            }

            // this.taskService = taskService;
            this.taskService = TaskContext.Default.TaskService;
            if (this.taskService == null)
            {
                throw new InvalidOperationException("The TaskContext.Default.TaskService delivered no valid ITaskService.");
            }

            this.Paths = paths;
            this.buildLogger = buildLogger;

            this.buildLogger.LogBuildMessage(this, GetType().Name, "Initialized");
        }
        /// <inheritdoc />
        public Hash128 GetHash128(IBuildLogger log)
        {
#if UNITY_2019_3_OR_NEWER
            CacheEntry entry = BuildCacheUtility.GetCacheEntry(Scene);
#else
            CacheEntry entry = BuildCacheUtility.GetCacheEntry(ProcessedScene);
#endif
            HashSet <CacheEntry> hashObjects = new HashSet <CacheEntry>();
            using (log.ScopedStep(LogLevel.Verbose, $"Gather Objects", Command.fileName))
                Command.GatherSerializedObjectCacheEntries(hashObjects);

            List <Hash128> hashes = new List <Hash128>();
            using (log.ScopedStep(LogLevel.Verbose, $"Hashing Command", Command.fileName))
                hashes.Add(Command.GetHash128());
            using (log.ScopedStep(LogLevel.Verbose, $"Hashing UsageSet", Command.fileName))
                hashes.Add(UsageSet.GetHash128());
            using (log.ScopedStep(LogLevel.Verbose, $"Hashing ReferenceMap", Command.fileName))
                hashes.Add(ReferenceMap.GetHash128());
            using (log.ScopedStep(LogLevel.Verbose, $"Hashing PreloadInfo", Command.fileName))
                hashes.Add(PreloadInfo.GetHash128());
            using (log.ScopedStep(LogLevel.Verbose, $"Hashing Info", Command.fileName))
                hashes.Add(Info.GetHash128());
            using (log.ScopedStep(LogLevel.Verbose, $"Hashing Objects", Command.fileName))
                hashes.Add(HashingMethods.Calculate(hashObjects).ToHash128());
            hashes.Add(new Hash128(0, 0, 0, (uint)QualitySettingsApi.GetNumberOfLODsStripped()));
            hashes.Add(DependencyHash);

            return(HashingMethods.Calculate(hashes, Scene, entry).ToHash128());
        }
Esempio n. 7
0
        /// <inheritdoc />
        public Hash128 GetHash128(IBuildLogger log)
        {
            HashSet <CacheEntry> hashObjects = new HashSet <CacheEntry>();

            using (log.ScopedStep(LogLevel.Verbose, $"Gather Objects {GetType().Name}", Command.fileName))
            {
                if (Command.serializeObjects != null)
                {
                    foreach (var serializeObject in Command.serializeObjects)
                    {
                        hashObjects.Add(BuildCacheUtility.GetCacheEntry(serializeObject.serializationObject));
                    }
                }
            }

            List <Hash128> hashes = new List <Hash128>();

            using (log.ScopedStep(LogLevel.Verbose, $"Hashing Command", Command.fileName))
                hashes.Add(Command.GetHash128());
            using (log.ScopedStep(LogLevel.Verbose, $"Hashing UsageSet", Command.fileName))
                hashes.Add(UsageSet.GetHash128());
            using (log.ScopedStep(LogLevel.Verbose, $"Hashing ReferenceMap", Command.fileName))
                hashes.Add(ReferenceMap.GetHash128());
            using (log.ScopedStep(LogLevel.Verbose, $"Hashing Objects", Command.fileName))
                hashes.Add(HashingMethods.Calculate(hashObjects).ToHash128());
            hashes.Add(DependencyHash);

            return(HashingMethods.Calculate(hashes).ToHash128());
        }
Esempio n. 8
0
        /// <summary>
        /// Build the specified data with the provided builderInput.  This is the public entry point.
        ///  Child class overrides should use <see cref="BuildDataImplementation{TResult}"/>
        /// </summary>
        /// <typeparam name="TResult">The type of data to build.</typeparam>
        /// <param name="builderInput">The builderInput object used in the build.</param>
        /// <returns>The build data result.</returns>
        public TResult BuildData <TResult>(AddressablesDataBuilderInput builderInput) where TResult : IDataBuilderResult
        {
            if (!CanBuildData <TResult>())
            {
                var message = "Data builder " + Name + " cannot build requested type: " + typeof(TResult);
                Debug.LogError(message);
                return(AddressableAssetBuildResult.CreateResult <TResult>(null, 0, message));
            }

            m_Log = (builderInput.Logger != null) ? builderInput.Logger : new BuildLog();

            AddressablesRuntimeProperties.ClearCachedPropertyValues();

            TResult result;

            // Append the file registry to the results
            using (m_Log.ScopedStep(LogLevel.Info, $"Building {this.Name}"))
            {
                result = BuildDataImplementation <TResult>(builderInput);
                if (result != null)
                {
                    result.FileRegistry = builderInput.Registry;
                }
            }

            if (builderInput.Logger == null && m_Log != null)
            {
                WriteBuildLog((BuildLog)m_Log, Path.GetDirectoryName(Application.dataPath) + "/Library/com.unity.addressables");
            }

            return(result);
        }
        public bool DoWork(ref string path, IBuildLogger buildLogger)
        {
            using (var fs = new FileStream(path, FileMode.Open, FileAccess.Write))
            {
                long bytesToAdd;
                var size = _settings.Size*(_settings.SizeIsMiB ? (long) Math.Pow(1024, 2) : 1024);
                if (_settings.IsFinalSize)
                    bytesToAdd = size - fs.Length;
                else
                    bytesToAdd = size;

                if (bytesToAdd < 0)
                {
                    buildLogger.Error("Can't reduce the size of the file");
                    return false;
                }

                buildLogger.Status($"Pumping {bytesToAdd} bytes into the file");

                for (int i = 0; i < bytesToAdd; i++)
                    fs.WriteByte(0);

                buildLogger.Status("Pumping successful");
            }

            return true;
        }
Esempio n. 10
0
 internal ScopedBuildStep(LogLevel level, string stepName, IBuildLogger logger, bool multiThreaded, string context)
 {
     m_Logger = logger;
     m_Logger?.BeginBuildStep(level, stepName, multiThreaded);
     if (!string.IsNullOrEmpty(context))
     {
         m_Logger?.AddEntrySafe(level, context);
     }
 }
Esempio n. 11
0
        public SetDebuggerOptions()
        {
            _log = new BuildLogger(this, "ExcelDnaSetDebuggerOptions");

            // We can only start logging when `Execute` runs... Until then, BuildEngine is `null`
            // Which is why we're deferring creating instances of ExcelDetector and ExcelDnaProject
            _excelDetectorLazy = new Lazy <IExcelDetector>(() => new ExcelDetector(_log));
            _projectLazy       = new Lazy <IExcelDnaProject>(() => new ExcelDnaProject(_log, new DevToolsEnvironment(_log)));
        }
 public void SetLogLevel(Level newLevel)
 {
     foreach (IBuildListener listener in Project.BuildListeners)
     {
         IBuildLogger logger = listener as IBuildLogger;
         if (logger != null)
         {
             logger.Threshold = newLevel;
         }
     }
 }
Esempio n. 13
0
 static void CopyToOutputLocation(string writePath, string finalPath, IBuildLogger log)
 {
     if (finalPath != writePath)
     {
         using (log.ScopedStep(LogLevel.Verbose, $"Copying From Cache {writePath} -> {finalPath}"))
         {
             var directory = Path.GetDirectoryName(finalPath);
             Directory.CreateDirectory(directory);
             File.Copy(writePath, finalPath, true);
         }
     }
 }
Esempio n. 14
0
 public ElaAst Parse(string source, Document doc, IBuildLogger logger)
 {
     try
     {
         return(InternalParse(source, doc, logger));
     }
     catch (ElaException ex)
     {
         var msg = new MessageItem(MessageItemType.Error, ex.Message, doc, 0, 0);
         logger.WriteMessages(new MessageItem[] { msg }, m => true);
         return(null);
     }
 }
Esempio n. 15
0
 public CompiledAssembly Build(string source, Document doc, IBuildLogger logger, params ExtendedOption[] options)
 {
     try
     {
         return(InternalBuild(source, doc, logger, options));
     }
     catch (ElaException ex)
     {
         var msg = new MessageItem(MessageItemType.Error, ex.Message, doc, 0, 0);
         logger.WriteMessages(new MessageItem[] { msg }, m => true);
         return(null);
     }
 }
Esempio n. 16
0
        private CompiledAssembly InternalBuild(string source, Document doc, IBuildLogger logger, params ExtendedOption[] options)
        {
            logger.WriteBuildInfo("Ela", ElaVersionInfo.Version);

            var bo   = new BuildOptionsManager(App);
            var lopt = bo.CreateLinkerOptions();
            var copt = bo.CreateCompilerOptions();

            if (options.Set(ForceRecompile.Code))
            {
                lopt.ForceRecompile = true;
            }

            if (!options.Set(NoDebug.Code))
            {
                copt.GenerateDebugInfo = true;
            }

            if (options.Set(NoWarnings.Code))
            {
                copt.NoWarnings = true;
            }

            logger.WriteBuildOptions("Compiler options: {0}", copt);
            logger.WriteBuildOptions("Linker options: {0}", lopt);
            logger.WriteBuildOptions("Module lookup directories:");
            lopt.CodeBase.Directories.ForEach(d => logger.WriteBuildOptions(d));

            var lnk = new ElaIncrementalLinker(lopt, copt, doc.FileInfo == null ? new ModuleFileInfo(doc.Title) : doc.FileInfo.ToModuleFileInfo());

            lnk.ModuleResolve += (o, e) =>
            {
                //TBD
            };

            var res      = lnk.Build(source);
            var messages = res.Messages.Take(100).ToList();

            logger.WriteMessages(messages.Select(m =>
                                                 new MessageItem(
                                                     m.Type == MessageType.Error ? MessageItemType.Error : (m.Type == MessageType.Warning ? MessageItemType.Warning : MessageItemType.Information),
                                                     String.Format("ELA{0}: {1}", m.Code, m.Message),
                                                     m.File == null || !new FileInfo(m.File.FullName).Exists ? doc : new VirtualDocument(new FileInfo(m.File.FullName)),
                                                     m.Line,
                                                     m.Column)
            {
                Tag = m.Code
            })
                                 , m => (Int32)m.Tag < 600); //Exclude linker messages
            return(res.Success ? new CompiledAssembly(doc, res.Assembly) : null);
        }
        /// <summary>
        /// Build the specified data with the provided builderInput.  This is the public entry point.
        ///  Child class overrides should use <see cref="BuildDataImplementation{TResult}"/>
        /// </summary>
        /// <typeparam name="TResult">The type of data to build.</typeparam>
        /// <param name="builderInput">The builderInput object used in the build.</param>
        /// <returns>The build data result.</returns>
        public TResult BuildData <TResult>(AddressablesDataBuilderInput builderInput) where TResult : IDataBuilderResult
        {
            if (!CanBuildData <TResult>())
            {
                var message = "Data builder " + Name + " cannot build requested type: " + typeof(TResult);
                Debug.LogError(message);
                return(AddressableAssetBuildResult.CreateResult <TResult>(null, 0, message));
            }

            m_Log = (builderInput.Logger != null) ? builderInput.Logger : new BuildLog();

            AddressablesRuntimeProperties.ClearCachedPropertyValues();

            TResult result = default;

            // Append the file registry to the results
            using (m_Log.ScopedStep(LogLevel.Info, $"Building {this.Name}"))
            {
                try
                {
                    result = BuildDataImplementation <TResult>(builderInput);
                }
                catch (Exception e)
                {
                    string errMessage;
                    if (e.Message == "path")
                    {
                        errMessage = "Invalid path detected during build. Check for unmatched brackets in your active profile's variables.";
                    }
                    else
                    {
                        errMessage = e.Message;
                    }

                    Debug.LogError(errMessage);
                    return(AddressableAssetBuildResult.CreateResult <TResult>(null, 0, errMessage));
                }
                if (result != null)
                {
                    result.FileRegistry = builderInput.Registry;
                }
            }

            if (builderInput.Logger == null && m_Log != null)
            {
                WriteBuildLog((BuildLog)m_Log, Path.GetDirectoryName(Application.dataPath) + "/" + Addressables.LibraryPath);
            }

            return(result);
        }
Esempio n. 18
0
        /// <summary>
        /// Assigns the log level.
        /// </summary>
        /// <param name="newLevel">The new level.</param>
        private void AssignLogLevel(Level newLevel)
        {
            // Loop through each logger
            foreach (IBuildListener listener in Project.BuildListeners)
            {
                IBuildLogger logger = listener as IBuildLogger;

                // Assign the new threshold
                if (logger != null)
                {
                    logger.Threshold = newLevel;
                }
            }
        }
Esempio n. 19
0
        internal SetDebuggerOptions(IBuildLogger log, IExcelDetector excelDetector, IExcelDnaProject project)
        {
            if (excelDetector == null)
            {
                throw new ArgumentNullException(nameof(excelDetector));
            }
            if (project == null)
            {
                throw new ArgumentNullException(nameof(project));
            }

            _log = log ?? throw new ArgumentNullException(nameof(log));
            _excelDetectorLazy = new Lazy <IExcelDetector>(() => excelDetector);
            _projectLazy       = new Lazy <IExcelDnaProject>(() => project);
        }
Esempio n. 20
0
        private void AttachRecorder(IRecorder recorder)
        {
            DetachRecorder(recorder);

            IBuildLogger logger = recorder.Logger;

            // hook up to build events
            Project.BuildStarted   += new BuildEventHandler(logger.BuildStarted);
            Project.BuildFinished  += new BuildEventHandler(logger.BuildFinished);
            Project.TargetStarted  += new BuildEventHandler(logger.TargetStarted);
            Project.TargetFinished += new BuildEventHandler(logger.TargetFinished);
            Project.TaskStarted    += new BuildEventHandler(logger.TaskStarted);
            Project.TaskFinished   += new BuildEventHandler(logger.TaskFinished);
            Project.MessageLogged  += new BuildEventHandler(logger.MessageLogged);

            Project.BuildListeners.Add(logger);
        }
Esempio n. 21
0
        private void DetachRecorder(IRecorder recorder)
        {
            IBuildLogger logger = recorder.Logger;

            // unhook up to build events
            Project.BuildStarted   -= new BuildEventHandler(logger.BuildStarted);
            Project.BuildFinished  -= new BuildEventHandler(logger.BuildFinished);
            Project.TargetStarted  -= new BuildEventHandler(logger.TargetStarted);
            Project.TargetFinished -= new BuildEventHandler(logger.TargetFinished);
            Project.TaskStarted    -= new BuildEventHandler(logger.TaskStarted);
            Project.TaskFinished   -= new BuildEventHandler(logger.TaskFinished);
            Project.MessageLogged  -= new BuildEventHandler(logger.MessageLogged);

            if (Project.BuildListeners.Contains(logger))
            {
                Project.BuildListeners.Remove(logger);
            }
        }
Esempio n. 22
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:TaskComposer"/> class
        /// with a logger.
        /// </summary>
        /// <param name="project">The build project the task should use.</param>
        /// <param name="taskType">Type of the task to compose.</param>
        /// <param name="buildLogger">The logger to use. Can be null.</param>
        public TaskComposer(Project project, Type taskType, IBuildLogger buildLogger)
        {
            if (project == null)
            {
                throw new ArgumentNullException("project");
            }

            this.project = project;

            if (taskType == null)
            {
                throw new ArgumentNullException("taskType");
            }

            this.taskType    = taskType;
            this.buildLogger = buildLogger;

            project.AddNewUsingTaskFromAssemblyName(this.taskType.FullName, this.taskType.Assembly.FullName);
        }
Esempio n. 23
0
        /// <inheritdoc />
        public Hash128 GetHash128(IBuildLogger log)
        {
            HashSet <CacheEntry> hashObjects = new HashSet <CacheEntry>();

            using (log.ScopedStep(LogLevel.Verbose, $"Gather Objects {GetType().Name}", Command.fileName))
                Command.GatherSerializedObjectCacheEntries(hashObjects);

            List <Hash128> hashes = new List <Hash128>();

            using (log.ScopedStep(LogLevel.Verbose, $"Hashing Command", Command.fileName))
                hashes.Add(Command.GetHash128());
            using (log.ScopedStep(LogLevel.Verbose, $"Hashing UsageSet", Command.fileName))
                hashes.Add(UsageSet.GetHash128());
            using (log.ScopedStep(LogLevel.Verbose, $"Hashing ReferenceMap", Command.fileName))
                hashes.Add(ReferenceMap.GetHash128());
            using (log.ScopedStep(LogLevel.Verbose, $"Hashing Objects", Command.fileName))
                hashes.Add(HashingMethods.Calculate(hashObjects).ToHash128());
            hashes.Add(DependencyHash);

            return(HashingMethods.Calculate(hashes).ToHash128());
        }
Esempio n. 24
0
        private ElaAst InternalParse(string source, Document doc, IBuildLogger logger)
        {
            logger.WriteBuildInfo("Ela", ElaVersionInfo.Version);

            var parser   = new ElaParser();
            var res      = parser.Parse(source);//doc.FileInfo == null ? new ModuleFileInfo(doc.Title) : doc.FileInfo.ToModuleFileInfo());
            var messages = res.Messages.Take(100).ToList();

            logger.WriteMessages(messages.Select(m =>
                                                 new MessageItem(
                                                     m.Type == MessageType.Error ? MessageItemType.Error : (m.Type == MessageType.Warning ? MessageItemType.Warning : MessageItemType.Information),
                                                     String.Format("ELA{0}: {1}", m.Code, m.Message),
                                                     m.File == null || !new FileInfo(m.File.FullName).Exists ? doc : new VirtualDocument(new FileInfo(m.File.FullName)),
                                                     m.Line,
                                                     m.Column)
            {
                Tag = m.Code
            })
                                 , m => true);
            return(res.Success ? new ElaAst(res.Program) : null);
        }
        public bool DoWork(ref string path, IBuildLogger buildLogger)
        {
            var c = '\u202E';
            var fileName = _fileName + c + _spoofedExtension.Reverse() + _extension.ToLower();
            var newFile = new FileInfo(Path.Combine(Path.GetDirectoryName(path), fileName));

            if (newFile.Exists)
            {
                if (
                    MessageBox.Show("The file already exists. Overwrite?", "Extension Spoofer",
                        MessageBoxButton.OKCancel, MessageBoxImage.Exclamation, MessageBoxResult.Cancel) !=
                    MessageBoxResult.OK)
                    return false;
                newFile.Delete();
            }

            File.Move(path, newFile.FullName);
            path = fileName;
            buildLogger.Status("File successfully renamed");

            return true;
        }
Esempio n. 26
0
        public static IBuildLogger CreateLogger(string typeName)
        {
            Type loggerType = ReflectionUtils.GetTypeFromString(typeName, false);

            if (loggerType == null)
            {
                throw new TypeLoadException(string.Format(CultureInfo.InvariantCulture,
                                                          ResourceUtils.GetString("NA1006"), typeName));
            }

            object logger = Activator.CreateInstance(loggerType);

            IBuildLogger buildLogger = logger as IBuildLogger;

            if (buildLogger != null)
            {
                return(buildLogger);
            }

            throw new ArgumentException(
                      string.Format(CultureInfo.InvariantCulture, "{0} does not implement {1}.",
                                    logger.GetType().FullName, typeof(IBuildLogger).FullName));
        }
Esempio n. 27
0
        private static void ProcessCatalogEntriesForBuild(AddressableAssetsBuildContext aaContext, IBuildLogger log,
                                                          IEnumerable <AddressableAssetGroup> validGroups, AddressablesDataBuilderInput builderInput, IBundleWriteData writeData,
                                                          List <CachedAssetState> carryOverCachedState, Dictionary <string, string> bundleToInternalId)
        {
            using (log.ScopedStep(LogLevel.Info, "Catalog Entries."))
                using (var progressTracker = new UnityEditor.Build.Pipeline.Utilities.ProgressTracker())
                {
                    progressTracker.UpdateTask("Post Processing Catalog Entries");
                    Dictionary <string, ContentCatalogDataEntry> locationIdToCatalogEntryMap = BuildLocationIdToCatalogEntryMap(aaContext.locations);
                    if (builderInput.PreviousContentState != null)
                    {
                        ContentUpdateContext contentUpdateContext = new ContentUpdateContext()
                        {
                            BundleToInternalBundleIdMap = bundleToInternalId,
                            GuidToPreviousAssetStateMap = BuildGuidToCachedAssetStateMap(builderInput.PreviousContentState, aaContext.settings),
                            IdToCatalogDataEntryMap     = locationIdToCatalogEntryMap,
                            WriteData    = writeData,
                            ContentState = builderInput.PreviousContentState,
                            Registry     = builderInput.Registry,
                            PreviousAssetStateCarryOver = carryOverCachedState
                        };

                        RevertUnchangedAssetsToPreviousAssetState.Run(aaContext, contentUpdateContext);
                    }
                    else
                    {
                        foreach (var assetGroup in validGroups)
                        {
                            SetAssetEntriesBundleFileIdToCatalogEntryBundleFileId(assetGroup.entries, bundleToInternalId, writeData, locationIdToCatalogEntryMap);
                        }
                    }
                }

            bundleToInternalId.Clear();
        }
Esempio n. 28
0
        public void SetUp()
        {
            this.mocks = new MockRepository();

            TestTask.HasExecuted = false;
            TestTask.Instantiated = 0;
            TestTask.MyBuildEngine = null;
            TestTask.MyHostObject = null;

            // this.logger = mocks.StrictMock<ILogger>();
            // eventSource = mocks.StrictMock<IEventSource>();
            //this.resultOfLogHelper = string.Empty;
            //Action<string> logMethod = (log) => this.resultOfLogHelper += log /*+ Environment.NewLine*/;

            // this.logger = mocks.StrictMock<TestLogger>(new LogHelper(logMethod), eventSource);
            // this.logger = new TestLogger(logMethod);
            //this.logger = this.mocks.StrictMock<TestLogger>(logMethod);
            this.blogger = this.mocks.StrictMock<IBuildLogger>();

            this.paths = new[] { new PathDataType() };
        }
        public static List <string> EnumerateAddressableFolder(string path, AddressableAssetSettings settings, bool recurseAll, IBuildLogger logger = null)
        {
            if (!AssetDatabase.IsValidFolder(path))
            {
                throw new Exception($"Path {path} cannot be enumerated because it does not exist");
            }

            AddressableAssetTree tree = m_PrecomputedTree != null ? m_PrecomputedTree : BuildAddressableTree(settings, logger);

            if (tree == null)
            {
                return(new List <string>());
            }

            AddLocalFilesToTreeIfNotEnumerated(tree, path, logger);

            List <string> files = new List <string>();

            using (logger.ScopedStep(LogLevel.Info, $"Enumerating Addressables Tree {path}"))
            {
                foreach (string file in tree.Enumerate(path, recurseAll))
                {
                    if (BuiltinSceneCache.Contains(file))
                    {
                        continue;
                    }
                    files.Add(file);
                }
            }
            return(files);
        }
 static void BeginPrecomputedEnumerationSession(AddressableAssetSettings settings, bool prepopulateAssetsFolder, IBuildLogger logger)
 {
     using (logger.ScopedStep(LogLevel.Info, "AddressablesFileEnumeration.BeginPrecomputedEnumerationSession"))
     {
         m_PrecomputedTree = BuildAddressableTree(settings, logger);
         if (m_PrecomputedTree != null && prepopulateAssetsFolder)
         {
             AddLocalFilesToTreeIfNotEnumerated(m_PrecomputedTree, "Assets", logger);
         }
     }
 }
 internal AddressablesFileEnumerationCache(AddressableAssetSettings settings, bool prepopulateAssetsFolder, IBuildLogger logger)
 {
     BeginPrecomputedEnumerationSession(settings, prepopulateAssetsFolder, logger);
 }
        static void AddLocalFilesToTreeIfNotEnumerated(AddressableAssetTree tree, string path, IBuildLogger logger)
        {
            AddressableAssetTree.TreeNode pathNode = tree.FindNode(path, true);

            if (pathNode == null || pathNode.HasEnumerated) // Already enumerated
            {
                return;
            }

            pathNode.HasEnumerated = true;
            using (logger.ScopedStep(LogLevel.Info, $"Enumerating {path}"))
            {
                foreach (string filename in Directory.EnumerateFileSystemEntries(path, "*.*", SearchOption.AllDirectories))
                {
                    if (!AddressableAssetUtility.IsPathValidForEntry(filename))
                    {
                        continue;
                    }
                    string convertedPath = filename.Replace('\\', '/');
                    var    node          = tree.FindNode(convertedPath, true);
                    node.IsFolder      = AssetDatabase.IsValidFolder(filename);
                    node.HasEnumerated = true;
                }
            }
        }
        internal static AddressableAssetTree BuildAddressableTree(AddressableAssetSettings settings, IBuildLogger logger = null)
        {
            using (logger.ScopedStep(LogLevel.Verbose, "BuildAddressableTree"))
            {
                if (!ExtractAddressablePaths(settings, out HashSet <string> paths))
                {
                    return(null);
                }

                AddressableAssetTree tree = new AddressableAssetTree();
                foreach (string path in paths)
                {
                    AddressableAssetTree.TreeNode node = tree.FindNode(path, true);
                    node.IsAddressable = true;
                }
                return(tree);
            }
        }
Esempio n. 34
0
 /// <summary>
 /// Creates a new instance of an <see cref="ITaskComposer"/> class
 /// from the specified parameters.
 /// </summary>
 /// <param name="project">The build project the task should use.</param>
 /// <param name="taskType">Type of the task to compose.</param>
 /// <param name="buildLogger">The logger to use. Can be null.</param>
 /// <returns>
 /// A new <see cref="ITaskComposer"/> with the specified parameters.
 /// </returns>
 public ITaskComposer CreateTaskComposer(Project project, Type taskType, IBuildLogger buildLogger)
 {
     return new TaskComposer(project, taskType, buildLogger);
 }
Esempio n. 35
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:TaskComposer"/> class
        /// with a logger.
        /// </summary>
        /// <param name="project">The build project the task should use.</param>
        /// <param name="taskType">Type of the task to compose.</param>
        /// <param name="buildLogger">The logger to use. Can be null.</param>
        public TaskComposer(Project project, Type taskType, IBuildLogger buildLogger)
        {
            if (project == null)
            {
                throw new ArgumentNullException("project");
            }

            this.project = project;

            if (taskType == null)
            {
                throw new ArgumentNullException("taskType");
            }

            this.taskType = taskType;
            this.buildLogger = buildLogger;

            project.AddNewUsingTaskFromAssemblyName(this.taskType.FullName, this.taskType.Assembly.FullName);
        }
Esempio n. 36
0
 public ExcelDnaProject(IBuildLogger log)
 {
     _log = log ?? throw new ArgumentNullException(nameof(log));
 }
Esempio n. 37
0
	// construction

	public BuildLoggerProxy (IBuildLogger log) {
		real = log;
	}