Example #1
0
        /// <summary>
        /// Run the distribution as an async task,
        /// since async tasks can't survive domain reloads,
        /// this method cannot build and will error if any builds are missing.
        /// </summary>
        public async Task DistributeWithoutBuilding(TaskToken task = default)
        {
            var removeProgressTask = false;

            if (task.taskId == 0)
            {
                // Set up default cancelable progress task if none is given
                removeProgressTask = true;

                task.taskId = Progress.Start(name);

                var source = new CancellationTokenSource();
                task.cancellation = source.Token;

                Progress.RegisterCancelCallback(task.taskId, () => {
                    source.Cancel();
                    return(true);
                });
            }

            try {
                // Prevent domain reloads from stopping the distribution
                EditorApplication.LockReloadAssemblies();

                // Check that all builds are present
                var paths = GetBuildPaths();
                if (!paths.Any())
                {
                    throw new Exception(name + ": Distribution has no targets in any of its profiles");
                }

                var missingBuilds = false;
                foreach (var path in paths)
                {
                    if (path.path == null)
                    {
                        Debug.LogError(name + ": Missing build for target '" + path.target + "' of profile '" + path.profile + "'");
                        missingBuilds = true;
                    }
                }
                if (missingBuilds)
                {
                    throw new Exception($"{name}: Missing builds");
                }

                // Run distribution
                await RunDistribute(paths, task);
            } finally {
                EditorApplication.UnlockReloadAssemblies();

                if (removeProgressTask)
                {
                    task.Remove();
                }
            }
        }
Example #2
0
        void Complete(bool success)
        {
            //Debug.Log($"Trimmer BuildRunner: Complete! success = {success}");

            var results = this.results;

            this.jobs     = null;
            this.results  = null;
            this.jobIndex = -1;
            this.restoreActiveTargetTo = 0;
            Current = null;

            token.Remove();

            if (Listener != null && Listener is IBuildsCompleteListener l)
            {
                Listener = null;
                l.OnComplete(success, results);
            }

            DestroyImmediate(this);
        }