示例#1
0
        private static bool Dfs(Dep dep, List <string> cycle)
        {
            dep.UpdateConfigurationIfNull();
            var depNameAndConfig = dep.Name + Helper.ConfigurationDelimiter + dep.Configuration;

            ModulesInProcessing.Add(depNameAndConfig);
            VisitedConfigurations.Add(depNameAndConfig);
            var deps = new DepsParser(Path.Combine(Helper.CurrentWorkspace, dep.Name)).Get(dep.Configuration).Deps ?? new List <Dep>();

            foreach (var d in deps)
            {
                d.UpdateConfigurationIfNull();
                var currentDep = d.Name + Helper.ConfigurationDelimiter + d.Configuration;
                if (ModulesInProcessing.Contains(currentDep))
                {
                    cycle.Add(currentDep);
                    cycle.Add(depNameAndConfig);
                    return(true);
                }
                if (VisitedConfigurations.Contains(currentDep))
                {
                    continue;
                }
                if (Dfs(d, cycle))
                {
                    cycle.Add(depNameAndConfig);
                    return(true);
                }
            }
            ModulesInProcessing.Remove(depNameAndConfig);
            return(false);
        }
示例#2
0
        private static void Dfs(Dep dep, Dictionary <Dep, List <Dep> > graph, HashSet <Dep> visitedConfigurations)
        {
            dep.UpdateConfigurationIfNull();

            if (Yaml.Exists(dep.Name) && !Yaml.ConfigurationParser(dep.Name).ConfigurationExists(dep.Configuration))
            {
                ConsoleWriter.WriteWarning($"Configuration '{dep.Configuration}' was not found in {dep.Name}. Will take full-build config");
                dep.Configuration = "full-build";
            }

            visitedConfigurations.Add(dep);
            graph[dep] = new List <Dep>();
            if (!Directory.Exists(Path.Combine(Helper.CurrentWorkspace, dep.Name)))
            {
                throw new CementBuildException("Failed to find module '" + dep.Name + "'");
            }
            var currentDeps = new DepsParser(Path.Combine(Helper.CurrentWorkspace, dep.Name)).Get(dep.Configuration).Deps ?? new List <Dep>();

            currentDeps = currentDeps.Select(d => new Dep(d.Name, null, d.Configuration)).ToList();
            foreach (var d in currentDeps)
            {
                d.UpdateConfigurationIfNull();
                graph[dep].Add(d);
                if (!visitedConfigurations.Contains(d))
                {
                    Dfs(d, graph, visitedConfigurations);
                }
            }
        }
示例#3
0
        public void GetDeps()
        {
            rootRepo        = new GitRepository(rootModule.Name, Helper.CurrentWorkspace, Log);
            rootRepoTreeish = rootRepo.CurrentLocalTreeish().Value;

            var depsContent = new DepsParser(rootRepo.RepoPath).Get(rootModule.Configuration);

            if (!Directory.Exists(Path.Combine(Helper.CurrentWorkspace, "nuget")) &&
                modules.Any(m => m.Name == "nuget"))
            {
                depsContent.Deps.Add(new Dep("nuget"));
            }

            depsContent.Force = Helper.DefineForce(depsContent.Force, rootRepo);
            Log.Info("OK");

            var queue = new DepsQueue();

            queue.AddRange(depsContent.Deps, rootModule.Name);

            var proceed = new ModulesContainer();

            GetDeps(depsContent.Force, queue, proceed);

            CycleDetector.WarnIfCycle(rootModule.Name, rootModule.Configuration, Log);
        }
示例#4
0
        private static DepsContent GetCurrentModuleDeps(Dep dep)
        {
            Log.Info($"{"[" + dep.Name + "]",-30}Getting deps for configuration {dep.Configuration ?? "full-build"}");
            var deps = new DepsParser(Path.Combine(Helper.CurrentWorkspace, dep.Name)).Get(dep.Configuration);

            return(deps);
        }
示例#5
0
        private static void Dfs(Dep dep, Dictionary <Dep, List <Dep> > graph, HashSet <Dep> visitedConfigurations)
        {
            CheckAndUpdateDepConfiguration(dep);
            visitedConfigurations.Add(dep);
            graph[dep] = new List <Dep>();
            var currentDeps = new DepsParser(Path.Combine(Helper.CurrentWorkspace, dep.Name)).Get(dep.Configuration).Deps ?? new List <Dep>();

            currentDeps = currentDeps.Select(d => new Dep(d.Name, null, d.Configuration)).ToList();
            foreach (var d in currentDeps)
            {
                d.UpdateConfigurationIfNull();
                graph[dep].Add(d);
                if (!visitedConfigurations.Contains(d))
                {
                    Dfs(d, graph, visitedConfigurations);
                }
            }
        }
示例#6
0
        public void GetDeps()
        {
            rootRepo        = new GitRepository(rootModule.Name, Helper.CurrentWorkspace, Log);
            rootRepoTreeish = rootRepo.CurrentLocalTreeish().Value;

            var depsContent = new DepsParser(rootRepo.RepoPath).Get(rootModule.Configuration);

            depsContent.Force = depsContent.Force?.Select(f => Helper.DefineForce(f, rootRepo)).ToArray();
            Log.LogInformation("OK");

            var queue = new DepsQueue();

            queue.AddRange(depsContent.Deps, rootModule.Name);

            var proceed = new ModulesContainer();

            GetDeps(depsContent.Force, queue, proceed);

            CycleDetector.WarnIfCycle(rootModule.Name, rootModule.Configuration, Log);
        }