Exemple #1
0
        public override bool Execute()
        {
            Log.LogMessage(MessageImportance.Normal, $"Frameworks: {string.Join(", ", Frameworks.Select(c => c.ItemSpec))}"); // debug

            var dependencies = new SafeList <Dependency>();

            void AddRange(IEnumerable <string> toAdd)
            {
                foreach (var dependency in toAdd)
                {
                    if (dependencies.AddIfNotFound(c => c.Dylib == dependency, () => new Dependency(dependency)))
                    {
                        Log.LogMessage(MessageImportance.Normal, $"Swift Dependency Found: {dependency}");
                    }
                }
            }

            Parallel.ForEach(Frameworks.Select(c => c.ItemSpec), (lib) =>
            {
                AddRange(ScanForDependenciesOnFrameworks(lib));
            });

            // we could precalculate this one and publish with a
            // know dependencies list for Swift dylibs
            // but that means updating the list everytime a new version
            // is released and supporting multiple versions.
            // Update: Windows version is doing it.
            while (dependencies.Any(c => c.Pending))
            {
                var verifyList = from c in dependencies
                                 where c.Pending
                                 select c;

                Parallel.ForEach(verifyList.ToList(), (dependency) =>
                {
                    AddRange(ScanForDependenciesOnSwift(dependency.Dylib));

                    dependency.MarkAsScanned();
                });
            }

            SwiftDependencies = dependencies
                                .Select(c => new TaskItem(c.Dylib))
                                .ToArray();

            return(true);
        }