Esempio n. 1
0
        /// <summary>
        /// Queues and builds multiple builds. For builds requiring explicit active Editor build target, this function also switches Editor build target before starting the build.
        /// That's why there's no return result here, because the build won't be executed immediately in some cases
        /// </summary>
        internal static void BuildAsync(BuildBatchDescription buildBatchDescription)
        {
            var buildEntities = buildBatchDescription.BuildItems;
            // ToDo: when running multiple builds, should we stop at first failure?
            var buildPipelineResults = new BuildPipelineResult[buildEntities.Length];

            for (int i = 0; i < buildEntities.Length; i++)
            {
                var settings = buildEntities[i].BuildSettings;
                var pipeline = settings.GetBuildPipeline();
                if (!settings.CanBuild(out var reason))
                {
                    buildPipelineResults[i] = BuildPipelineResult.Failure(pipeline, settings, reason);
                }
                else
                {
                    buildPipelineResults[i] = null;
                }
            }


            var queue = BuildQueue.instance;

            for (int i = 0; i < buildEntities.Length; i++)
            {
                var settings = buildEntities[i].BuildSettings;
                var pipeline = settings.GetBuildPipeline();
                queue.QueueBuild(settings, buildPipelineResults[i]);
            }

            queue.FlushBuilds(buildBatchDescription.OnBuildCompleted);
        }
Esempio n. 2
0
        public void QueueBuild(BuildSettings buildSettings, BuildPipelineResult buildPipelineResult)
        {
            if (m_PrepareQueueBuilds == null)
            {
                m_PrepareQueueBuilds = new List <QueuedBuild>();
            }

            if (buildSettings == null)
            {
                throw new ArgumentNullException(nameof(buildSettings));
            }
            var b = new QueuedBuild();

            b.requiredActiveTarget = GetRequiredEditorTarget(buildSettings);
            b.buildSettingsGuid    = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(buildSettings));

            if (m_QueueBuilds.Count > 0)
            {
                buildPipelineResult = BuildPipelineResult.Failure(buildSettings.GetBuildPipeline(), buildSettings, "Can't queue builds while executing build.");
            }

            // If the build failed in previous step, don't execute it
            if (buildPipelineResult != null && buildPipelineResult.Failed)
            {
                b.buildFinished = true;
            }
            else
            {
                b.buildFinished = false;
            }

            b.buildPipelineResult = buildPipelineResult != null?JsonSerialization.Serialize(buildPipelineResult) : string.Empty;

            m_PrepareQueueBuilds.Add(b);
        }
Esempio n. 3
0
        /// <summary>
        /// Run the <see cref="BuildPipeline"/> of this <see cref="BuildConfiguration"/> to build the target.
        /// </summary>
        /// <returns>The result of the <see cref="BuildPipeline"/> build.</returns>
        public BuildPipelineResult Build()
        {
            var pipeline = GetBuildPipeline();

            if (!CanBuild(out var reason))
            {
                return(BuildPipelineResult.Failure(pipeline, this, reason));
            }

            var what = !string.IsNullOrEmpty(name) ? $" {name}" : string.Empty;

            using (var progress = new BuildProgress($"Building{what}", "Please wait..."))
            {
                return(pipeline.Build(this, progress));
            }
        }
        public void LogResult_SupportFormattingCharacters()
        {
            var pipeline = BuildPipeline.CreateInstance();
            var config   = BuildConfiguration.CreateInstance();

            var resultSuccess = BuildPipelineResult.Success(pipeline, config);

            Assert.DoesNotThrow(() =>
            {
                LogAssert.Expect(LogType.Log, new Regex(@"Build succeeded after .+\."));
                resultSuccess.LogResult();
            });

            var resultFailure = BuildPipelineResult.Failure(pipeline, config, @"{}{{}}{0}{s}%s%%\s±@£¢¤¬¦²³¼½¾");

            Assert.DoesNotThrow(() =>
            {
                LogAssert.Expect(LogType.Error, new Regex(@"Build failed after .+\.\n.+"));
                resultFailure.LogResult();
            });
        }