List <Runtime> GetEnabledRuntimes(bool enableLogging)
        {
            var enabledRuntimes = new List <Runtime> ();

            if (allRuntimes == null)
            {
                allRuntimes = new Runtimes();
            }
            return(MonoRuntimesHelpers.GetEnabledRuntimes(allRuntimes, enableLogging));
        }
        void EnsureAllSDKHeadersAreIncluded(Context context, Runtimes allRuntimes)
        {
            string topDirTail = Configurables.Paths.MonoSDKRelativeIncludeSourceDir;

            if (!topDirTail.EndsWith(Path.DirectorySeparatorChar.ToString(), StringComparison.Ordinal))
            {
                topDirTail += Path.DirectorySeparatorChar;
            }

            // Find first enabled runtime - all headers are the same across all runtimes, so we don't care
            // where they come from.
            Runtime runtime = MonoRuntimesHelpers.GetEnabledRuntimes(allRuntimes, enableLogging: false)?.FirstOrDefault();

            if (runtime == null)
            {
                Log.WarningLine("No enabled runtimes (?!)");
                return;
            }

            string runtimeIncludeDirRoot        = Path.Combine(Configurables.Paths.MonoSourceFullPath, MonoRuntimesHelpers.GetRootDir(runtime), Configurables.Paths.MonoSDKRelativeIncludeSourceDir);
            IEnumerable <string> sourceIncludes = Directory.EnumerateFiles(runtimeIncludeDirRoot, "*", SearchOption.AllDirectories);
            var destinationIncludes             = new List <string> ();

            foreach (RuntimeFile rf in allRuntimes.RuntimeFilesToInstall.Where(rf => rf.Type == RuntimeFileType.SdkHeader))
            {
                destinationIncludes.Add(Path.Combine(Configurables.Paths.MonoSourceFullPath, rf.Source(runtime)));
            }

            bool haveDifference = false;

            haveDifference &= ReportDifference(sourceIncludes.Except(destinationIncludes).ToList(), "runtime", "bundle");
            haveDifference &= ReportDifference(destinationIncludes.Except(sourceIncludes).ToList(), "bundle", "runtime");

            if (haveDifference)
            {
                throw new InvalidOperationException("Differences found between the Mono SDK header files shipped in Mono archive and included in Xamarin.Android bundle");
            }

            bool ReportDifference(List <string> diff, string foundIn, string notFoundIn)
            {
                if (diff.Count == 0)
                {
                    return(false);
                }

                Log.ErrorLine($"There are files found in the {foundIn} but not in the {notFoundIn}:");
                foreach (string f in diff)
                {
                    Log.ErrorLine($"  {context.Characters.Bullet} {Utilities.GetRelativePath (runtimeIncludeDirRoot, f)}");
                }
                Log.ErrorLine();
                return(true);
            }
        }
        protected override Task <bool> Execute(Context context)
        {
            List <Runtime> enabledRuntimes = MonoRuntimesHelpers.GetEnabledRuntimes(new Runtimes(), enableLogging: true);

            if (enabledRuntimes.Count == 0)
            {
                Log.StatusLine("No runtimes to build/install");
            }

            return(Task.FromResult(true));
        }
Пример #4
0
        public static void AddRange(this List <BundleItem> list, List <RuntimeFile> runtimeFiles)
        {
            if (list == null)
            {
                throw new ArgumentNullException(nameof(list));
            }

            if (runtimeFiles == null)
            {
                throw new ArgumentNullException(nameof(runtimeFiles));
            }

            var sharedFiles = new HashSet <string> (StringComparer.Ordinal);

            foreach (Runtime runtime in MonoRuntimesHelpers.GetEnabledRuntimes(new Runtimes(), false))
            {
                foreach (RuntimeFile rtf in runtimeFiles)
                {
                    if (rtf == null)
                    {
                        continue;
                    }

                    // Runtime file's *destination* location is our *source* path
                    (bool skipFile, string _, string destFilePath) = MonoRuntimesHelpers.GetRuntimeFilePaths(runtime, rtf);
                    if (rtf.Shared && sharedFiles.Contains(destFilePath))
                    {
                        continue;
                    }

                    if (skipFile)
                    {
                        continue;
                    }
                    list.Add(destFilePath);

                    if (rtf.Shared)
                    {
                        sharedFiles.Add(destFilePath);
                    }
                }
            }
        }