Ejemplo n.º 1
0
 private bool GetCanVersionIncremental(IncrementalStatus buildInfoIncrementalStatus)
 {
     if (!buildInfoIncrementalStatus.CanIncremental)
     {
         IncrementalInfo.ReportStatus(false, IncrementalPhase.Build, buildInfoIncrementalStatus.Details);
         Logger.LogVerbose(buildInfoIncrementalStatus.Details);
         return(false);
     }
     if (LastBuildVersionInfo == null)
     {
         string message = $"Cannot build incrementally because last build didn't contain version {Version}.";
         IncrementalInfo.ReportStatus(false, IncrementalPhase.Build, message);
         Logger.LogVerbose(message);
         return(false);
     }
     if (CurrentBuildVersionInfo.ConfigHash != LastBuildVersionInfo.ConfigHash)
     {
         string message = "Cannot build incrementally because config changed.";
         IncrementalInfo.ReportStatus(false, IncrementalPhase.Build, message);
         Logger.LogVerbose(message);
         return(false);
     }
     if (_parameters.ForceRebuild)
     {
         string message = $"Disable incremental build by force rebuild option.";
         IncrementalInfo.ReportStatus(false, IncrementalPhase.Build, message);
         Logger.LogVerbose(message);
         return(false);
     }
     IncrementalInfo.ReportStatus(true, IncrementalPhase.Build);
     return(true);
 }
Ejemplo n.º 2
0
        public bool CanProcessorIncremental(IDocumentProcessor processor)
        {
            if (!CanVersionIncremental)
            {
                IncrementalInfo.ReportProcessorStatus(processor.Name, false);
                return(false);
            }

            var cpi = CurrentBuildVersionInfo.Processors.Find(p => p.Name == processor.Name);

            if (cpi == null)
            {
                string message = $"Current BuildVersionInfo missed processor info for {processor.Name}.";
                IncrementalInfo.ReportProcessorStatus(processor.Name, false, message);
                Logger.LogWarning(message);
                return(false);
            }
            var lpi = LastBuildVersionInfo.Processors.Find(p => p.Name == processor.Name);

            if (lpi == null)
            {
                string message = $"Processor {processor.Name} disable incremental build because last build doesn't contain version {Version}.";
                IncrementalInfo.ReportProcessorStatus(processor.Name, false, message);
                Logger.LogVerbose(message);
                return(false);
            }
            if (cpi.IncrementalContextHash != lpi.IncrementalContextHash)
            {
                string message = $"Processor {processor.Name} disable incremental build because incremental context hash changed.";
                IncrementalInfo.ReportProcessorStatus(processor.Name, false, message);
                Logger.LogVerbose(message);
                return(false);
            }
            if (cpi.Steps.Count != lpi.Steps.Count)
            {
                string message = $"Processor {processor.Name} disable incremental build because steps count is different.";
                IncrementalInfo.ReportProcessorStatus(processor.Name, false, message);
                Logger.LogVerbose(message);
                return(false);
            }
            for (int i = 0; i < cpi.Steps.Count; i++)
            {
                if (!object.Equals(cpi.Steps[i], lpi.Steps[i]))
                {
                    string message = $"Processor {processor.Name} disable incremental build because steps changed, from step {lpi.Steps[i].ToJsonString()} to {cpi.Steps[i].ToJsonString()}.";
                    IncrementalInfo.ReportProcessorStatus(processor.Name, false, message);
                    Logger.LogVerbose(message);
                    return(false);
                }
            }
            IncrementalInfo.ReportProcessorStatus(processor.Name, true);
            Logger.LogVerbose($"Processor {processor.Name} enable incremental build.");
            return(true);
        }
Ejemplo n.º 3
0
 private IncrementalBuildContext(string baseDir, string lastBaseDir, DateTime?lastBuildStartTime, IncrementalStatus buildInfoIncrementalStatus, DocumentBuildParameters parameters, BuildVersionInfo cbv, BuildVersionInfo lbv)
 {
     _parameters             = parameters;
     BaseDir                 = baseDir;
     LastBaseDir             = lastBaseDir;
     LastBuildStartTime      = lastBuildStartTime;
     CurrentBuildVersionInfo = cbv;
     LastBuildVersionInfo    = lbv;
     IncrementalInfo         = new IncrementalInfo();
     CanVersionIncremental   = GetCanVersionIncremental(buildInfoIncrementalStatus);
 }
Ejemplo n.º 4
0
        private bool GetCanVersionIncremental(IncrementalStatus buildInfoIncrementalStatus)
        {
            bool   canIncremental;
            string details;
            string fullBuildReasonCode;

            if (!buildInfoIncrementalStatus.CanIncremental)
            {
                details             = buildInfoIncrementalStatus.Details;
                fullBuildReasonCode = buildInfoIncrementalStatus.FullBuildReasonCode;
                canIncremental      = false;
            }
            else if (LastBuildVersionInfo == null)
            {
                details             = $"Cannot build incrementally because last build didn't contain group {Version}.";
                fullBuildReasonCode = InfoCodes.FullBuildReason.NoAvailableGroupCache;
                canIncremental      = false;
            }
            else if (CurrentBuildVersionInfo.ConfigHash != LastBuildVersionInfo.ConfigHash)
            {
                details             = "Cannot build incrementally because config changed.";
                fullBuildReasonCode = InfoCodes.FullBuildReason.ConfigChanged;
                canIncremental      = false;
            }
            else if (_parameters.ForceRebuild)
            {
                details             = "Disable incremental build by force rebuild option.";
                fullBuildReasonCode = InfoCodes.FullBuildReason.ForceRebuild;
                canIncremental      = false;
            }
            else
            {
                details             = null;
                canIncremental      = true;
                fullBuildReasonCode = null;
            }

            var buildStrategy = canIncremental ? InfoCodes.Build.IsIncrementalBuild : InfoCodes.Build.IsFullBuild;

            if (canIncremental)
            {
                IncrementalInfo.ReportStatus(true, IncrementalPhase.Build);
                Logger.LogInfo($"Group {Version} will be built incrementally.", code: buildStrategy);
            }
            else
            {
                IncrementalInfo.ReportStatus(false, IncrementalPhase.Build, details, fullBuildReasonCode);
                Logger.LogInfo($"Group {Version} will be built fully.", code: buildStrategy);
                Logger.LogInfo($"The reason of full building under group {Version} is: {details}", code: fullBuildReasonCode);
            }

            return(canIncremental);
        }
        private bool GetIsIncremental()
        {
            const string prependWarning = "Cannot support incremental post processing, the reason is:";
            string       message;

            if (!ShouldTraceIncrementalInfo)
            {
                message = $"{prependWarning} should not trace intermediate info.";
                IncrementalInfo.ReportStatus(false, IncrementalPhase.PostProcessing, message);
                Logger.LogVerbose(message);
                return(false);
            }
            if (!EnableIncremental)
            {
                message = $"{prependWarning} it's disabled.";
                IncrementalInfo.ReportStatus(false, IncrementalPhase.PostProcessing, message);
                Logger.LogVerbose(message);
                return(false);
            }
            if (LastInfo == null)
            {
                message = $"{prependWarning} last post processor info is null.";
                IncrementalInfo.ReportStatus(false, IncrementalPhase.PostProcessing, message);
                Logger.LogVerbose(message);
                return(false);
            }
            if (CurrentInfo.PostProcessorInfos.Count != LastInfo.PostProcessorInfos.Count)
            {
                message = $"{prependWarning} post processor info count mismatch: last has {LastInfo.PostProcessorInfos.Count} while current has {CurrentInfo.PostProcessorInfos.Count}.";
                IncrementalInfo.ReportStatus(false, IncrementalPhase.PostProcessing, message);
                Logger.LogVerbose(message);
                return(false);
            }
            for (var i = 0; i < CurrentInfo.PostProcessorInfos.Count; i++)
            {
                var currentPostProcessorInfo = CurrentInfo.PostProcessorInfos[i];
                var lastPostProcessorInfo    = LastInfo.PostProcessorInfos[i];
                if (!currentPostProcessorInfo.Equals(lastPostProcessorInfo))
                {
                    message = $"{prependWarning} post processor info changed from last {lastPostProcessorInfo.ToJsonString()} to current {currentPostProcessorInfo.ToJsonString()}.";
                    IncrementalInfo.ReportStatus(false, IncrementalPhase.PostProcessing, message);
                    Logger.LogVerbose(message);
                    return(false);
                }
            }

            message = "Can support incremental post processing.";
            IncrementalInfo.ReportStatus(true, IncrementalPhase.PostProcessing, message);
            Logger.LogVerbose(message);
            return(true);
        }
        private bool GetCanVersionIncremental(IncrementalStatus buildInfoIncrementalStatus)
        {
            bool   canIncremental;
            string details;
            string fullBuildReasonCode;

            if (!buildInfoIncrementalStatus.CanIncremental)
            {
                details             = buildInfoIncrementalStatus.Details;
                fullBuildReasonCode = buildInfoIncrementalStatus.FullBuildReasonCode;
                canIncremental      = false;
            }
            else if (LastBuildVersionInfo == null)
            {
                details             = $"Cannot build incrementally because last build didn't contain group {Version}.";
                fullBuildReasonCode = InfoCodes.FullBuildReason.NoAvailableGroupCache;
                canIncremental      = false;
            }
            else if (CurrentBuildVersionInfo.ConfigHash != LastBuildVersionInfo.ConfigHash)
            {
                details             = "Cannot build incrementally because config changed.";
                fullBuildReasonCode = InfoCodes.FullBuildReason.ConfigChanged;
                canIncremental      = false;
            }
            else
            {
                details             = null;
                canIncremental      = true;
                fullBuildReasonCode = null;
            }

            var buildStrategy    = canIncremental ? InfoCodes.Build.IsIncrementalBuild : InfoCodes.Build.IsFullBuild;
            var groupDisplayName = string.IsNullOrEmpty(Version) ? "the default group" : $"group '{Version}'";

            if (canIncremental)
            {
                IncrementalInfo.ReportStatus(true, IncrementalPhase.Build);
                Logger.LogVerbose($"Building {groupDisplayName} incrementally.", code: buildStrategy);
            }
            else
            {
                IncrementalInfo.ReportStatus(false, IncrementalPhase.Build, details, fullBuildReasonCode);
                Logger.LogVerbose($"Building {groupDisplayName} fully.", code: buildStrategy);
                Logger.LogVerbose($"The reason of full building for {groupDisplayName} is: {details}", code: fullBuildReasonCode);
            }

            return(canIncremental);
        }
Ejemplo n.º 7
0
        private bool GetCanVersionIncremental(IncrementalStatus buildInfoIncrementalStatus)
        {
            bool   canIncremental;
            string message;

            if (!buildInfoIncrementalStatus.CanIncremental)
            {
                message        = buildInfoIncrementalStatus.Details;
                canIncremental = false;
            }
            else if (LastBuildVersionInfo == null)
            {
                message        = $"Cannot build incrementally because last build didn't contain group {Version}.";
                canIncremental = false;
            }
            else if (CurrentBuildVersionInfo.ConfigHash != LastBuildVersionInfo.ConfigHash)
            {
                message        = "Cannot build incrementally because config changed.";
                canIncremental = false;
            }
            else if (_parameters.ForceRebuild)
            {
                message        = "Disable incremental build by force rebuild option.";
                canIncremental = false;
            }
            else
            {
                message        = null;
                canIncremental = true;
            }

            var buildStrategy = canIncremental ? InfoCodes.Build.IsIncrementalBuild : InfoCodes.Build.IsFullBuild;

            if (canIncremental)
            {
                IncrementalInfo.ReportStatus(true, IncrementalPhase.Build);
                Logger.LogInfo($"Group: {Version}, build strategy: {buildStrategy}", code: buildStrategy);
            }
            else
            {
                IncrementalInfo.ReportStatus(false, IncrementalPhase.Build, message);
                Logger.LogInfo($"Group: {Version}, build strategy: {buildStrategy}, details: {message}", code: buildStrategy);
            }

            return(canIncremental);
        }
Ejemplo n.º 8
0
 public bool ShouldProcessorTraceInfo(IDocumentProcessor processor)
 {
     if (!(processor is ISupportIncrementalDocumentProcessor))
     {
         string message = $"Processor {processor.Name} cannot suppport incremental build because the processor doesn't implement {nameof(ISupportIncrementalDocumentProcessor)} interface.";
         IncrementalInfo.ReportProcessorStatus(processor.Name, false, message);
         Logger.LogVerbose(message);
         return(false);
     }
     if (!processor.BuildSteps.All(step => step is ISupportIncrementalBuildStep))
     {
         string message = $"Processor {processor.Name} cannot suppport incremental build because the following steps don't implement {nameof(ISupportIncrementalBuildStep)} interface: {string.Join(",", processor.BuildSteps.Where(step => !(step is ISupportIncrementalBuildStep)).Select(s => s.Name))}.";
         IncrementalInfo.ReportProcessorStatus(processor.Name, false, message);
         Logger.LogVerbose(message);
         return(false);
     }
     return(true);
 }
Ejemplo n.º 9
0
 private bool GetCanVersionIncremental(IncrementalStatus buildInfoIncrementalStatus)
 {
     if (!buildInfoIncrementalStatus.CanIncremental)
     {
         IncrementalInfo.ReportStatus(false, IncrementalPhase.Build, buildInfoIncrementalStatus.Details);
         Logger.LogVerbose(buildInfoIncrementalStatus.Details);
         return(false);
     }
     if (LastBuildVersionInfo == null)
     {
         string message = $"Cannot build incrementally because last build didn't contain version {Version}.";
         IncrementalInfo.ReportStatus(false, IncrementalPhase.Build, message);
         Logger.LogVerbose(message);
         return(false);
     }
     if (CurrentBuildVersionInfo.ConfigHash != LastBuildVersionInfo.ConfigHash)
     {
         string message = "Cannot build incrementally because config changed.";
         IncrementalInfo.ReportStatus(false, IncrementalPhase.Build, message);
         Logger.LogVerbose(message);
         return(false);
     }
     if (_parameters.ForceRebuild)
     {
         string message = $"Disable incremental build by force rebuild option.";
         IncrementalInfo.ReportStatus(false, IncrementalPhase.Build, message);
         Logger.LogVerbose(message);
         return(false);
     }
     if (_parameters.ApplyTemplateSettings != null)
     {
         var options = _parameters.ApplyTemplateSettings.Options;
         if ((options & (ApplyTemplateOptions.ExportRawModel | ApplyTemplateOptions.ExportViewModel)) != ApplyTemplateOptions.None)
         {
             string message = $"Disable incremental build because ExportRawModel/ExportViewModel option enabled.";
             IncrementalInfo.ReportStatus(false, IncrementalPhase.Build, message);
             Logger.LogVerbose(message);
             return(false);
         }
     }
     IncrementalInfo.ReportStatus(true, IncrementalPhase.Build);
     return(true);
 }