Пример #1
0
        public static IncrementalBuildContext Create(DocumentBuildParameters parameters, BuildInfo cb, BuildInfo lb, string intermediateFolder, string markdownServiceContextHash)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }
            if (cb == null)
            {
                throw new ArgumentNullException(nameof(cb));
            }
            if (intermediateFolder == null)
            {
                throw new ArgumentNullException(nameof(intermediateFolder));
            }
            var baseDir     = Path.Combine(intermediateFolder, cb.DirectoryName);
            var lastBaseDir = lb != null?Path.Combine(intermediateFolder, lb.DirectoryName) : null;

            var lastBuildStartTime      = lb?.BuildStartTime;
            var canBuildInfoIncremental = CanBuildInfoIncremental(cb, lb);
            var lbv = lb?.Versions?.SingleOrDefault(v => v.VersionName == parameters.VersionName);
            var cbv = new BuildVersionInfo
            {
                VersionName      = parameters.VersionName,
                ConfigHash       = ComputeConfigHash(parameters, markdownServiceContextHash),
                AttributesFile   = IncrementalUtility.CreateRandomFileName(baseDir),
                DependencyFile   = IncrementalUtility.CreateRandomFileName(baseDir),
                ManifestFile     = IncrementalUtility.CreateRandomFileName(baseDir),
                OutputFile       = IncrementalUtility.CreateRandomFileName(baseDir),
                XRefSpecMapFile  = IncrementalUtility.CreateRandomFileName(baseDir),
                FileMapFile      = IncrementalUtility.CreateRandomFileName(baseDir),
                BuildMessageFile = IncrementalUtility.CreateRandomFileName(baseDir),
                Attributes       = ComputeFileAttributes(parameters, lbv?.Dependency),
                Dependency       = ConstructDependencyGraphFromLast(lbv?.Dependency),
            };

            cb.Versions.Add(cbv);
            var context = new IncrementalBuildContext(baseDir, lastBaseDir, lastBuildStartTime, canBuildInfoIncremental, parameters, cbv, lbv);

            context.InitChanges();
            return(context);
        }
Пример #2
0
        public static IncrementalBuildContext Create(DocumentBuildParameters parameters, BuildInfo cb, BuildInfo lb, string intermediateFolder, string markdownServiceContextHash)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }
            if (cb == null)
            {
                throw new ArgumentNullException(nameof(cb));
            }
            if (intermediateFolder == null)
            {
                throw new ArgumentNullException(nameof(intermediateFolder));
            }
            var baseDir     = Path.Combine(intermediateFolder, cb.DirectoryName);
            var lastBaseDir = lb != null?Path.Combine(intermediateFolder, lb.DirectoryName) : null;

            var lastBuildStartTime         = lb?.BuildStartTime;
            var buildInfoIncrementalStatus = GetBuildInfoIncrementalStatus(cb, lb);
            var lbv = lb?.Versions?.SingleOrDefault(v => v.VersionName == parameters.VersionName);
            var cbv = new BuildVersionInfo()
            {
                BaseDir             = Path.GetFullPath(Environment.ExpandEnvironmentVariables(baseDir)),
                VersionName         = parameters.VersionName,
                ConfigHash          = ComputeConfigHash(parameters, markdownServiceContextHash),
                AttributesFile      = IncrementalUtility.CreateRandomFileName(baseDir),
                DependencyFile      = IncrementalUtility.CreateRandomFileName(baseDir),
                ManifestFile        = IncrementalUtility.CreateRandomFileName(baseDir),
                OutputFile          = IncrementalUtility.CreateRandomFileName(baseDir),
                XRefSpecMapFile     = IncrementalUtility.CreateRandomFileName(baseDir),
                FileMapFile         = IncrementalUtility.CreateRandomFileName(baseDir),
                BuildMessageFile    = IncrementalUtility.CreateRandomFileName(baseDir),
                TocRestructionsFile = IncrementalUtility.CreateRandomFileName(baseDir),
            };

            cb.Versions.Add(cbv);
            var context = new IncrementalBuildContext(baseDir, lastBaseDir, lastBuildStartTime, buildInfoIncrementalStatus, parameters, cbv, lbv)
            {
                IsTemplateUpdated = (cb.TemplateHash != lb?.TemplateHash)
            };

            context.InitDependency();
            context.InitFileAttributes();
            context.InitChanges();
            return(context);
        }