void InstallBCLFiles(List <BclFile> files)
        {
            foreach (BclFile bf in files)
            {
                (string destFilePath, string debugSymbolsDestPath) = MonoRuntimesHelpers.GetDestinationPaths(bf);

                Utilities.CopyFile(bf.SourcePath, destFilePath);
                if (bf.ExcludeDebugSymbols)
                {
                    continue;
                }
                if (debugSymbolsDestPath == null)
                {
                    Log.DebugLine($"Debug symbols not found for BCL file {bf.Name} ({bf.Type})");
                    continue;
                }

                if (!File.Exists(bf.DebugSymbolsPath))
                {
                    Log.DebugLine($"Debug symbols file does not exist: {bf.DebugSymbolsPath}");
                    continue;
                }

                Utilities.CopyFile(bf.DebugSymbolsPath, debugSymbolsDestPath);
            }
        }
Пример #2
0
        public static void AddRange(this List <BundleItem> list, List <MonoUtilityFile> muFiles)
        {
            if (list == null)
            {
                throw new ArgumentNullException(nameof(list));
            }

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

            foreach (MonoUtilityFile muf in muFiles)
            {
                if (muf == null)
                {
                    continue;
                }

                // MU file's *destination* location is our *source* path
                (string destFilePath, string debugSymbolsDestPath) = MonoRuntimesHelpers.GetDestinationPaths(muf);
                list.Add(destFilePath);
                if (muf.IgnoreDebugInfo || String.IsNullOrEmpty(debugSymbolsDestPath))
                {
                    continue;
                }
                list.Add(debugSymbolsDestPath);
            }
        }
Пример #3
0
        public static void AddRange(this List <BundleItem> list, List <BclFile> bclFiles)
        {
            if (list == null)
            {
                throw new ArgumentNullException(nameof(list));
            }

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

            foreach (BclFile bf in bclFiles)
            {
                if (bf == null)
                {
                    continue;
                }

                // BCL file's *destination* location is our *source* path
                (string destFilePath, string debugSymbolsDestPath) = MonoRuntimesHelpers.GetDestinationPaths(bf);
                list.Add(destFilePath);
                if (bf.ExcludeDebugSymbols || !File.Exists(debugSymbolsDestPath))
                {
                    continue;
                }
                list.Add(debugSymbolsDestPath);
            }
        }
Пример #4
0
        public static void AddRange(this List <BundleItem> list, List <TestAssembly> testAssemblies)
        {
            if (list == null)
            {
                throw new ArgumentNullException(nameof(list));
            }

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

            foreach (TestAssembly tasm in testAssemblies)
            {
                if (tasm == null)
                {
                    continue;
                }

                // Test assembly's *destination* location is our *source* path
                (string destFilePath, string debugSymbolsDestPath) = MonoRuntimesHelpers.GetDestinationPaths(tasm);
                list.Add(destFilePath);
                if (String.IsNullOrEmpty(debugSymbolsDestPath))
                {
                    continue;
                }
                list.Add(debugSymbolsDestPath);
            }
        }
Пример #5
0
        bool InstallUtilities(Context context)
        {
            string destDir = MonoRuntimesHelpers.UtilitiesDestinationDir;

            Utilities.CreateDirectory(destDir);

            string managedRuntime     = context.Properties.GetRequiredValue(KnownProperties.ManagedRuntime);
            bool   haveManagedRuntime = !String.IsNullOrEmpty(managedRuntime);
            string remapper           = Utilities.GetRelativePath(BuildPaths.XamarinAndroidSourceRoot, context.Properties.GetRequiredValue(KnownProperties.RemapAssemblyRefToolExecutable));
            string targetCecil        = Utilities.GetRelativePath(BuildPaths.XamarinAndroidSourceRoot, Path.Combine(Configurables.Paths.BuildBinDir, "Xamarin.Android.Cecil.dll"));

            StatusStep(context, "Installing runtime utilities");
            foreach (MonoUtilityFile muf in allRuntimes.UtilityFilesToInstall)
            {
                (string destFilePath, string debugSymbolsDestPath) = MonoRuntimesHelpers.GetDestinationPaths(muf);
                Utilities.CopyFile(muf.SourcePath, destFilePath);
                if (!muf.IgnoreDebugInfo)
                {
                    if (!String.IsNullOrEmpty(debugSymbolsDestPath))
                    {
                        Utilities.CopyFile(muf.DebugSymbolsPath, debugSymbolsDestPath);
                    }
                    else
                    {
                        Log.DebugLine($"Debug symbols not found for utility file {Path.GetFileName (muf.SourcePath)}");
                    }
                }

                if (!muf.RemapCecil)
                {
                    continue;
                }

                string relDestFilePath = Utilities.GetRelativePath(BuildPaths.XamarinAndroidSourceRoot, destFilePath);
                StatusSubStep(context, $"Remapping Cecil references for {relDestFilePath}");
                bool result = Utilities.RunCommand(
                    haveManagedRuntime ? managedRuntime : remapper, // command
                    BuildPaths.XamarinAndroidSourceRoot,            // workingDirectory
                    true,                                           // ignoreEmptyArguments

                    // arguments
                    haveManagedRuntime ? remapper : String.Empty,
                    Utilities.GetRelativePath(BuildPaths.XamarinAndroidSourceRoot, muf.SourcePath),
                    relDestFilePath,
                    "Mono.Cecil",
                    targetCecil);

                if (result)
                {
                    continue;
                }

                Log.ErrorLine($"Failed to remap cecil reference for {destFilePath}");
                return(false);
            }

            return(true);
        }
Пример #6
0
        void InstallBCLFiles(List <BclFile> files)
        {
            foreach (BclFile bf in files)
            {
                (string destFilePath, string debugSymbolsDestPath) = MonoRuntimesHelpers.GetDestinationPaths(bf);

                Utilities.CopyFile(bf.SourcePath, destFilePath);
                if (!bf.ExcludeDebugSymbols && !String.IsNullOrEmpty(bf.DebugSymbolsPath) && debugSymbolsDestPath.Length > 0)
                {
                    Utilities.CopyFile(bf.DebugSymbolsPath !, debugSymbolsDestPath);
                }
            }
        }
        async Task <bool> InstallRuntimes(Context context, List <Runtime> enabledRuntimes)
        {
            StatusStep(context, "Installing tests");
            foreach (TestAssembly tasm in Runtimes.TestAssemblies)
            {
                string sourceBasePath;

                switch (tasm.TestType)
                {
                case TestAssemblyType.Reference:
                case TestAssemblyType.TestRunner:
                    sourceBasePath = Path.Combine(Configurables.Paths.MonoProfileDir);
                    break;

                case TestAssemblyType.XUnit:
                case TestAssemblyType.NUnit:
                case TestAssemblyType.Satellite:
                    sourceBasePath = Configurables.Paths.BCLTestsSourceDir;
                    break;

                default:
                    throw new InvalidOperationException($"Unsupported test assembly type: {tasm.TestType}");
                }

                (string destFilePath, string debugSymbolsDestPath) = MonoRuntimesHelpers.GetDestinationPaths(tasm);
                CopyFile(Path.Combine(sourceBasePath, tasm.Name), destFilePath);
                if (debugSymbolsDestPath != null)
                {
                    CopyFile(Path.Combine(sourceBasePath, Utilities.GetDebugSymbolsPath(tasm.Name)), debugSymbolsDestPath);
                }
            }

            StatusSubStep(context, "Creating BCL tests archive");
            Utilities.DeleteFileSilent(MonoRuntimesHelpers.BCLTestsArchivePath);
            var sevenZip = new SevenZipRunner(context);

            if (!await sevenZip.Zip(MonoRuntimesHelpers.BCLTestsArchivePath, MonoRuntimesHelpers.BCLTestsDestinationDir, new List <string> {
                "."
            }))
            {
                Log.ErrorLine("BCL tests archive creation failed, see the log files for details.");
                return(false);
            }

            StatusStep(context, "Installing runtimes");
            foreach (Runtime runtime in enabledRuntimes)
            {
                StatusSubStep(context, $"Installing {runtime.Flavor} runtime {runtime.Name}");

                string src, dst;
                bool   skipFile;
                foreach (RuntimeFile rtf in allRuntimes.RuntimeFilesToInstall)
                {
                    if (rtf.Shared && rtf.AlreadyCopied)
                    {
                        continue;
                    }

                    (skipFile, src, dst) = MonoRuntimesHelpers.GetRuntimeFilePaths(runtime, rtf);
                    if (skipFile)
                    {
                        continue;
                    }

                    CopyFile(src, dst);
                    if (!StripFile(runtime, rtf, dst))
                    {
                        return(false);
                    }

                    if (rtf.Shared)
                    {
                        rtf.AlreadyCopied = true;
                    }
                }
            }

            return(true);

            bool StripFile(Runtime runtime, RuntimeFile rtf, string filePath)
            {
                if (rtf.Type != RuntimeFileType.StrippableBinary)
                {
                    return(true);
                }

                var monoRuntime = runtime.As <MonoRuntime> ();

                if (monoRuntime == null || !monoRuntime.CanStripNativeLibrary || !rtf.Strip)
                {
                    return(true);
                }

                if (String.IsNullOrEmpty(monoRuntime.Strip))
                {
                    Log.WarningLine($"Binary stripping impossible, runtime {monoRuntime.Name} doesn't define the strip command");
                    return(true);
                }

                bool result;

                if (!String.IsNullOrEmpty(monoRuntime.StripFlags))
                {
                    result = Utilities.RunCommand(monoRuntime.Strip, monoRuntime.StripFlags, filePath);
                }
                else
                {
                    result = Utilities.RunCommand(monoRuntime.Strip, filePath);
                }

                if (result)
                {
                    return(true);
                }

                Log.ErrorLine($"Failed to strip the binary file {filePath}, see logs for error details");
                return(false);
            }

            void CopyFile(string src, string dest)
            {
                if (!CheckFileExists(src, true))
                {
                    return;
                }

                Utilities.CopyFile(src, dest);
            }
        }