Пример #1
0
        private void CookBundles(IEnumerable <string> bundles, bool requiredCookCode = true)
        {
            LogText = "";
            var allTimer = StartBenchmark(
                $"Asset cooking. Asset cache mode: {AssetCache.Instance.Mode}. Active platform: {Target.Platform}" +
                System.Environment.NewLine +
                DateTime.Now +
                System.Environment.NewLine
                );

            PluginLoader.BeforeBundlesCooking();

            bool skipCodeCooking = The.Workspace.ProjectJson.GetValue <bool>("SkipCodeCooking");

            if (skipCodeCooking)
            {
                requiredCookCode = false;
            }

            try {
                UserInterface.Instance.SetupProgressBar(CalculateAssetCount(bundles));
                BeginCookBundles?.Invoke();

                foreach (var bundle in bundles)
                {
                    var extraTimer = StartBenchmark();
                    CookBundle(bundle);
                    StopBenchmark(extraTimer, $"{bundle} cooked: ");
                }

                var extraBundles = bundles.ToList();
                extraBundles.Remove(CookingRulesBuilder.MainBundleName);
                extraBundles.Reverse();
                PluginLoader.AfterBundlesCooked(extraBundles);
                if (requiredCookCode)
                {
                    CodeCooker.Cook(Target, CookingRulesMap, bundles.ToList());
                }
                StopBenchmark(allTimer, "All bundles cooked: ");
                PrintBenchmark();
            } catch (OperationCanceledException e) {
                Console.WriteLine(e.Message);
                RestoreBackups();
            } finally {
                cookCanceled = false;
                RemoveBackups();
                EndCookBundles?.Invoke();
                UserInterface.Instance.StopProgressBar();
            }
        }
Пример #2
0
        public void Cook(List <string> bundles)
        {
            AssetCache.Instance.Initialize();
            CookingRulesMap = CookingRulesBuilder.Build(InputBundle, Target);
            LogText         = "";
            var allTimer = StartBenchmark(
                $"Asset cooking. Asset cache mode: {AssetCache.Instance.Mode}. Active platform: {Target.Platform}" +
                System.Environment.NewLine +
                DateTime.Now +
                System.Environment.NewLine
                );

            PluginLoader.BeforeBundlesCooking();
            var requiredCookCode = !The.Workspace.ProjectJson.GetValue <bool>("SkipCodeCooking");
            var bundleBackups    = new List <string>();

            try {
                UserInterface.Instance.SetupProgressBar(CalculateOperationCount(bundles));
                BeginCookBundles?.Invoke();
                var assetsGroupedByBundles = GetAssetsGroupedByBundles(InputBundle.EnumerateFileInfos(), bundles);
                for (int i = 0; i < bundles.Count; i++)
                {
                    var extraTimer = StartBenchmark();
                    CookBundle(bundles[i], assetsGroupedByBundles[i], bundleBackups);
                    StopBenchmark(extraTimer, $"{bundles[i]} cooked: ");
                }
                var extraBundles = bundles.ToList();
                extraBundles.Remove(CookingRulesBuilder.MainBundleName);
                extraBundles.Reverse();
                PluginLoader.AfterBundlesCooked(extraBundles);
                if (requiredCookCode)
                {
                    CodeCooker.Cook(Target, CookingRulesMap, bundles.ToList());
                }
                StopBenchmark(allTimer, "All bundles cooked: ");
                PrintBenchmark();
            } catch (System.Exception e) {
                Console.WriteLine(e.Message);
                RestoreBackups(bundleBackups);
            } finally {
                cookCanceled = false;
                RemoveBackups(bundleBackups);
                EndCookBundles?.Invoke();
                UserInterface.Instance.StopProgressBar();
            }
        }
Пример #3
0
        private static void CookBundles(bool requiredCookCode = true)
        {
            var extraBundles = new HashSet <string>();

            foreach (var dictionaryItem in cookingRulesMap)
            {
                foreach (var bundle in dictionaryItem.Value.Bundles)
                {
                    if (bundle != CookingRulesBuilder.MainBundleName)
                    {
                        extraBundles.Add(bundle);
                    }
                }
            }

            try {
                BeginCookBundles?.Invoke();

                CookBundle(CookingRulesBuilder.MainBundleName);
                foreach (var extraBundle in extraBundles)
                {
                    CookBundle(extraBundle);
                }
                extraBundles.Add(CookingRulesBuilder.MainBundleName);

                var extraBundlesList = extraBundles.ToList();
                PluginLoader.AfterBundlesCooked(extraBundlesList);
                if (requiredCookCode)
                {
                    CodeCooker.Cook(extraBundlesList);
                }
            } catch (OperationCanceledException e) {
                Console.WriteLine(e.Message);
                RestoreBackups();
            } finally {
                cookCanceled = false;
                RemoveBackups();
                EndCookBundles?.Invoke();
            }
        }