diff --git a/.external b/.external index 90e675b1832..ffd73a2699a 100644 --- a/.external +++ b/.external @@ -1,2 +1 @@ xamarin/monodroid:release/8.0.1xx@21aed734165ab0ea8bcaa1f4151bf13654153327 -mono/mono:2020-02@6dd9def57ce969ca04a0ecd9ef72c0a8f069112d diff --git a/.github/dependabot.yml b/.github/dependabot.yml index fa93c1e867c..9c3f02fab8f 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -17,7 +17,6 @@ updates: - dependency-name: "external/apksig" - dependency-name: "external/debugger-libs" - dependency-name: "external/lz4" - - dependency-name: "external/mman-win32" - dependency-name: "external/nrefactory" - dependency-name: "external/opentk" - dependency-name: "external/robin-map" diff --git a/.gitmodules b/.gitmodules index 6a7b436b555..7d9ca6c7122 100644 --- a/.gitmodules +++ b/.gitmodules @@ -14,10 +14,6 @@ path = external/lz4 url = https://github.com/lz4/lz4.git branch = release -[submodule "external/mman-win32"] - path = external/mman-win32 - url = https://github.com/alitrack/mman-win32.git - branch = master [submodule "external/nrefactory"] path = external/nrefactory url = https://github.com/xamarin/NRefactory.git diff --git a/Configuration.Override.props.in b/Configuration.Override.props.in index 722b508470d..8e5284085df 100644 --- a/Configuration.Override.props.in +++ b/Configuration.Override.props.in @@ -38,24 +38,9 @@ - win-x86_64 --> armeabi-v7a:win-armeabi-v7a:arm64:win-arm64:x86:win-x86:x86_64:win-x86_64 - - Darwin:mxe-Win64 - - - clang - clang++ $(HOME)\android-archives $(HOME)\android-toolchain - $(AndroidToolchainDirectory)\mxe diff --git a/Configuration.props b/Configuration.props index 06323961aa3..c784a59e5e1 100644 --- a/Configuration.props +++ b/Configuration.props @@ -69,15 +69,6 @@ $(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.$(AndroidApiLevel).android-x64\$(AndroidPackVersion)\runtimes\android-x64\ $(BuildOutputDirectory)lib\packs\$(MicrosoftAndroidSdkPackName)\$(AndroidPackVersion)\ $(MicrosoftAndroidSdkPackDir)\tools\ - $(MSBuildThisFileDirectory)\bin\Build$(Configuration)\mingw-deps - $(HostCc64) - $(HostCxx64) - $(HostCc32) - $(HostCxx32) - cc - c++ - cc - c++ -j$(HostCpuCount) mono --debug=casts @@ -85,8 +76,6 @@ v1.0 $(HOME)\android-archives $(HOME)\android-toolchain - \usr - $(HostHomebrewPrefix) $(ANDROID_SDK_ROOT) $(AndroidToolchainDirectory)\sdk $(ANDROID_NDK_LATEST_HOME) @@ -102,7 +91,6 @@ $(MSBuildThisFileDirectory)build-tools\gradle $(GradleHome)\gradlew --stacktrace --no-daemon - $(HostOS) armeabi-v7a:arm64:x86:x86_64:win-armeabi-v7a:win-arm64:win-x86:win-x86_64 armeabi-v7a:arm64:x86:x86_64 armeabi-v7a:arm64-v8a:x86:x86_64 @@ -113,13 +101,7 @@ $(MonoRequiredMinimumVersion) False True - $(MSBuildThisFileDirectory)external\mono\sdks\out\android-sources\external\linker\src $(MSBuildThisFileDirectory)external\opentk - \usr - $(HostHomebrewPrefix)\opt\mingw-zlib\usr - $(MingwZlibRootDirectory)\i686-w64-mingw32 - $(MingwZlibRootDirectory)\x86_64-w64-mingw32 - libz.a $(MSBuildThisFileDirectory)external\sqlite $(MSBuildThisFileDirectory) $(MSBuildThisFileDirectory)src-ThirdParty\ @@ -149,10 +131,6 @@ <_TestsProfiledAotName Condition=" '$(AndroidEnableProfiledAot)' == 'true' ">-Profiled $(_TestsProfiledAotName)$(_TestsAotName) - - i686-w64-mingw32 - x86_64-w64-mingw32 - 1.8 1.8 @@ -161,12 +139,10 @@ $(JavaSdkDirectory) - $([System.IO.Path]::GetFullPath ('$(AndroidMxeInstallPrefix)')) $([System.IO.Path]::GetFullPath ('$(AndroidNdkDirectory)')) $([System.IO.Path]::GetFullPath ('$(AndroidSdkDirectory)')) $([System.IO.Path]::GetFullPath ('$(JavaInteropSourceDirectory)')) $([System.IO.Path]::GetFullPath ('$(MonoSourceDirectory)')) - $([System.IO.Path]::GetFullPath ('$(LinkerSourceDirectory)')) $([System.IO.Path]::GetFullPath ('$(SqliteSourceDirectory)')) $([System.IO.Path]::GetFullPath ('$(OpenTKSourceDirectory)')) @@ -195,19 +171,6 @@ $(MSBuildThisFileDirectory)bin/Build$(Configuration)/SourceLink.json - - - $(AndroidSupportedHostJitAbis) - $(AndroidSupportedHostJitAbisForConditionalChecks): - :$(AndroidSupportedHostJitAbisForConditionalChecks) - $(AndroidSupportedHostJitAbis.Split(':')) - - - - diff --git a/Documentation/building/configuration.md b/Documentation/building/configuration.md index 630e27407d0..200f4fe202f 100644 --- a/Documentation/building/configuration.md +++ b/Documentation/building/configuration.md @@ -64,22 +64,6 @@ Overridable MSBuild properties include: building `src/Mono.Android`. This is usually the same value as `$(AndroidApiLevel)`, but may differ with Android Preview releases. - * `$(AndroidSupportedHostJitAbis)`: The Android ABIs for which to build a - host JIT *and* Xamarin.Android base class libraries (`mscorlib.dll`/etc.). - The "host JIT" is used e.g. with the Xamarin Studio Designer, to render - Xamarin.Android apps on the developer's machine. - There can also be support for cross-compiling mono for a different - host, e.g. to build Windows `libmonosgen-2.0.dll` from OS X. - Supported host values include: - - * `Darwin` - * `Linux` - * `mxe-Win64`: Cross-compile Windows 64-bit binaries from Unix. - - The default value is `$(HostOS)`, where `$(HostOS)` is based on probing - various environment variables and filesystem locations. - On OS X, the default would be `Darwin`. - * `$(AndroidSupportedTargetAotAbis)`: The Android ABIs for which to build the Mono AOT compilers. The AOT compilers are required in order to set the [`$(RunAOTCompilation)`][runaotcompilation] app configuration property to True. @@ -107,9 +91,6 @@ Overridable MSBuild properties include: check when building Mono.Android if set to `True`. The check is performed by default. - * `$(HostCc)`, `$(HostCxx)`: The C and C++ compilers to use to generate - host-native binaries. - * `$(IgnoreMaxMonoVersion)`: Skip the enforcement of the `$(MonoRequiredMaximumVersion)` property. This is so that developers can run against the latest and greatest. But the build system can enforce the min and max diff --git a/Documentation/building/unix/instructions.md b/Documentation/building/unix/instructions.md index cea4a849c4b..76388468e1e 100644 --- a/Documentation/building/unix/instructions.md +++ b/Documentation/building/unix/instructions.md @@ -348,8 +348,7 @@ The `ForceBuild` target can be executed as: The `ForceBuild` target will build mono for *all* configured architectures, then invoke the `_InstallRuntimes` target when all the mono's have finished -building; see the `$(AndroidSupportedHostJitAbis)`, -`$(AndroidSupportedTargetAotAbis)`, and `$(AndroidSupportedTargetJitAbis)` +building; see the `$(AndroidSupportedTargetAotAbis)`, and `$(AndroidSupportedTargetJitAbis)` MSBuild properties within [README.md](../../README.md). This may not always be desirable, for example if you're trying to fix a Mono runtime bug for a specific ABI, and improving turnaround time is paramount. diff --git a/Makefile b/Makefile index f1bb5760d47..b15785d433c 100644 --- a/Makefile +++ b/Makefile @@ -59,18 +59,6 @@ ifneq ($(PREPARE_AUTOPROVISION),0) _PREPARE_ARGS += --auto-provision=yes --auto-provision-uses-sudo=yes endif -ifeq ($(OS_NAME),Darwin) -ifeq ($(HOMEBREW_PREFIX),) -HOMEBREW_PREFIX ?= $(shell brew --prefix) -endif -else -HOMEBREW_PREFIX := $prefix -endif - -ifeq ($(wildcard Configuration.OperatingSystem.props),) -PREPARE_MSBUILD_FLAGS += "/p:HostHomebrewPrefix=$(HOMEBREW_PREFIX)" -endif - ifneq ($(PREPARE_SCENARIO),) _PREPARE_ARGS += -s:"$(PREPARE_SCENARIO)" endif diff --git a/Xamarin.Android.sln b/Xamarin.Android.sln index 0e6838a8ab1..46701dbf8fc 100644 --- a/Xamarin.Android.sln +++ b/Xamarin.Android.sln @@ -11,8 +11,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "jnienv-gen", "build-tools\j EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "api-merge", "build-tools\api-merge\api-merge.csproj", "{3FC3E78B-F7D4-42EA-BBE8-4535DF42BFF8}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "remap-assembly-ref", "build-tools\remap-assembly-ref\remap-assembly-ref.csproj", "{C876DA71-8573-4CEF-9149-716D72455ED4}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{04E3E11E-B47D-4599-8AFC-50515A95E715}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Java.Interop", "external\Java.Interop\src\Java.Interop\Java.Interop.csproj", "{94BD81F7-B06F-4295-9636-F8A3B6BDC762}" @@ -157,10 +155,6 @@ Global {3FC3E78B-F7D4-42EA-BBE8-4535DF42BFF8}.Debug|AnyCPU.Build.0 = Debug|Any CPU {3FC3E78B-F7D4-42EA-BBE8-4535DF42BFF8}.Release|AnyCPU.ActiveCfg = Release|Any CPU {3FC3E78B-F7D4-42EA-BBE8-4535DF42BFF8}.Release|AnyCPU.Build.0 = Release|Any CPU - {C876DA71-8573-4CEF-9149-716D72455ED4}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU - {C876DA71-8573-4CEF-9149-716D72455ED4}.Debug|AnyCPU.Build.0 = Debug|Any CPU - {C876DA71-8573-4CEF-9149-716D72455ED4}.Release|AnyCPU.ActiveCfg = Release|Any CPU - {C876DA71-8573-4CEF-9149-716D72455ED4}.Release|AnyCPU.Build.0 = Release|Any CPU {94BD81F7-B06F-4295-9636-F8A3B6BDC762}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU {94BD81F7-B06F-4295-9636-F8A3B6BDC762}.Debug|AnyCPU.Build.0 = Debug|Any CPU {94BD81F7-B06F-4295-9636-F8A3B6BDC762}.Release|AnyCPU.ActiveCfg = Release|Any CPU @@ -397,7 +391,6 @@ Global {1D4FC8F1-0DA4-4F38-BE68-11AEBA9A0EA4} = {04E3E11E-B47D-4599-8AFC-50515A95E715} {AFB8F6D1-6EA9-42C3-950B-98F34C669AD2} = {E351F97D-EA4F-4E7F-AAA0-8EBB1F2A4A62} {3FC3E78B-F7D4-42EA-BBE8-4535DF42BFF8} = {E351F97D-EA4F-4E7F-AAA0-8EBB1F2A4A62} - {C876DA71-8573-4CEF-9149-716D72455ED4} = {E351F97D-EA4F-4E7F-AAA0-8EBB1F2A4A62} {94BD81F7-B06F-4295-9636-F8A3B6BDC762} = {04E3E11E-B47D-4599-8AFC-50515A95E715} {B501D075-6183-4E1D-92C9-F7B5002475B1} = {04E3E11E-B47D-4599-8AFC-50515A95E715} {D14A1B5C-2060-4930-92BE-F7190256C735} = {04E3E11E-B47D-4599-8AFC-50515A95E715} diff --git a/build-tools/conjure-xamarin-android-cecil/conjure-xamarin-android-cecil.cs b/build-tools/conjure-xamarin-android-cecil/conjure-xamarin-android-cecil.cs deleted file mode 100644 index 4b8fa391e16..00000000000 --- a/build-tools/conjure-xamarin-android-cecil/conjure-xamarin-android-cecil.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; - -using Mono.Cecil; - -public class ConjureXamarinAndroidCecil -{ - const string BaseNameReplacement = "Xamarin.Android.Cecil"; - const string CecilAssemblyName = BaseNameReplacement; - const string CecilMdbAssemblyName = BaseNameReplacement + ".Mdb"; - const string PublicKey = - "00240000048000009400000006020000" + - "00240000525341310004000001000100" + - "79159977D2D03A8E6BEA7A2E74E8D1AF" + - "CC93E8851974952BB480A12C9134474D" + - "04062447C37E0E68C080536FCF3C3FBE" + - "2FF9C979CE998475E506E8CE82DD5B0F" + - "350DC10E93BF2EEECF874B24770C5081" + - "DBEA7447FDDAFA277B22DE47D6FFEA44" + - "9674A4F9FCCF84D15069089380284DBD" + - "D35F46CDFF12A1BD78E4EF0065D016DF"; - - static readonly List internalsVisibleTo = new List { - $"Xamarin.Android.Cecil.Pdb, PublicKey={PublicKey}", - $"Xamarin.Android.Cecil.Mdb, PublicKey={PublicKey}" - }; - - public static int Main (string[] args) - { - if (args.Length < 2) { - Console.WriteLine ("Usage: "); - Console.WriteLine (" must have Mono.Cecil.dll and Mono.Cecil.Mdb.dll assemblies"); - return 1; - } - - string inputDir = args [0]; - string inputFilePath = Path.Combine (inputDir, "Mono.Cecil.dll"); - string outputDirPath = args [1]; - - var resolver = new DefaultAssemblyResolver (); - resolver.AddSearchDirectory (Path.GetDirectoryName (inputFilePath)); - var rp = new ReaderParameters () { - AssemblyResolver = resolver, - ReadSymbols = true - }; - var monoCecil = AssemblyDefinition.ReadAssembly (inputFilePath, rp); - monoCecil.Name.Name = CecilAssemblyName; - - var ivtCtor = monoCecil.MainModule.ImportReference (typeof (System.Runtime.CompilerServices.InternalsVisibleToAttribute).GetConstructor (new []{typeof(string)})); - foreach (string ivtParam in internalsVisibleTo) { - var ca = new CustomAttribute (ivtCtor); - ca.ConstructorArguments.Add (new CustomAttributeArgument (monoCecil.MainModule.TypeSystem.String, ivtParam)); - monoCecil.CustomAttributes.Add (ca); - } - - var wp = new WriterParameters { - WriteSymbols = true - }; - - monoCecil.Write (Path.Combine (outputDirPath, $"{CecilAssemblyName}.dll"), wp); - - inputFilePath = Path.Combine (inputDir, "Mono.Cecil.Mdb.dll"); - var monoCecilMdb = AssemblyDefinition.ReadAssembly (inputFilePath, rp); - monoCecilMdb.Name.Name = CecilMdbAssemblyName; - - AssemblyNameReference monoCecilRef = monoCecilMdb.MainModule.AssemblyReferences.Single (r => String.Compare ("Mono.Cecil", r.Name, StringComparison.Ordinal) == 0); - monoCecilRef.Name = CecilAssemblyName; - monoCecilMdb.Write (Path.Combine (outputDirPath, $"{CecilMdbAssemblyName}.dll"), wp); - - return 0; - } -} diff --git a/build-tools/conjure-xamarin-android-cecil/conjure-xamarin-android-cecil.csproj b/build-tools/conjure-xamarin-android-cecil/conjure-xamarin-android-cecil.csproj deleted file mode 100644 index 469501afb30..00000000000 --- a/build-tools/conjure-xamarin-android-cecil/conjure-xamarin-android-cecil.csproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - $(DotNetStableTargetFramework) - false - Exe - Xamarin.Android.Prepare - conjure-xamarin-android-cecil - ..\..\bin\Build$(Configuration) - - - - - - - $(XamarinAndroidSourcePath)external\mono\sdks\out\android-bcl\monodroid_tools\Mono.Cecil.dll - - - \ No newline at end of file diff --git a/build-tools/installers/create-installers.targets b/build-tools/installers/create-installers.targets index 7080dc29fde..081664ed619 100644 --- a/build-tools/installers/create-installers.targets +++ b/build-tools/installers/create-installers.targets @@ -220,10 +220,10 @@ <_MSBuildFiles Include="@(_LocalizationLanguages->'$(MicrosoftAndroidSdkOutDir)%(Identity)\Xamarin.Android.Build.Tasks.resources.dll')" /> <_MSBuildFiles Include="@(_LocalizationLanguages->'$(MicrosoftAndroidSdkOutDir)%(Identity)\Xamarin.Android.Tools.AndroidSdk.resources.dll')" /> <_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)Xamarin.Android.BuildInfo.txt" /> - <_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)Xamarin.Android.Cecil.dll" /> - <_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)Xamarin.Android.Cecil.pdb" /> - <_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)Xamarin.Android.Cecil.Mdb.dll" /> - <_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)Xamarin.Android.Cecil.Mdb.pdb" /> + <_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)Mono.Cecil.dll" /> + <_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)Mono.Cecil.pdb" /> + <_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)Mono.Cecil.Mdb.dll" /> + <_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)Mono.Cecil.Mdb.pdb" /> <_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)Xamarin.Android.Common.props" /> <_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)Xamarin.Android.Common.targets" /> <_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)Xamarin.Android.CSharp.targets" ExcludeFromAndroidNETSdk="true" /> diff --git a/build-tools/remap-assembly-ref/remap-assembly-ref.cs b/build-tools/remap-assembly-ref/remap-assembly-ref.cs deleted file mode 100644 index db1e0d116cc..00000000000 --- a/build-tools/remap-assembly-ref/remap-assembly-ref.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; -using System.IO; -using Mono.Cecil; - -public class Remap -{ - public static int Main (String[] args) { - if (args.Length < 4) { - Console.WriteLine ("Usage: "); - return 1; - } - string in_aname = args [0]; - string out_aname = args [1]; - string ref1 = args [2]; - string target_filename = args [3]; - - var resolver = new DefaultAssemblyResolver (); - resolver.AddSearchDirectory (Path.GetDirectoryName (target_filename)); - var rp = new ReaderParameters () { - AssemblyResolver = resolver, - }; - var target = AssemblyDefinition.ReadAssembly (target_filename, rp); - var ad = AssemblyDefinition.ReadAssembly (in_aname, rp); - bool found = false; - var arefs = ad.MainModule.AssemblyReferences; - for (int i = 0; i < arefs.Count; ++i) { - var aref = arefs [i]; - if (aref.Name == ref1) { - arefs [i] = target.Name; - found = true; - break; - } - } - if (!found) { - Console.Error.WriteLine (string.Format ("remap-assembly-ref.exe: warning: Assembly reference '{0}' not found in file '{1}'.", ref1, in_aname)); - } - - ad.Write (out_aname); - - return 0; - } -} diff --git a/build-tools/remap-assembly-ref/remap-assembly-ref.csproj b/build-tools/remap-assembly-ref/remap-assembly-ref.csproj deleted file mode 100644 index cacd4b29f8e..00000000000 --- a/build-tools/remap-assembly-ref/remap-assembly-ref.csproj +++ /dev/null @@ -1,18 +0,0 @@ - - - - $(DotNetStableTargetFramework) - false - Exe - remapassemblyref - remap-assembly-ref - ..\..\bin\Build$(Configuration)\remap-assembly-ref - - - - - - - - - diff --git a/build-tools/scripts/Configuration.Java.Interop.Override.in.props b/build-tools/scripts/Configuration.Java.Interop.Override.in.props index ca898cf8a6a..76ac996a267 100644 --- a/build-tools/scripts/Configuration.Java.Interop.Override.in.props +++ b/build-tools/scripts/Configuration.Java.Interop.Override.in.props @@ -2,7 +2,6 @@ <_XamarinAndroidCecilVersion>@MonoCecilVersion@ - $(MSBuildThisFileDirectory)..\..\external\mono\external\cecil $(MSBuildThisFileDirectory)..\..\bin\$(Configuration)\lib\xamarin.android\xbuild\Xamarin\Android\ @MicrosoftAndroidSdkOutDir@ $(MSBuildThisFileDirectory)..\..\external\xamarin-android-tools diff --git a/build-tools/scripts/XAVersionInfo.targets b/build-tools/scripts/XAVersionInfo.targets index c30f614b13e..2450ca6de7c 100644 --- a/build-tools/scripts/XAVersionInfo.targets +++ b/build-tools/scripts/XAVersionInfo.targets @@ -6,7 +6,6 @@ - - - -"; - - const string FileBottom = @" - -"; - - public GeneratedProfileAssembliesProjitemsFile (string outputPath) - : base (outputPath) - {} - - public override void Generate (Context context) - { - var runtimes = new Runtimes (); - - IEnumerable facadeAssemblies = runtimes.BclFilesToInstall.Where (f => f.Type == BclFileType.FacadeAssembly); - IEnumerable profileAssemblies = runtimes.BclFilesToInstall.Where (f => f.Type == BclFileType.ProfileAssembly); - IEnumerable testAssemblies = runtimes.TestAssemblies; - - EnsureNoDiscrepancies (facadeAssemblies, profileAssemblies, testAssemblies.Where (ta => ta.TestType != TestAssemblyType.Reference && ta.TestType != TestAssemblyType.TestRunner)); - - using (var fs = File.Open (OutputPath, FileMode.Create)) { - using (var sw = new StreamWriter (fs)) { - GenerateFile (sw, facadeAssemblies, profileAssemblies, testAssemblies); - } - } - } - - void EnsureNoDiscrepancies (IEnumerable facadeAssemblies, IEnumerable profileAssemblies, IEnumerable testAssemblies) - { - bool failed = false; - - // We compare against the *installed* locations since we will not always need to download and/or build the - // Mono Archive (when the XA bundle is present) so we can't rely on the *source* locations of those - // assemblies to be present. - failed |= FileSetsDiffer (facadeAssemblies, Configurables.Paths.InstallBCLFrameworkFacadesDir, "Façade", new HashSet (StringComparer.OrdinalIgnoreCase) { "nunitlite.dll" }); - failed |= FileSetsDiffer (profileAssemblies, Configurables.Paths.InstallBCLFrameworkDir, "Profile"); - failed |= FileSetsDiffer (testAssemblies, Configurables.Paths.BCLTestsDestDir, "Test"); - - if (failed) - throw new InvalidOperationException ("Profile assembly discrepancies found. Please examine 'build-tools/xaprepare/xaprepare/ConfigAndData/Runtimes.cs' to make sure all assemblies listed above are included"); - } - - bool FileSetsDiffer (IEnumerable assemblies, string directoryPath, string batchName, HashSet? ignoreFiles = null) - { - List tests = FilesFromDir (directoryPath, ignoreFiles).ToList (); - tests.AddRange ( - FilesFromDir ( - directoryPath, - globPattern: "*.resources.dll", - stripPath: false, - searchSubdirs: true - ).Select (f => Utilities.GetRelativePath (directoryPath, f)) - ); - - return FileSetsDiffer (ToStringSet (assemblies), tests, batchName); - } - - bool FileSetsDiffer (IEnumerable assemblies, string directoryPath, string batchName, HashSet? ignoreFiles = null) - { - return FileSetsDiffer (ToStringSet (assemblies), FilesFromDir (directoryPath, ignoreFiles), batchName); - } - - bool FileSetsDiffer (IEnumerable set1, IEnumerable set2, string batchName) - { - List diff = set1.Except (set2).ToList (); - - if (diff.Count == 0) - return false; - - Log.ErrorLine ($"{batchName} assemblies found on disk but missing from xaprepare:"); - foreach (string asm in diff) { - Log.StatusLine ($" {Context.Instance.Characters.Bullet} {asm}", ConsoleColor.Cyan); - } - - return true; - } - - IEnumerable FilesFromDir (string directoryPath, HashSet? ignoreFiles = null, string globPattern = "*.dll", bool stripPath = true, bool searchSubdirs = false) - { - IEnumerable files = Directory.EnumerateFiles ( - directoryPath, - globPattern, - searchSubdirs ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly - ).Select (f => stripPath ? Path.GetFileName (f) : f); - - if (ignoreFiles == null || ignoreFiles.Count == 0) - return files; - - return files.Where (f => !ignoreFiles.Contains (f)); - } - - IEnumerable ToStringSet (IEnumerable files) - { - return files.Select (bcf => bcf.Name); - } - - IEnumerable ToStringSet (IEnumerable files) - { - return files.Select (ta => ta.Name); - } - - void GenerateFile (StreamWriter sw, IEnumerable facadeAssemblies, IEnumerable profileAssemblies, IEnumerable testAssemblies) - { - sw.Write (FileTop); - - WriteGroup (sw, "MonoFacadeAssembly", facadeAssemblies); - WriteGroup (sw, "MonoProfileAssembly", profileAssemblies); - WriteGroup (sw, testAssemblies); - - sw.Write (FileBottom); - } - - void WriteGroup (StreamWriter sw, string itemName, IEnumerable files) - { - StartGroup (sw); - foreach (BclFile bcf in files) { - sw.WriteLine ($" <{itemName} Include=\"{bcf.Name}\" />"); - } - foreach (BclFile bcf in files.Where (b => !b.ExcludeDebugSymbols)) { - sw.WriteLine ($" <{itemName}Symbol Include=\"{Path.GetFileName (bcf.DebugSymbolsPath)}\" />"); - } - EndGroup (sw); - } - - void WriteGroup (StreamWriter sw, IEnumerable files) - { - sw.WriteLine (""); - StartGroup (sw); - foreach (TestAssembly taf in files) { - string itemName = "MonoTestAssembly"; - string testType = String.Empty; - - switch (taf.TestType) { - case TestAssemblyType.Satellite: - itemName = "MonoTestSatelliteAssembly"; - break; - - case TestAssemblyType.XUnit: - testType = "xunit"; - break; - - case TestAssemblyType.Reference: - testType = "reference"; - break; - - case TestAssemblyType.TestRunner: - itemName = "MonoTestRunner"; - break; - } - - sw.Write ($" <{itemName} Include=\"{taf.Name}\""); - if (String.IsNullOrEmpty (testType)) - sw.WriteLine (" />"); - else { - sw.WriteLine (" >"); - sw.WriteLine ($" {testType}"); - sw.WriteLine ($" "); - } - } - EndGroup (sw); - } - - void StartGroup (StreamWriter sw) - { - sw.WriteLine (" "); - } - - void EndGroup (StreamWriter sw) - { - sw.WriteLine (" "); - } - } -} diff --git a/build-tools/xaprepare/xaprepare/Application/KnownProperties.cs b/build-tools/xaprepare/xaprepare/Application/KnownProperties.cs index ea4e25770b3..dd2c7c733c0 100644 --- a/build-tools/xaprepare/xaprepare/Application/KnownProperties.cs +++ b/build-tools/xaprepare/xaprepare/Application/KnownProperties.cs @@ -10,10 +10,8 @@ static class KnownProperties public const string AndroidLatestStableApiLevel = "AndroidLatestStableApiLevel"; public const string AndroidLatestUnstableApiLevel = "AndroidLatestUnstableApiLevel"; public const string AndroidLatestStableFrameworkVersion = "AndroidLatestStableFrameworkVersion"; - public const string AndroidMxeFullPath = "AndroidMxeFullPath"; public const string AndroidNdkDirectory = "AndroidNdkDirectory"; public const string AndroidSdkDirectory = "AndroidSdkDirectory"; - public const string AndroidSupportedHostJitAbis = "AndroidSupportedHostJitAbis"; public const string AndroidSupportedTargetAotAbis = "AndroidSupportedTargetAotAbis"; public const string AndroidSupportedTargetJitAbis = "AndroidSupportedTargetJitAbis"; public const string AndroidToolchainCacheDirectory = "AndroidToolchainCacheDirectory"; @@ -43,12 +41,6 @@ static class KnownProperties public const string LibZipSourceFullPath = "LibZipSourceFullPath"; public const string ManagedRuntime = "ManagedRuntime"; public const string MicrosoftAndroidSdkOutDir = "MicrosoftAndroidSdkOutDir"; - public const string MingwCommandPrefix32 = "MingwCommandPrefix32"; - public const string MingwCommandPrefix64 = "MingwCommandPrefix64"; - public const string MingwDependenciesRootDirectory = "MingwDependenciesRootDirectory"; - public const string MingwZlibLibraryName = "MingwZlibLibraryName"; - public const string MingwZlibRootDirectory32 = "MingwZlibRootDirectory32"; - public const string MingwZlibRootDirectory64 = "MingwZlibRootDirectory64"; public const string MonoCecilVersion = "MonoCecilVersion"; public const string MonoDarwinPackageUrl = "MonoDarwinPackageUrl"; public const string MonoRequiredMinimumVersion = "MonoRequiredMinimumVersion"; @@ -58,7 +50,6 @@ static class KnownProperties public const string Pkg7Zip_CommandLine = "Pkg7-Zip_CommandLine"; public const string PkgXamarin_LibZipSharp = "PkgXamarin_LibZipSharp"; public const string ProductVersion = "ProductVersion"; - public const string RemapAssemblyRefToolExecutable = "RemapAssemblyRefToolExecutable"; public const string XABuildToolsFolder = "XABuildToolsFolder"; public const string XABuildToolsVersion = "XABuildToolsVersion"; public const string XABuildToolsPackagePrefixMacOS = "XABuildToolsPackagePrefixMacOS"; diff --git a/build-tools/xaprepare/xaprepare/Application/LlvmRuntime.Linux.cs b/build-tools/xaprepare/xaprepare/Application/LlvmRuntime.Linux.cs deleted file mode 100644 index 1552e3a5ae1..00000000000 --- a/build-tools/xaprepare/xaprepare/Application/LlvmRuntime.Linux.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; - -namespace Xamarin.Android.Prepare -{ - partial class LlvmRuntime - { - const string OSInstallPath = "Linux"; - } -} diff --git a/build-tools/xaprepare/xaprepare/Application/LlvmRuntime.MacOS.cs b/build-tools/xaprepare/xaprepare/Application/LlvmRuntime.MacOS.cs deleted file mode 100644 index 23a819c7677..00000000000 --- a/build-tools/xaprepare/xaprepare/Application/LlvmRuntime.MacOS.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; - -namespace Xamarin.Android.Prepare -{ - partial class LlvmRuntime - { - const string OSInstallPath = "Darwin"; - } -} diff --git a/build-tools/xaprepare/xaprepare/Application/LlvmRuntime.Windows.cs b/build-tools/xaprepare/xaprepare/Application/LlvmRuntime.Windows.cs deleted file mode 100644 index c24fad5cd98..00000000000 --- a/build-tools/xaprepare/xaprepare/Application/LlvmRuntime.Windows.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; - -namespace Xamarin.Android.Prepare -{ - partial class LlvmRuntime - { - const string OSInstallPath = ""; - } -} diff --git a/build-tools/xaprepare/xaprepare/Application/LlvmRuntime.cs b/build-tools/xaprepare/xaprepare/Application/LlvmRuntime.cs deleted file mode 100644 index 2de5a75b3d2..00000000000 --- a/build-tools/xaprepare/xaprepare/Application/LlvmRuntime.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; - -namespace Xamarin.Android.Prepare -{ - partial class LlvmRuntime : Runtime - { - public override string Flavor => "LLVM"; - public bool InstallBinaries { get; protected set; } = true; - - public LlvmRuntime (string name, Func enabledCheck) - : base (name, enabledCheck) - {} - - public override void Init (Context context) - { - if (Context.IsLlvmWindowsAbi (Name)) { - ExeSuffix = Configurables.Defaults.WindowsExecutableSuffix; - InstallPath = Configurables.Paths.InstallMSBuildDir; - } else - InstallPath = OSInstallPath; - } - } -} diff --git a/build-tools/xaprepare/xaprepare/Application/MonoCrossRuntime.Windows.cs b/build-tools/xaprepare/xaprepare/Application/MonoCrossRuntime.Windows.cs deleted file mode 100644 index 888f0af589b..00000000000 --- a/build-tools/xaprepare/xaprepare/Application/MonoCrossRuntime.Windows.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.IO; - -namespace Xamarin.Android.Prepare -{ - partial class MonoCrossRuntime : MonoRuntime - { - partial void InitOS (Context context) - { - // On Windows we should not check cross runtimes because we don't build them - thus they must be - // removed from the set of runtime files/bundle items or otherwise we'll get false negatives - // similar to: - // - // bin\Debug\lib\xamarin.android\xbuild\Xamarin\Android\Windows\cross-arm missing, skipping the rest of bundle item file scan - // Some bundle files are missing, download/rebuild/reinstall forced - // - if (!context.IsWindowsCrossAotAbi (Name)) - SupportedOnHostOS = false; - } - } -} diff --git a/build-tools/xaprepare/xaprepare/Application/MonoCrossRuntime.cs b/build-tools/xaprepare/xaprepare/Application/MonoCrossRuntime.cs deleted file mode 100644 index c59eb042c70..00000000000 --- a/build-tools/xaprepare/xaprepare/Application/MonoCrossRuntime.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using System.IO; - -namespace Xamarin.Android.Prepare -{ - partial class MonoCrossRuntime : MonoRuntime - { - public override string Flavor => "cross compilation"; - - public MonoCrossRuntime (string name, Func enabledCheck) - : base (name, enabledCheck) - {} - - public override void Init (Context context) - { - if (context.IsHostCrossAotAbi (Name)) { - InstallPath = context.OS.Type; // Linux | Darwin | Windows - Strip = "strip"; - StripFlags = "-S"; - } else if (Context.IsWindowsCrossAotAbi (Name)) { - Strip = Path.Combine (Configurables.Paths.MingwBinDir, Context.Properties.GetRequiredValue (KnownProperties.MingwCommandPrefix64) + "-strip"); - ExeSuffix = Configurables.Defaults.WindowsExecutableSuffix; - } else - throw new InvalidOperationException ($"Unsupported cross compiler abi {Name}"); - - CrossMonoName = Configurables.Defaults.CrossRuntimeNames [Name]; - ExePrefix = Configurables.Defaults.CrossRuntimeExePrefixes [Name]; - - InitOS (context); - } - - partial void InitOS (Context context); - } -} diff --git a/build-tools/xaprepare/xaprepare/Application/MonoHostRuntime.Linux.cs b/build-tools/xaprepare/xaprepare/Application/MonoHostRuntime.Linux.cs deleted file mode 100644 index 3cf408315c3..00000000000 --- a/build-tools/xaprepare/xaprepare/Application/MonoHostRuntime.Linux.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Xamarin.Android.Prepare -{ - partial class MonoHostRuntime - { - partial void InitOS () - { - if (Context.Is32BitMingwHostAbi (Name)) - CanStripNativeLibrary = false; - } - } -} diff --git a/build-tools/xaprepare/xaprepare/Application/MonoHostRuntime.cs b/build-tools/xaprepare/xaprepare/Application/MonoHostRuntime.cs deleted file mode 100644 index 9aa8b8c5ebd..00000000000 --- a/build-tools/xaprepare/xaprepare/Application/MonoHostRuntime.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; -using System.IO; - -namespace Xamarin.Android.Prepare -{ - partial class MonoHostRuntime : MonoRuntime - { - public override string Flavor => "host"; - public bool MinGW { get; } - - public MonoHostRuntime (string name, bool mingw, Func enabledCheck) - : base (name, enabledCheck) - { - MinGW = mingw; - CanStripNativeLibrary = true; - MonoSdksPrefix = "host-"; - } - - public override void Init (Context context) - { - if (MinGW) { - NativeLibraryExtension = Configurables.Defaults.MonoHostMingwRuntimeNativeLibraryExtension; - NativeLibraryDirPrefix = Configurables.Paths.MonoRuntimeHostMingwNativeLibraryPrefix; - } else - NativeLibraryExtension = Configurables.Defaults.NativeLibraryExtension; - - if (Context.IsNativeHostAbi (Name)) { - OutputAotProfilerFilename = Configurables.Defaults.MonoRuntimeOutputAotProfilerFilename; - OutputProfilerFilename = Configurables.Defaults.MonoRuntimeOutputProfilerFilename; - } else { - OutputAotProfilerFilename = String.Empty; - OutputProfilerFilename = String.Empty; - } - OutputMonoBtlsFilename = String.Empty; - OutputMonoPosixHelperFilename = Configurables.Defaults.MonoRuntimeOutputMonoPosixHelperFilename; - - if (Context.IsMingwHostAbi (Name)) { - string prefix; - if (Context.Is32BitMingwHostAbi (Name)) { - prefix = Context.Properties.GetRequiredValue (KnownProperties.MingwCommandPrefix32); - } else if (Context.Is64BitMingwHostAbi (Name)) { - prefix = Context.Properties.GetRequiredValue (KnownProperties.MingwCommandPrefix64); - } else - throw new InvalidOperationException($"MinGW host ABI {Name} is neither 32 nor 64-bit (?!)"); - Strip = Path.Combine (Configurables.Paths.MingwBinDir, $"{prefix}-strip"); - } else { - Strip = "strip"; - StripFlags = "-S"; - } - - InitOS (); - } - - partial void InitOS (); - } -} diff --git a/build-tools/xaprepare/xaprepare/Application/MonoJitRuntime.cs b/build-tools/xaprepare/xaprepare/Application/MonoJitRuntime.cs deleted file mode 100644 index 4838e62647e..00000000000 --- a/build-tools/xaprepare/xaprepare/Application/MonoJitRuntime.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.IO; - -namespace Xamarin.Android.Prepare -{ - class MonoJitRuntime : MonoRuntime - { - public override string Flavor => "Android JIT"; - - public MonoJitRuntime (string abiName, bool interpreter, Func enabledCheck) - : base (abiName, enabledCheck) - { - if (interpreter) { - MonoSdksPrefix = "interpreter-"; - DisplayName = $"{abiName} (interpreter)"; - } - } - - public override void Init (Context context) - { - InstallPath = "lib"; - NativeLibraryExtension = Configurables.Defaults.MonoJitRuntimeNativeLibraryExtension; - OutputAotProfilerFilename = Configurables.Defaults.MonoRuntimeOutputAotProfilerFilename; - OutputMonoBtlsFilename = Configurables.Defaults.MonoRuntimeOutputMonoBtlsFilename; - OutputMonoPosixHelperFilename = Configurables.Defaults.MonoRuntimeOutputMonoPosixHelperFilename; - OutputProfilerFilename = Configurables.Defaults.MonoRuntimeOutputProfilerFilename; - Strip = Path.Combine (Configurables.Paths.AndroidToolchainBinDirectory, "llvm-strip"); - } - } -} diff --git a/build-tools/xaprepare/xaprepare/Application/MonoRuntime.cs b/build-tools/xaprepare/xaprepare/Application/MonoRuntime.cs deleted file mode 100644 index 4fabdb2723d..00000000000 --- a/build-tools/xaprepare/xaprepare/Application/MonoRuntime.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; - -namespace Xamarin.Android.Prepare -{ - abstract class MonoRuntime : Runtime - { - public bool CanStripNativeLibrary { get; set; } = true; - public string CrossMonoName { get; set; } = String.Empty; - public string ExePrefix { get; set; } = String.Empty; - public bool IsCrossRuntime { get; set; } - public string NativeLibraryExtension { get; set; } = String.Empty; - - /// - /// Optional directory prefix for native library source. This should be a path relative to runtime's library - /// output dir and it exists because MinGW builds will put the runtime .dll in the bin directory instead of in - /// the lib one. - /// - public string NativeLibraryDirPrefix { get; set; } = String.Empty; - public string OutputAotProfilerFilename { get; set; } = String.Empty; - public string OutputMonoBtlsFilename { get; set; } = String.Empty; - public string OutputMonoPosixHelperFilename { get; set; } = String.Empty; - public string OutputProfilerFilename { get; set; } = String.Empty; - public string OutputRuntimeFilename { get; set; } = Configurables.Defaults.MonoRuntimeOutputFileName; - public string Strip { get; set; } = String.Empty; - public string StripFlags { get; set; } = "--strip-debug"; - - protected MonoRuntime (string name, Func enabledCheck) - : base (name, enabledCheck) - {} - } -} diff --git a/build-tools/xaprepare/xaprepare/Application/MonoRuntimesHelpers.cs b/build-tools/xaprepare/xaprepare/Application/MonoRuntimesHelpers.cs deleted file mode 100644 index ae1ce811798..00000000000 --- a/build-tools/xaprepare/xaprepare/Application/MonoRuntimesHelpers.cs +++ /dev/null @@ -1,254 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; - -namespace Xamarin.Android.Prepare -{ - class MonoRuntimesHelpers - { - public static string UtilitiesDestinationDir => Configurables.Paths.InstallMSBuildDir; - public static string BCLRedistListDestinationDir => Configurables.Paths.InstallBCLFrameworkRedistListDir; - public static string BCLTestsDestinationDir => Configurables.Paths.BCLTestsDestDir; - public static string BCLTestsArchivePath => Configurables.Paths.BCLTestsArchivePath; - public static string RuntimeDestinationDir => Configurables.Paths.InstallMSBuildDir; - public static string FrameworkListPath => Configurables.Paths.FrameworkListInstallPath; - - public static readonly Dictionary BCLDestinationDirs = new Dictionary () { - { BclFileTarget.Android, Configurables.Paths.InstallBCLFrameworkDir }, - { BclFileTarget.DesignerHost, Configurables.Paths.InstallHostBCLDir }, - { BclFileTarget.DesignerWindows, Configurables.Paths.InstallWindowsBCLDir }, - }; - - public static readonly Dictionary BCLFacadesDestinationDirs = new Dictionary () { - { BclFileTarget.Android, Configurables.Paths.InstallBCLFrameworkFacadesDir }, - { BclFileTarget.DesignerHost, Configurables.Paths.InstallHostBCLFacadesDir }, - { BclFileTarget.DesignerWindows, Configurables.Paths.InstallWindowsBCLFacadesDir }, - }; - - public static List GetEnabledRuntimes (Runtimes allRuntimes, bool enableLogging) - { - if (allRuntimes == null) - throw new ArgumentNullException (nameof (allRuntimes)); - - var context = Context.Instance; - var enabledRuntimes = new List (); - - if (enableLogging) - Log.Instance.StatusLine ("Enabled Mono Android runtime ABIs:", ConsoleColor.White); - - foreach (Runtime runtime in allRuntimes.Items.Where (r => r is MonoJitRuntime && r.Enabled)) { - enabledRuntimes.Add (runtime); - if (enableLogging) - Log.Instance.StatusLine ($" {context.Characters.Bullet} {runtime.DisplayName}"); - } - - if (enableLogging) { - Log.Instance.StatusLine (); - Log.Instance.StatusLine ("Enabled Mono host runtimes:", ConsoleColor.White); - } - foreach (Runtime runtime in allRuntimes.Items.Where (r => r is MonoHostRuntime && r.Enabled)) { - enabledRuntimes.Add (runtime); - if (enableLogging) - Log.Instance.StatusLine ($" {context.Characters.Bullet} {runtime.DisplayName}"); - } - - bool anyCrossEnabled = false; - if (enableLogging) { - Log.Instance.StatusLine (); - Log.Instance.StatusLine ("Enabled Mono cross compilers:", ConsoleColor.White); - } - foreach (Runtime runtime in allRuntimes.Items.Where (r => r is MonoCrossRuntime && r.Enabled)) { - anyCrossEnabled = true; - enabledRuntimes.Add (runtime); - if (enableLogging) - Log.Instance.StatusLine ($" {context.Characters.Bullet} {runtime.DisplayName}"); - } - - if (enableLogging && !anyCrossEnabled) - Log.Instance.StatusLine ($" NONE", ConsoleColor.DarkCyan); - - anyCrossEnabled = false; - if (enableLogging) { - Log.Instance.StatusLine (); - Log.Instance.StatusLine ("Enabled LLVM cross compilers:", ConsoleColor.White); - } - foreach (Runtime runtime in allRuntimes.Items.Where (r => r is LlvmRuntime && r.Enabled)) { - anyCrossEnabled = true; - enabledRuntimes.Add (runtime); - if (enableLogging) - Log.Instance.StatusLine ($" {context.Characters.Bullet} {runtime.DisplayName}"); - } - if (enableLogging && !anyCrossEnabled) - Log.Instance.StatusLine ($" NONE", ConsoleColor.DarkCyan); - - return enabledRuntimes; - } - - public static (string executable, string debugSymbols) GetDestinationPaths (MonoUtilityFile muf) - { - string destDir = UtilitiesDestinationDir; - string targetFileName; - - if (!String.IsNullOrEmpty (muf.TargetName)) - targetFileName = muf.TargetName!; - else - targetFileName = Path.GetFileName (muf.SourcePath); - - string destFilePath = Path.Combine (destDir, targetFileName); - if (String.IsNullOrEmpty (muf.DebugSymbolsPath)) - return (destFilePath, String.Empty); - - return (destFilePath, Path.Combine (destDir, Utilities.GetDebugSymbolsPath (targetFileName))); - } - - public static (string assembly, string debugSymbols) GetDestinationPaths (BclFile bf) - { - string destDir; - switch (bf.Type) { - case BclFileType.ProfileAssembly: - destDir = BCLDestinationDirs [bf.Target]; - break; - - case BclFileType.FacadeAssembly: - destDir = BCLFacadesDestinationDirs [bf.Target]; - break; - - default: - throw new InvalidOperationException ($"Unsupported BCL file type {bf.Type} for file {bf.Name}"); - } - - string destFile = Path.Combine (destDir, bf.Name); - if (bf.ExcludeDebugSymbols) - return (destFile, String.Empty); - - return (destFile, Path.Combine (destDir, Path.GetFileName (bf.DebugSymbolsPath) ?? String.Empty)); - } - - public static (string assembly, string debugSymbols) GetDestinationPaths (TestAssembly tasm) - { - if (tasm == null) - throw new ArgumentNullException (nameof (tasm)); - - bool pdbRequired; - switch (tasm.TestType) { - case TestAssemblyType.Reference: - case TestAssemblyType.TestRunner: - case TestAssemblyType.XUnit: - case TestAssemblyType.NUnit: - case TestAssemblyType.Satellite: - pdbRequired = tasm.TestType != TestAssemblyType.Satellite && !tasm.ExcludeDebugSymbols; - break; - - default: - throw new InvalidOperationException ($"Unsupported test assembly type: {tasm.TestType}"); - } - - string destDir; - if (tasm.Name.IndexOf (Path.DirectorySeparatorChar) >= 0) - destDir = Path.Combine (BCLTestsDestinationDir, Path.GetDirectoryName (tasm.Name) ?? String.Empty); - else - destDir = BCLTestsDestinationDir; - - string destFile = Path.Combine (destDir, Path.GetFileName (tasm.Name)); - return (destFile, pdbRequired ? Utilities.GetDebugSymbolsPath (destFile) : String.Empty); - } - - public static (bool skip, string src, string dst) GetRuntimeFilePaths (Runtime runtime, RuntimeFile rtf) - { - if (rtf.ShouldSkip != null && rtf.ShouldSkip (runtime)) - return (true, String.Empty, String.Empty); - - return ( - false, - GetPath ("source", rtf.Source (runtime), Configurables.Paths.MonoSourceFullPath), - GetPath ("destination", rtf.Destination (runtime), RuntimeDestinationDir) - ); - - string GetPath (string name, string path, string defaultRoot) - { - if (String.IsNullOrEmpty (path)) - throw new InvalidOperationException ($"Empty {name} file path"); - if (!Path.IsPathRooted (path)) - path = Path.Combine (defaultRoot, path); - return Path.GetFullPath (path); - } - } - - public static string GetRootDir (Runtime runtime) - { - if (runtime == null) - throw new ArgumentNullException (nameof (runtime)); - - return Path.Combine (Configurables.Paths.MonoSDKSRelativeOutputDir, $"android-{runtime.PrefixedName}-{Configurables.Defaults.MonoSdksConfiguration}"); - } - - public static bool AreRuntimeItemsInstalled (Context context, Runtimes runtimes) - { - if (context == null) - throw new ArgumentNullException (nameof (context)); - if (runtimes == null) - throw new ArgumentNullException (nameof (runtimes)); - - if (!string.IsNullOrEmpty (context.MonoArchiveCustomUrl)) { - context.Log.StatusLine ("Skipping AreRuntimeItemsInstalled check, due to custom mono archive URL."); - return false; - } - - foreach (var bclFile in runtimes.BclFilesToInstall) { - (string destFilePath, string debugSymbolsDestPath) = GetDestinationPaths (bclFile); - if (!DoesItemExist (destFilePath, bclFile.ExcludeDebugSymbols, debugSymbolsDestPath)) - return false; - } - - foreach (var bclFile in runtimes.DesignerHostBclFilesToInstall) { - (string destFilePath, string debugSymbolsDestPath) = GetDestinationPaths (bclFile); - if (!DoesItemExist (destFilePath, bclFile.ExcludeDebugSymbols, debugSymbolsDestPath)) - return false; - } - - foreach (var bclFile in runtimes.DesignerWindowsBclFilesToInstall) { - (string destFilePath, string debugSymbolsDestPath) = GetDestinationPaths (bclFile); - if (!DoesItemExist (destFilePath, bclFile.ExcludeDebugSymbols, debugSymbolsDestPath)) - return false; - } - - foreach (var testFile in runtimes.TestAssemblies) { - (string destFilePath, string debugSymbolsDestPath) = GetDestinationPaths (testFile); - if (!DoesItemExist (destFilePath, true, debugSymbolsDestPath)) - return false; - } - - foreach (var utilFile in runtimes.UtilityFilesToInstall) { - (string destFilePath, string debugSymbolsDestPath) = GetDestinationPaths (utilFile); - if (!DoesItemExist (destFilePath, utilFile.IgnoreDebugInfo, debugSymbolsDestPath)) - return false; - } - - foreach (var runtime in GetEnabledRuntimes (runtimes, true)) { - foreach (var runtimeFile in runtimes.RuntimeFilesToInstall) { - (bool skipFile, string src, string dst) = GetRuntimeFilePaths (runtime, runtimeFile); - - if (!skipFile && (dst.Length == 0 || !File.Exists (dst))) { - Log.Instance.WarningLine ($"File '{dst}' missing, skipping the rest of runtime item file scan"); - return false; - } - } - } - - return true; - - bool DoesItemExist (string destFilePath, bool shouldExcludeSymbols, string debugSymbolsDestPath) - { - if (File.Exists (destFilePath) && shouldExcludeSymbols) - return true; - - if (File.Exists (destFilePath) && !shouldExcludeSymbols && !String.IsNullOrEmpty (debugSymbolsDestPath) && File.Exists (debugSymbolsDestPath)) - return true; - - Log.Instance.DebugLine ($"File '{destFilePath}' or symbols '{debugSymbolsDestPath}' missing, skipping the rest of runtime item file scan"); - return false; - } - } - } -} diff --git a/build-tools/xaprepare/xaprepare/Application/MonoUtilityFile.cs b/build-tools/xaprepare/xaprepare/Application/MonoUtilityFile.cs deleted file mode 100644 index e8f16caafc4..00000000000 --- a/build-tools/xaprepare/xaprepare/Application/MonoUtilityFile.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using System.IO; - -namespace Xamarin.Android.Prepare -{ - sealed class MonoUtilityFile - { - public string SourcePath { get; } - public string? TargetName { get; } - public bool RemapCecil { get; } - public bool IgnoreDebugInfo { get; } - - public string DebugSymbolsPath => Utilities.GetDebugSymbolsPath (SourcePath); - - public MonoUtilityFile (string name, bool remap = false, string? targetName = null, bool ignoreDebugInfo = false) - { - name = name.Trim (); - if (String.IsNullOrEmpty (name)) - throw new ArgumentException ("must not be null or empty", nameof (name)); - - SourcePath = Path.GetFullPath (Path.Combine (Configurables.Paths.MonoProfileToolsDir, name)); - RemapCecil = remap; - TargetName = targetName; - IgnoreDebugInfo = ignoreDebugInfo; - } - } -} diff --git a/build-tools/xaprepare/xaprepare/Application/Properties.Defaults.cs.in b/build-tools/xaprepare/xaprepare/Application/Properties.Defaults.cs.in index b0220aa9717..2d0bd087f0c 100644 --- a/build-tools/xaprepare/xaprepare/Application/Properties.Defaults.cs.in +++ b/build-tools/xaprepare/xaprepare/Application/Properties.Defaults.cs.in @@ -14,10 +14,8 @@ namespace Xamarin.Android.Prepare properties.Add (KnownProperties.AndroidLatestStableApiLevel, StripQuotes ("@AndroidLatestStableApiLevel@")); properties.Add (KnownProperties.AndroidLatestUnstableApiLevel, StripQuotes ("@AndroidLatestUnstableApiLevel@")); properties.Add (KnownProperties.AndroidLatestStableFrameworkVersion, StripQuotes ("@AndroidLatestStableFrameworkVersion@")); - properties.Add (KnownProperties.AndroidMxeFullPath, StripQuotes (@"@AndroidMxeFullPath@")); properties.Add (KnownProperties.AndroidNdkDirectory, StripQuotes (@"@AndroidNdkDirectory@")); properties.Add (KnownProperties.AndroidSdkDirectory, StripQuotes (@"@AndroidSdkDirectory@")); - properties.Add (KnownProperties.AndroidSupportedHostJitAbis, StripQuotes ("@AndroidSupportedHostJitAbis@")); properties.Add (KnownProperties.AndroidSupportedTargetAotAbis, StripQuotes ("@AndroidSupportedTargetAotAbis@")); properties.Add (KnownProperties.AndroidSupportedTargetJitAbis, StripQuotes ("@AndroidSupportedTargetJitAbis@")); properties.Add (KnownProperties.AndroidToolchainCacheDirectory, StripQuotes (@"@AndroidToolchainCacheDirectory@")); @@ -47,12 +45,6 @@ namespace Xamarin.Android.Prepare properties.Add (KnownProperties.LibZipSourceFullPath, StripQuotes (@"@LibZipSourceFullPath@")); properties.Add (KnownProperties.ManagedRuntime, StripQuotes (@"@ManagedRuntime@")); properties.Add (KnownProperties.MicrosoftAndroidSdkOutDir, StripQuotes (@"@MicrosoftAndroidSdkOutDir@")); - properties.Add (KnownProperties.MingwCommandPrefix32, StripQuotes ("@MingwCommandPrefix32@")); - properties.Add (KnownProperties.MingwCommandPrefix64, StripQuotes ("@MingwCommandPrefix64@")); - properties.Add (KnownProperties.MingwDependenciesRootDirectory, StripQuotes (@"@MingwDependenciesRootDirectory@")); - properties.Add (KnownProperties.MingwZlibLibraryName, StripQuotes ("@MingwZlibLibraryName@")); - properties.Add (KnownProperties.MingwZlibRootDirectory32, StripQuotes (@"@MingwZlibRootDirectory32@")); - properties.Add (KnownProperties.MingwZlibRootDirectory64, StripQuotes (@"@MingwZlibRootDirectory64@")); properties.Add (KnownProperties.MonoCecilVersion, StripQuotes ("@MonoCecilVersion@")); properties.Add (KnownProperties.MonoDarwinPackageUrl, StripQuotes ("@MonoDarwinPackageUrl@")); properties.Add (KnownProperties.MonoRequiredMinimumVersion, StripQuotes ("@MonoRequiredMinimumVersion@")); @@ -62,7 +54,6 @@ namespace Xamarin.Android.Prepare properties.Add (KnownProperties.Pkg7Zip_CommandLine, StripQuotes (@"@Pkg7-Zip_CommandLine@")); properties.Add (KnownProperties.PkgXamarin_LibZipSharp, StripQuotes (@"@PkgXamarin_LibZipSharp@")); properties.Add (KnownProperties.ProductVersion, StripQuotes ("@ProductVersion@")); - properties.Add (KnownProperties.RemapAssemblyRefToolExecutable, StripQuotes (@"@RemapAssemblyRefToolExecutable@")); properties.Add (KnownProperties.XABuildToolsFolder, StripQuotes (@"@XABuildToolsFolder@")); properties.Add (KnownProperties.XABuildToolsVersion, StripQuotes ("@XABuildToolsVersion@")); properties.Add (KnownProperties.XABuildToolsPackagePrefixMacOS, StripQuotes ("@XABuildToolsPackagePrefixMacOS@")); diff --git a/build-tools/xaprepare/xaprepare/Application/Runtime.cs b/build-tools/xaprepare/xaprepare/Application/Runtime.cs deleted file mode 100644 index 647b48d4d59..00000000000 --- a/build-tools/xaprepare/xaprepare/Application/Runtime.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System; - -namespace Xamarin.Android.Prepare -{ - abstract class Runtime : AppObject - { - string displayName = String.Empty; - Func enabledCheck; - - /// - /// Set to true if the current runtime is supported on the host OS. - /// - protected bool SupportedOnHostOS { get; set; } = true; - - protected Context Context => Context.Instance; - public bool Enabled => SupportedOnHostOS && enabledCheck (Context); - public string ExeSuffix { get; protected set; } = String.Empty; - - /// - /// Path relative to where the runtime will be placed or - /// null to install the runtime directly under . In - /// each case the runtime will be appended to create full path to the destination - /// directory. - /// - public string InstallPath { get; protected set; } = String.Empty; - public string Name { get; protected set; } - - /// - /// Name of the runtime for display purposes. If not set explicitly, it is the same as - /// - public string DisplayName { - get => String.IsNullOrEmpty (displayName) ? Name : displayName; - set => displayName = value ?? String.Empty; - } - - /// - /// Purely cosmetic thing - the kind of runtime (LLVM, JIT etc), for progress reporting. - /// - public abstract string Flavor { get; } - - /// - /// Prefix to used by MonoSDKs to construct the runtime output directory. - /// - protected string MonoSdksPrefix { get; set; } = String.Empty; - - /// - /// Host runtimes need a prefix in order to match Mono SDKs output directory name for them. This property is - /// defined in the base class to make code using the runtime definitions simpler. - /// - public string PrefixedName => String.IsNullOrEmpty (MonoSdksPrefix) ? Name : $"{MonoSdksPrefix}{Name}"; - - public Runtime (string name, Func enabledCheck) - { - if (String.IsNullOrEmpty (name)) - throw new ArgumentException ("must not be null or empty", nameof (name)); - - if (enabledCheck == null) - throw new ArgumentNullException (nameof (enabledCheck)); - - this.enabledCheck = enabledCheck; - Name = name; - } - - public abstract void Init (Context context); - } -} diff --git a/build-tools/xaprepare/xaprepare/Application/RuntimeFile.cs b/build-tools/xaprepare/xaprepare/Application/RuntimeFile.cs deleted file mode 100644 index 7e61be9c847..00000000000 --- a/build-tools/xaprepare/xaprepare/Application/RuntimeFile.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; - -namespace Xamarin.Android.Prepare -{ - class RuntimeFile - { - /// - /// Path of the source file (one in the Mono SDK output location). Either relative to Mono SDK output path or - /// absolute. - /// - public Func Source { get; } - - /// - /// Destination of the file. Either relative to or absolute. - /// - public Func Destination { get; } - - /// - /// An optional check on whether or not the file should be installed for the particular runtime. - /// - public Func? ShouldSkip { get; } - - /// - /// Whether or not to strip the binary of debugging symbols after installation. - /// - public bool Strip { get; } = true; - - /// - /// Type of the file. It's needed in order to determine what tools, if any, we can run on the file once it is - /// installed, if any. - /// - public RuntimeFileType Type { get; } = RuntimeFileType.Other; - - /// - /// If set to true then the file will be copied only once, not per runtime - /// - public bool Shared { get; } - - public bool AlreadyCopied { get; set; } - - public RuntimeFile (Func sourceCreator, Func destinationCreator, Func? shouldSkip = null, bool strip = true, RuntimeFileType type = RuntimeFileType.Other, bool shared = false) - { - Source = sourceCreator; - Destination = destinationCreator; - ShouldSkip = shouldSkip; - Strip = strip; - Type = type; - Shared = shared; - } - } -} diff --git a/build-tools/xaprepare/xaprepare/Application/RuntimeFileType.cs b/build-tools/xaprepare/xaprepare/Application/RuntimeFileType.cs deleted file mode 100644 index 70e0e9cde58..00000000000 --- a/build-tools/xaprepare/xaprepare/Application/RuntimeFileType.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Xamarin.Android.Prepare -{ - enum RuntimeFileType - { - Other, - Binary, - StrippableBinary, - SdkHeader, - } -} diff --git a/build-tools/xaprepare/xaprepare/Application/Utilities.cs b/build-tools/xaprepare/xaprepare/Application/Utilities.cs index e594209db44..e380f8563ca 100644 --- a/build-tools/xaprepare/xaprepare/Application/Utilities.cs +++ b/build-tools/xaprepare/xaprepare/Application/Utilities.cs @@ -53,92 +53,6 @@ public static bool ParseAndroidPkgRevision (string? v, out Version? version, out return false; } - public static bool AbiChoiceChanged (Context context) - { - string cacheFile = Configurables.Paths.MonoRuntimesEnabledAbisCachePath; - if (!File.Exists (cacheFile)) { - Log.DebugLine ($"Enabled ABI cache file not found at {cacheFile}"); - return true; - } - - var oldAbis = new HashSet (StringComparer.Ordinal); - foreach (string l in File.ReadAllLines (cacheFile)) { - string line = l.Trim (); - if (String.IsNullOrEmpty (line) || oldAbis.Contains (line)) - continue; - oldAbis.Add (line); - } - - HashSet? currentAbis = null; - FillCurrentAbis (context, ref currentAbis); - - if (currentAbis == null) - return false; - - if (oldAbis.Count != currentAbis.Count) - return true; - - foreach (string abi in oldAbis) { - if (!currentAbis.Contains (abi)) - return true; - } - - return false; - } - - public static void SaveAbiChoice (Context context) - { - HashSet? currentAbis = null; - FillCurrentAbis (context, ref currentAbis); - - if (currentAbis == null || currentAbis.Count == 0) { - Log.WarningLine ("Cannot save ABI choice, no current ABIs"); - return; - } - - string cacheFile = Configurables.Paths.MonoRuntimesEnabledAbisCachePath; - Log.DebugLine ($"Writing ABI cache file {cacheFile}"); - File.WriteAllLines (cacheFile, currentAbis); - } - - static void FillCurrentAbis (Context context, ref HashSet? currentAbis) - { - Utilities.AddAbis (context.Properties.GetRequiredValue (KnownProperties.AndroidSupportedTargetJitAbis).Trim (), ref currentAbis); - Utilities.AddAbis (context.Properties.GetRequiredValue (KnownProperties.AndroidSupportedTargetAotAbis).Trim (), ref currentAbis); - Utilities.AddAbis (context.Properties.GetRequiredValue (KnownProperties.AndroidSupportedHostJitAbis).Trim (), ref currentAbis); - } - - public static void PropagateXamarinAndroidCecil (Context context) - { - const string CecilAssembly = "Xamarin.Android.Cecil.dll"; - - CopyFile ( - Path.Combine (Configurables.Paths.InstallMSBuildDir, CecilAssembly), - Path.Combine (Configurables.Paths.ExternalJavaInteropDir, "bin", context.Configuration, CecilAssembly) - ); - } - - public static async Task BuildRemapRef (Context context, bool haveManagedRuntime, string managedRuntime, bool quiet = false) - { - if (!quiet) - Log.StatusLine ("Building remap-assembly-ref"); - - var msbuild = new MSBuildRunner (context); - string projectPath = Path.Combine (Configurables.Paths.BuildToolsDir, "remap-assembly-ref", "remap-assembly-ref.csproj"); - bool result = await msbuild.Run ( - projectPath: projectPath, - logTag: "remap-assembly-ref", - binlogName: "build-remap-assembly-ref" - ); - - if (!result) { - Log.ErrorLine ("Failed to build remap-assembly-ref"); - return false; - } - - return true; - } - public static string ToXamarinAndroidPropertyValue (ICollection coll) { if (coll == null) diff --git a/build-tools/xaprepare/xaprepare/ConfigAndData/AbiNames.cs b/build-tools/xaprepare/xaprepare/ConfigAndData/AbiNames.cs deleted file mode 100644 index 4a334b03f45..00000000000 --- a/build-tools/xaprepare/xaprepare/ConfigAndData/AbiNames.cs +++ /dev/null @@ -1,167 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace Xamarin.Android.Prepare -{ - static class AbiNames - { - static HashSet ? allHostAbis; - - public static class TargetJit - { - public const string AndroidArmV7a = "armeabi-v7a"; - public const string AndroidArmV8a = "arm64-v8a"; - public const string AndroidArm64 = AndroidArmV8a; - public const string AndroidX86 = "x86"; - public const string AndroidX86_64 = "x86_64"; - } - - public static class TargetAot - { - public const string ArmV7a = "armeabi-v7a"; - public const string WinArmV7a = "win-armeabi-v7a"; - public const string ArmV8a = "arm64"; - public const string Arm64 = ArmV8a; - public const string WinArmV8a = "win-arm64"; - public const string WinArm64 = WinArmV8a; - public const string X86 = "x86"; - public const string WinX86 = "win-x86"; - public const string X86_64 = "x86_64"; - public const string WinX86_64 = "win-x86_64"; - } - - public static class HostJit - { - public const string Linux = "Linux"; - public const string Darwin = "Darwin"; - public const string Win32 = "mxe-Win32"; - public const string Win64 = "mxe-Win64"; - } - - public static class CrossAot - { - public static readonly string ArmV7a = "cross-arm"; - public static readonly string WinArmV7a = $"{ArmV7a}-win"; - public static readonly string ArmV8a = "cross-arm64"; - public static readonly string Arm64 = ArmV8a; - public static readonly string WinArmV8a = $"{ArmV8a}-win"; - public static readonly string WinArm64 = WinArmV8a; - public static readonly string X86 = "cross-x86"; - public static readonly string WinX86 = $"{X86}-win"; - public static readonly string X86_64 = "cross-x86_64"; - public static readonly string WinX86_64 = $"{X86_64}-win"; - } - - public static class Llvm - { - public const string Host32Bit = "llvm32"; - public const string Host64Bit = "llvm64"; - public const string Windows32Bit = "llvmwin32"; - public const string Windows64Bit = "llvmwin64"; - } - - public static HashSet AllHostAbis { - get { - if (allHostAbis == null) - allHostAbis = Abi.GetHostAbis (includeAllHostOSes: false); - return allHostAbis; - } - } - - public static readonly HashSet AllNativeHostAbis = Abi.GetHostAbis (osType: Abi.OS.NotWindows); - - public static readonly HashSet AllAotAbis = Abi.GetHostAotAbis (); - - public static readonly HashSet AllLlvmHostAbis = Abi.GetLlvmAbis (); - public static readonly HashSet AllLlvmWindowsAbis = Abi.GetLlvmAbis (osType: Abi.OS.Windows); - public static readonly HashSet All32BitLlvmAbis = Abi.GetLlvmAbis (bitness: Abi.Bitness.ThirtyTwo); - public static readonly HashSet All64BitLlvmAbis = Abi.GetLlvmAbis (bitness: Abi.Bitness.SixtyFour); - - public static readonly HashSet AllJitAbis = Abi.GetTargetJitAbis (); - public static readonly HashSet All32BitTargetJitAbis = Abi.GetTargetJitAbis (Abi.Bitness.ThirtyTwo); - public static readonly HashSet All64BitTargetJitAbis = Abi.GetTargetJitAbis (Abi.Bitness.SixtyFour); - - public static readonly HashSet AllHostAotAbis = Abi.GetHostAotAbis (osType: Abi.OS.NotWindows); - public static readonly HashSet All32BitHostAotAbis = Abi.GetHostAotAbis (osType: Abi.OS.NotWindows, bitness: Abi.Bitness.ThirtyTwo); - public static readonly HashSet All64BitHostAotAbis = Abi.GetHostAotAbis (osType: Abi.OS.NotWindows, bitness: Abi.Bitness.SixtyFour); - - public static readonly HashSet AllWindowsAotAbis = Abi.GetHostAotAbis (osType: Abi.OS.Windows); - public static readonly HashSet All32BitWindowsAotAbis = Abi.GetHostAotAbis (osType: Abi.OS.Windows, bitness: Abi.Bitness.ThirtyTwo); - public static readonly HashSet All64BitWindowsAotAbis = Abi.GetHostAotAbis (osType: Abi.OS.Windows, bitness: Abi.Bitness.SixtyFour); - - public static readonly HashSet AllTargetAotAbis = Abi.GetHostAotAbis (); - public static readonly HashSet All64BitTargetAotAbis = Abi.GetHostAotAbis (osType: Abi.OS.Any, bitness: Abi.Bitness.SixtyFour); - public static readonly HashSet All32BitTargetAotAbis = Abi.GetHostAotAbis (osType: Abi.OS.Any, bitness: Abi.Bitness.ThirtyTwo); - - public static readonly HashSet AllCrossHostAotAbis = Abi.GetCrossAbis (osType: Abi.OS.NotWindows); - public static readonly HashSet AllCrossWindowsAotAbis = Abi.GetCrossAbis (osType: Abi.OS.Windows); - public static readonly HashSet All64BitCrossAotAbis = Abi.GetCrossAbis (bitness: Abi.Bitness.SixtyFour); - public static readonly HashSet All32BitCrossAotAbis = Abi.GetCrossAbis (bitness: Abi.Bitness.ThirtyTwo); - - public static readonly HashSet AllMingwHostAbis = Abi.GetHostAbis (osType: Abi.OS.Windows); - public static readonly HashSet All32BitMingwHostAbis = Abi.GetHostAbis (osType: Abi.OS.Windows, bitness: Abi.Bitness.ThirtyTwo); - public static readonly HashSet All64BitMingwHostAbis = Abi.GetHostAbis (osType: Abi.OS.Windows, bitness: Abi.Bitness.SixtyFour); - - public static void LogAllNames (Context context) - { - if (context.LoggingVerbosity < LoggingVerbosity.Verbose) - return; - - Log.Instance.DebugLine ("All defined ABI names:"); - - LogAbis (context, "AllHostAbis", AllHostAbis); - LogAbis (context, "AllNativeHostAbis", AllNativeHostAbis); - - LogAbis (context, "AllLlvmHostAbis", AllLlvmHostAbis); - LogAbis (context, "AllLlvmWindowsAbis", AllLlvmWindowsAbis); - LogAbis (context, "All32BitLlvmAbis", All32BitLlvmAbis); - LogAbis (context, "All64BitLlvmAbis", All64BitLlvmAbis); - - LogAbis (context, "AllJitAbis", AllJitAbis); - LogAbis (context, "All32BitTargetJitAbis", All32BitTargetJitAbis); - LogAbis (context, "All64BitTargetJitAbis", All64BitTargetJitAbis); - - LogAbis (context, "AllHostAotAbis", AllHostAotAbis); - LogAbis (context, "All32BitHostAotAbis", All32BitHostAotAbis); - LogAbis (context, "All64BitHostAotAbis", All64BitHostAotAbis); - - LogAbis (context, "AllWindowsAotAbis", AllWindowsAotAbis); - LogAbis (context, "All32BitWindowsAotAbis", All32BitWindowsAotAbis); - LogAbis (context, "All64BitWindowsAotAbis", All64BitWindowsAotAbis); - LogAbis (context, "All64BitTargetAotAbis", All64BitTargetAotAbis); - LogAbis (context, "All32BitTargetAotAbis", All32BitTargetAotAbis); - - LogAbis (context, "AllCrossHostAotAbis", AllCrossHostAotAbis); - LogAbis (context, "AllCrossWindowsAotAbis", AllCrossWindowsAotAbis); - LogAbis (context, "All64BitCrossAotAbis", All64BitCrossAotAbis); - LogAbis (context, "All32BitCrossAotAbis", All32BitCrossAotAbis); - - LogAbis (context, "AllMingwHostAbis", AllMingwHostAbis); - LogAbis (context, "All32BitMingwHostAbis", All32BitMingwHostAbis); - LogAbis (context, "All64BitMingwHostAbis", All64BitMingwHostAbis); - } - - static void LogAbis (Context context, string name, HashSet abis) - { - Log.Instance.DebugLine ($" {context.Characters.Bullet} {name}"); - foreach (string abi in abis) { - Log.Instance.DebugLine ($" {abi}"); - } - Log.Instance.DebugLine (); - } - - public static string AbiToRuntimeIdentifier (string androidAbi) - { - if (androidAbi == TargetJit.AndroidArmV7a) { - return "android-arm"; - } else if (androidAbi == TargetJit.AndroidArmV8a) { - return "android-arm64"; - } else if (androidAbi == TargetJit.AndroidX86) { - return "android-x86"; - } else if (androidAbi == TargetJit.AndroidX86_64) { - return "android-x64"; - } - throw new InvalidOperationException ($"Unknown abi: {androidAbi}"); - } - } -} diff --git a/build-tools/xaprepare/xaprepare/ConfigAndData/BuildAndroidPlatforms.cs b/build-tools/xaprepare/xaprepare/ConfigAndData/BuildAndroidPlatforms.cs index 24675bcba58..506a56b25e4 100644 --- a/build-tools/xaprepare/xaprepare/ConfigAndData/BuildAndroidPlatforms.cs +++ b/build-tools/xaprepare/xaprepare/ConfigAndData/BuildAndroidPlatforms.cs @@ -47,12 +47,5 @@ class BuildAndroidPlatforms new AndroidPlatform (apiName: "UpsideDownCake", apiLevel: 34, platformID: "34", include: "v14.0", framework: "v14.0"), }; - public static readonly Dictionary NdkMinimumAPIMap = new Dictionary { - { AbiNames.TargetJit.AndroidArmV7a, NdkMinimumAPILegacy32 }, - { AbiNames.TargetJit.AndroidArmV8a, NdkMinimumAPI }, - { AbiNames.TargetJit.AndroidX86, NdkMinimumAPILegacy32 }, - { AbiNames.TargetJit.AndroidX86_64, NdkMinimumAPI }, - }; - } } diff --git a/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.MacOS.cs b/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.MacOS.cs index 4e7c41133a7..9e277a90aad 100644 --- a/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.MacOS.cs +++ b/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.MacOS.cs @@ -13,18 +13,13 @@ partial class Configurables partial class Defaults { - public const string MacOSDeploymentTarget = "10.11"; public const string NativeLibraryExtension = ".dylib"; } partial class Paths { - const string LibMonoSgenBaseName = "libmonosgen-2.0"; - public const string MonoCrossRuntimeInstallPath = "Darwin"; public const string NdkToolchainOSTag = "darwin-x86_64"; - public static readonly string UnstrippedLibMonoSgenName = $"{LibMonoSgenBaseName}.d{Defaults.NativeLibraryExtension}"; - public static readonly string StrippedLibMonoSgenName = $"{LibMonoSgenBaseName}{Defaults.NativeLibraryExtension}"; } } } diff --git a/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.Unix.cs b/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.Unix.cs index 148b8b003bd..4c02c008f8c 100644 --- a/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.Unix.cs +++ b/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.Unix.cs @@ -13,17 +13,6 @@ partial class Defaults public const string DefaultCompiler = "cc"; } - partial class Paths - { - static string ArchiveOSType => Context.Instance.OS.Type; - - public static string HostRuntimeDir => GetCachedPath (ref hostRuntimeDir, () => Path.Combine (XAInstallPrefix, "xbuild", "Xamarin", "Android", "lib", $"host-{ctx.OS.Type}")); - - public static readonly string MonoRuntimeHostMingwNativeLibraryPrefix = Path.Combine ("..", "bin"); - - static string? hostRuntimeDir; - } - partial class Urls { public static readonly Uri DotNetInstallScript = new Uri ("https://dot.net/v1/dotnet-install.sh"); diff --git a/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.Windows.cs b/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.Windows.cs index be13e5f6c3f..cf20faf3d1f 100644 --- a/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.Windows.cs +++ b/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.Windows.cs @@ -21,9 +21,6 @@ partial class Defaults partial class Paths { - static string ArchiveOSType => "Darwin"; // Windows need sources from there - public const string MonoCrossRuntimeInstallPath = "Windows"; - public static readonly string MonoRuntimeHostMingwNativeLibraryPrefix = Path.Combine ("..", "bin"); public const string NdkToolchainOSTag = "windows-x86_64"; } diff --git a/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs b/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs index cb86460ba07..3d830c8f3c7 100644 --- a/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs +++ b/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs @@ -71,7 +71,6 @@ public static partial class Defaults // Mono runtimes public const string DebugFileExtension = ".pdb"; - public const string MonoHostMingwRuntimeNativeLibraryExtension = WindowsDLLSuffix; public const string MonoJitRuntimeNativeLibraryExtension = ".so"; public const string MonoRuntimeOutputMonoBtlsFilename = "libmono-btls-shared"; public const string MonoRuntimeOutputMonoPosixHelperFilename = "libMonoPosixHelper"; @@ -159,42 +158,10 @@ public static partial class Defaults public const string HashAlgorithm = "SHA1"; public static readonly Dictionary AndroidToolchainPrefixes = new Dictionary (StringComparer.Ordinal) { - { AbiNames.TargetJit.AndroidArmV7a, "arm-linux-androideabi" }, - { AbiNames.TargetJit.AndroidArmV8a, "aarch64-linux-android" }, - { AbiNames.TargetJit.AndroidX86, "i686-linux-android" }, - { AbiNames.TargetJit.AndroidX86_64, "x86_64-linux-android" }, - }; - - const string CrossArmV7aName = "cross-arm"; - const string CrossArmV8aName = "cross-arm64"; - const string CrossX86Name = "cross-x86"; - const string CrossX86_64Name = "cross-x86_64"; - - public static readonly Dictionary CrossRuntimeNames = new Dictionary (StringComparer.Ordinal) { - { AbiNames.CrossAot.ArmV7a, CrossArmV7aName }, - { AbiNames.CrossAot.ArmV8a, CrossArmV8aName }, - { AbiNames.CrossAot.X86, CrossX86Name }, - { AbiNames.CrossAot.X86_64, CrossX86_64Name }, - { AbiNames.CrossAot.WinArmV7a, CrossArmV7aName }, - { AbiNames.CrossAot.WinArmV8a, CrossArmV8aName }, - { AbiNames.CrossAot.WinX86, CrossX86Name }, - { AbiNames.CrossAot.WinX86_64, CrossX86_64Name }, - }; - - const string ArmV7aPrefix = "armv7-linux-android-"; - const string ArmV8aPrefix = "aarch64-v8a-linux-android-"; - const string X86Prefix = "i686-linux-android-"; - const string X86_64Prefix = "x86_64-linux-android-"; - - public static readonly Dictionary CrossRuntimeExePrefixes = new Dictionary (StringComparer.Ordinal) { - { AbiNames.CrossAot.ArmV7a, ArmV7aPrefix}, - { AbiNames.CrossAot.ArmV8a, ArmV8aPrefix }, - { AbiNames.CrossAot.X86, X86Prefix }, - { AbiNames.CrossAot.X86_64, X86_64Prefix }, - { AbiNames.CrossAot.WinArmV7a, ArmV7aPrefix }, - { AbiNames.CrossAot.WinArmV8a, ArmV8aPrefix }, - { AbiNames.CrossAot.WinX86, X86Prefix }, - { AbiNames.CrossAot.WinX86_64, X86_64Prefix }, + { "armeabi-v7a", "arm-linux-androideabi" }, + { "arm64-v8a", "aarch64-linux-android" }, + { "x86", "i686-linux-android" }, + { "x86_64", "x86_64-linux-android" }, }; /// @@ -242,65 +209,16 @@ public static partial class Paths public static readonly string ExternalGitDepsFilePath = Path.Combine (BuildPaths.XamarinAndroidSourceRoot, ".external"); public static readonly string ExternalGitDepsDestDir = ExternalDir; public static readonly string ExternalXamarinAndroidToolsSln = Path.Combine (ExternalDir, "xamarin-android-tools", "Xamarin.Android.Tools.sln"); - public static readonly string MxeSourceDir = Path.Combine (ExternalDir, "mxe"); - public static readonly string MonoSDKSRelativeOutputDir = Path.Combine ("sdks", "out"); - public static readonly string MonoSDKRelativeIncludeSourceDir = Path.Combine ("include", "mono-2.0", "mono"); - public static readonly string RuntimeInstallRelativeLibDir = "lib"; - public static readonly string PackageImageDependenciesTemplate = Path.Combine (BuildToolsScriptsDir, "prepare-image-dependencies.sh.in"); - public static readonly string PackageImageDependenciesOutput = Path.Combine (BuildPaths.XamarinAndroidSourceRoot, "prepare-image-dependencies.sh"); // Dynamic locations used throughout the code public static string ExternalJavaInteropDir => GetCachedPath (ref externalJavaInteropDir, () => ctx.Properties.GetRequiredValue (KnownProperties.JavaInteropFullPath)); - public static string MonoSDKSOutputDir => GetCachedPath (ref monoSDKsOutputDir, () => Path.Combine (MonoSourceFullPath, MonoSDKSRelativeOutputDir)); - public static string MonoProfileDir => GetCachedPath (ref monoProfileDir, () => Path.Combine (MonoSDKSOutputDir, "android-bcl", "monodroid")); - public static string MonoProfileToolsDir => GetCachedPath (ref monoProfileToolsDir, () => Path.Combine (MonoSDKSOutputDir, "android-bcl", "monodroid_tools")); - public static string MonoSDKIncludeDestinationDir => GetCachedPath (ref monoSDKSIncludeDestDir, () => Path.Combine (OutputIncludeDir, "mono-2.0", "mono")); - - public static string BCLFacadeAssembliesSourceDir => GetCachedPath (ref bclFacadeAssembliesSourceDir, () => Path.Combine (BCLAssembliesSourceDir, "Facades")); - public static string BCLHostAssembliesSourceDir => BCLAssembliesSourceDir; - public static string BCLHostFacadeAssembliesSourceDir => BCLFacadeAssembliesSourceDir; - - public static string BCLWindowsOutputDir => GetCachedPath (ref bclWindowsOutputDir, () => Path.Combine (BuildBinDir, "windows-bcl")); - public static string BCLWindowsAssembliesSourceDir => GetCachedPath (ref bclWindowsAssembliesSourceDir, () => Path.Combine (BCLWindowsOutputDir, "android-bcl", "monodroid")); - public static string BCLWindowsFacadeAssembliesSourceDir => GetCachedPath (ref bclWindowsFacadeAssembliesSourceDir, () => Path.Combine (BCLWindowsAssembliesSourceDir, "Facades")); - - public static string BCLAssembliesSourceDir => MonoProfileDir; - - public static string BCLTestsSourceDir => GetCachedPath (ref bclTestsSourceDir, () => Path.Combine (MonoProfileDir, "tests")); - - public static string BCLTestsDestDir => GetCachedPath (ref bclTestsDestDir, () => Path.Combine (XAInstallPrefix, "..", "..", "bcl-tests")); - public static string BCLTestsArchivePath => GetCachedPath (ref bclTestsArchivePath, () => Path.Combine (BCLTestsDestDir, BCLTestsArchiveName)); - public static string TestBinDir => GetCachedPath (ref testBinDir, () => Path.Combine (Configurables.Paths.BinDirRoot, $"Test{ctx.Configuration}")); public static string BinDir => GetCachedPath (ref binDir, () => Path.Combine (Configurables.Paths.BinDirRoot, ctx.Configuration)); public static string BuildBinDir => GetCachedPath (ref buildBinDir, () => Path.Combine (Configurables.Paths.BinDirRoot, $"Build{ctx.Configuration}")); - public static string MingwBinDir => GetCachedPath (ref mingwBinDir, () => Path.Combine (ctx.Properties.GetRequiredValue (KnownProperties.AndroidMxeFullPath), "bin")); - public static string ProfileAssembliesProjitemsPath => GetCachedPath (ref profileAssembliesProjitemsPath, () => Path.Combine (BuildBinDir, "ProfileAssemblies.projitems")); public static string ConfigurationPropsGeneratedPath => GetCachedPath (ref configurationPropsGeneratedPath, () => Path.Combine (BuildBinDir, "Configuration.Generated.props")); - - // Mono Runtimes public static string MonoAndroidFrameworksSubDir = Path.Combine ("xbuild-frameworks", "MonoAndroid"); public static string MonoAndroidFrameworksRootDir => GetCachedPath (ref monoAndroidFrameworksRootDir, () => Path.Combine (XAInstallPrefix, MonoAndroidFrameworksSubDir)); - public static string InstallBCLFrameworkDir => GetCachedPath (ref installBCLFrameworkDir, () => Path.Combine (MonoAndroidFrameworksRootDir, "v1.0")); - public static string InstallBCLFrameworkFacadesDir => GetCachedPath (ref installBCLFrameworkFacadesDir, () => Path.Combine (InstallBCLFrameworkDir, "Facades")); - public static string InstallBCLFrameworkRedistListDir => GetCachedPath (ref installBCLFrameworkRedistListDir, () => Path.Combine (InstallBCLFrameworkDir, "RedistList")); - - public static string InstallBCLDesignerDir => GetCachedPath (ref installBCLDesignerDir, () => Path.Combine (XAInstallPrefix, "xbuild", "Xamarin", "Android")); - public static string InstallHostBCLDir => GetCachedPath (ref installHostBCLDir, () => Path.Combine (InstallBCLDesignerDir, ctx.OS.Type, "bcl")); - public static string InstallHostBCLFacadesDir => GetCachedPath (ref installHostBCLFacadesDir, () => Path.Combine (InstallBCLDesignerDir, ctx.OS.Type, "bcl", "Facades")); - public static string InstallWindowsBCLDir => GetCachedPath (ref installWindowsBCLDir, () => Path.Combine (InstallBCLDesignerDir, "bcl")); - public static string InstallWindowsBCLFacadesDir => GetCachedPath (ref installWindowsBCLFacadesDir, () => Path.Combine (InstallBCLDesignerDir, "bcl", "Facades")); - public static string InstallMSBuildDir => GetCachedPath (ref installMSBuildDir, () => ctx.Properties.GetRequiredValue (KnownProperties.MicrosoftAndroidSdkOutDir)); - public static string OutputIncludeDir => GetCachedPath (ref outputIncludeDir, () => Path.Combine (BinDirRoot, ctx.Configuration, "include")); - public static string MonoRuntimesEnabledAbisCachePath => GetCachedPath (ref monoRuntimesEnabledAbisCachePath, () => Path.Combine (BuildBinDir, "mono-runtimes-abi.cache")); - public static string FrameworkListInstallPath => GetCachedPath (ref frameworkListInstallPath, () => Path.Combine (InstallBCLFrameworkRedistListDir, "FrameworkList.xml")); - - // Cmake + MinGW - public static string Mingw32CmakeTemplatePath => GetCachedPath (ref mingw32CmakeTemplatePath, () => Path.Combine (BuildToolsScriptsDir, "mingw-32.cmake.in")); - public static string Mingw64CmakeTemplatePath => GetCachedPath (ref mingw64CmakeTemplatePath, () => Path.Combine (BuildToolsScriptsDir, "mingw-64.cmake.in")); - public static string Mingw32CmakePath => GetCachedPath (ref mingw32CmakePath, () => Path.Combine (BuildBinDir, "mingw-32.cmake")); - public static string Mingw64CmakePath => GetCachedPath (ref mingw64CmakePath, () => Path.Combine (BuildBinDir, "mingw-64.cmake")); // AdoptOpenJDK public static string OldOpenJDKInstallDir => GetCachedPath (ref oldOpenJDKInstallDir, () => Path.Combine (ctx.Properties.GetRequiredValue (KnownProperties.AndroidToolchainDirectory), "jdk")); @@ -309,17 +227,6 @@ public static partial class Paths public static string OpenJDK17InstallDir => GetCachedPath (ref openJDK17InstallDir, () => Path.Combine (ctx.Properties.GetRequiredValue (KnownProperties.AndroidToolchainDirectory), "jdk-17")); public static string OpenJDK17CacheDir => GetCachedPath (ref openJDK17CacheDir, () => ctx.Properties.GetRequiredValue (KnownProperties.AndroidToolchainCacheDirectory)); - // bundle - public static string BCLTestsArchiveName = "bcl-tests.zip"; - - // Mono Archive - public static string MonoArchiveMonoHash => ctx.BuildInfo.FullMonoHash; - public static string MonoArchiveBaseFileName => $"android-{Defaults.MonoSdksConfiguration}-{ArchiveOSType}-{MonoArchiveMonoHash}"; - public static string MonoArchiveWindowsBaseFileName => $"android-release-Windows-{MonoArchiveMonoHash}"; - public static string MonoArchiveFileName => $"{MonoArchiveBaseFileName}.7z"; - public static string MonoArchiveWindowsFileName => $"{MonoArchiveWindowsBaseFileName}.7z"; - public static string MonoArchiveLocalPath => Path.Combine (ctx.Properties.GetRequiredValue (KnownProperties.AndroidToolchainCacheDirectory), MonoArchiveFileName); - public static string MonoArchiveWindowsLocalPath => Path.Combine (ctx.Properties.GetRequiredValue (KnownProperties.AndroidToolchainCacheDirectory), MonoArchiveWindowsFileName); // .NET 6 public static string NetcoreAppRuntimeAndroidARM => GetCachedPath (ref netcoreAppRuntimeAndroidARM, () => GetNetcoreAppRuntimePath (ctx, "arm")); @@ -360,13 +267,6 @@ public static partial class Paths // not really configurables, merely convenience aliases for more frequently used paths that come from properties public static string XAInstallPrefix => ctx.Properties.GetRequiredValue (KnownProperties.XAInstallPrefix); public static string XAPackagesDir = DetermineNugetPackagesDir (ctx); - public static string MonoSourceFullPath => ctx.Properties.GetRequiredValue (KnownProperties.MonoSourceFullPath); - public static string MonoSdksTpnPath => GetCachedPath (ref monoSdksTpnPath, () => Path.Combine (MonoSDKSOutputDir, "android-tpn")); - public static string MonoSdksTpnExternalPath => GetCachedPath (ref monoSdksTpnExternalPath, () => Path.Combine (MonoSdksTpnPath, "external")); - public static string MonoLlvmTpnPath => GetCachedPath (ref monoLlvmTpnPath, () => { - var path = Path.Combine (MonoSdksTpnExternalPath, "llvm-project", "llvm"); - return Directory.Exists (path) ? path : Path.Combine (MonoSdksTpnExternalPath, "llvm"); - }); static string GetNetcoreAppRuntimePath (Context ctx, string androidTarget) { @@ -410,44 +310,13 @@ static string GetCachedPath (ref string? variable, Func creator) static string? testBinDir; static string? buildBinDir; - static string? mingwBinDir; static string? binDir; - static string? monoSDKsOutputDir; static string? androidToolchainRootDirectory; static string? androidToolchainBinDirectory; static string? androidToolchainSysrootLibDirectory; - static string? monoProfileDir; - static string? monoProfileToolsDir; - static string? bclTestsDestDir; - static string? bclTestsArchivePath; - static string? bclFacadeAssembliesSourceDir; - static string? bclWindowsOutputDir; - static string? bclWindowsAssembliesSourceDir; - static string? bclWindowsFacadeAssembliesSourceDir; - static string? installBCLFrameworkDir; - static string? installBCLFrameworkFacadesDir; - static string? installBCLFrameworkRedistListDir; static string? installMSBuildDir; - static string? outputIncludeDir; - static string? mingw32CmakePath; - static string? mingw64CmakePath; - static string? mingw32CmakeTemplatePath; - static string? mingw64CmakeTemplatePath; - static string? monoRuntimesEnabledAbisCachePath; - static string? frameworkListInstallPath; - static string? profileAssembliesProjitemsPath; - static string? bclTestsSourceDir; - static string? installHostBCLDir; - static string? installHostBCLFacadesDir; - static string? installWindowsBCLDir; - static string? installWindowsBCLFacadesDir; - static string? installBCLDesignerDir; static string? monoAndroidFrameworksRootDir; static string? externalJavaInteropDir; - static string? monoSdksTpnPath; - static string? monoSdksTpnExternalPath; - static string? monoSDKSIncludeDestDir; - static string? monoLlvmTpnPath; static string? openJDK8InstallDir, openJDK17InstallDir; static string? openJDK8CacheDir, openJDK17CacheDir; static string? oldOpenJDKInstallDir; diff --git a/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/Linux.DebianCommon.cs b/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/Linux.DebianCommon.cs index a37e9ff3217..7a7a7d1bdd7 100644 --- a/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/Linux.DebianCommon.cs +++ b/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/Linux.DebianCommon.cs @@ -16,11 +16,8 @@ abstract class LinuxDebianCommon : Linux new DebianLinuxProgram ("devscripts"), new DebianLinuxProgram ("gcc"), new DebianLinuxProgram ("g++"), - new DebianLinuxProgram ("g++-mingw-w64"), - new DebianLinuxProgram ("gcc-mingw-w64"), new DebianLinuxProgram ("git"), new DebianLinuxProgram ("libtool"), - new DebianLinuxProgram ("libz-mingw-w64-dev"), new DebianLinuxProgram ("linux-libc-dev"), new DebianLinuxProgram ("make"), new DebianLinuxProgram ("ninja-build", "ninja"), diff --git a/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/MacOS.cs b/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/MacOS.cs index 3abffca7d40..99e0b4114d4 100644 --- a/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/MacOS.cs +++ b/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/MacOS.cs @@ -20,10 +20,6 @@ partial class MacOS }, }; - static readonly HomebrewProgram mingw = new HomebrewProgram ("mingw-w64") { - MinimumVersion = "7.0.0_2", - }; - static readonly HomebrewProgram git = new HomebrewProgram ("git") { MinimumVersion = "2.20.0", }; @@ -31,8 +27,6 @@ partial class MacOS protected override void InitializeDependencies () { Dependencies.AddRange (programs); - if (!Context.Instance.NoMingwW64) - Dependencies.Add (mingw); // Allow using git from $PATH if it has the right version (bool success, string bv) = Utilities.GetProgramVersion (git.Name); diff --git a/build-tools/xaprepare/xaprepare/ConfigAndData/Runtimes.Code.cs b/build-tools/xaprepare/xaprepare/ConfigAndData/Runtimes.Code.cs deleted file mode 100644 index 938a9d2ba1c..00000000000 --- a/build-tools/xaprepare/xaprepare/ConfigAndData/Runtimes.Code.cs +++ /dev/null @@ -1,248 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; - -namespace Xamarin.Android.Prepare -{ - partial class Runtimes - { - static Context ctx => Context.Instance; - - static string GetMonoUtilitySourcePath (string utilityName) - { - return Path.Combine (Configurables.Paths.MonoProfileToolsDir, utilityName); - } - - static string GetLlvmOutputSourcePath (Runtime runtime) - { - var llvmRuntime = EnsureRuntimeType (runtime, "LLVM"); - return Path.Combine (GetLlvmInputDir (runtime), "bin"); - } - - static string GetLlvmOutputDestinationPath (Runtime runtime) - { - var llvmRuntime = EnsureRuntimeType (runtime, "LLVM"); - return llvmRuntime.InstallPath; - } - - static string GetMonoPosixHelperOutputSourcePath (Runtime runtime) - { - var monoRuntime = EnsureRuntimeType (runtime, "Mono"); - return Path.Combine (GetAndroidInputLibDir (runtime), monoRuntime.NativeLibraryDirPrefix, $"{monoRuntime.OutputMonoPosixHelperFilename}{monoRuntime.NativeLibraryExtension}"); - } - - static string GetMonoPosixHelperOutputDestinationPath (Runtime runtime, bool debug) - { - var monoRuntime = EnsureRuntimeType (runtime, "Mono"); - return Path.Combine (GetRuntimeOutputDir (runtime), $"{monoRuntime.OutputMonoPosixHelperFilename}{GetDebugInfix (debug)}{monoRuntime.NativeLibraryExtension}"); - } - - static string GetMonoBtlsOutputSourcePath (Runtime runtime) - { - var monoRuntime = EnsureRuntimeType (runtime, "Mono"); - return Path.Combine (GetAndroidInputLibDir (runtime), monoRuntime.NativeLibraryDirPrefix, $"{monoRuntime.OutputMonoBtlsFilename}{monoRuntime.NativeLibraryExtension}"); - } - - static string GetMonoBtlsOutputDestinationPath (Runtime runtime, bool debug) - { - var monoRuntime = EnsureRuntimeType (runtime, "Mono"); - return Path.Combine (GetRuntimeOutputDir (runtime), $"{monoRuntime.OutputMonoBtlsFilename}{GetDebugInfix (debug)}{monoRuntime.NativeLibraryExtension}"); - } - - static string GetAotProfilerOutputSourcePath (Runtime runtime) - { - var monoRuntime = EnsureRuntimeType (runtime, "Mono"); - return Path.Combine (GetAndroidInputLibDir (runtime), monoRuntime.NativeLibraryDirPrefix, $"{monoRuntime.OutputAotProfilerFilename}{monoRuntime.NativeLibraryExtension}"); - } - - static string GetAotProfilerOutputDestinationPath (Runtime runtime, bool debug) - { - var monoRuntime = EnsureRuntimeType (runtime, "Mono"); - return Path.Combine (GetRuntimeOutputDir (runtime), $"{monoRuntime.OutputAotProfilerFilename}{GetDebugInfix (debug)}{monoRuntime.NativeLibraryExtension}"); - } - - static string GetProfilerOutputSourcePath (Runtime runtime) - { - var monoRuntime = EnsureRuntimeType (runtime, "Mono"); - return Path.Combine (GetAndroidInputLibDir (runtime), monoRuntime.NativeLibraryDirPrefix, $"{monoRuntime.OutputProfilerFilename}{monoRuntime.NativeLibraryExtension}"); - } - - static string GetProfilerOutputDestinationPath (Runtime runtime, bool debug) - { - var monoRuntime = EnsureRuntimeType (runtime, "Mono"); - return Path.Combine (GetRuntimeOutputDir (runtime), $"{monoRuntime.OutputProfilerFilename}{GetDebugInfix (debug)}{monoRuntime.NativeLibraryExtension}"); - } - - static string GetCrossRuntimeOutputSourcePath (Runtime runtime) - { - var crossRuntime = EnsureRuntimeType (runtime, "cross compilation"); - return Path.Combine (MonoRuntimesHelpers.GetRootDir (runtime), "bin", $"{crossRuntime.ExePrefix}mono-sgen{crossRuntime.ExeSuffix}"); - } - - static string GetCrossRuntimeOutputDestinationPath (Runtime runtime, bool debug) - { - var crossRuntime = EnsureRuntimeType (runtime, "cross compilation"); - string runtimeName = $"{crossRuntime.CrossMonoName}{GetDebugInfix (debug)}{crossRuntime.ExeSuffix}"; - if (String.IsNullOrEmpty (crossRuntime.InstallPath)) - return runtimeName; - - return Path.Combine (crossRuntime.InstallPath, runtimeName); - } - - static string GetRuntimeOutputSourcePath (Runtime runtime) - { - var monoRuntime = EnsureRuntimeType (runtime, "Mono"); - return Path.Combine (GetAndroidInputLibDir (runtime), monoRuntime.NativeLibraryDirPrefix, $"{monoRuntime.OutputRuntimeFilename}{monoRuntime.NativeLibraryExtension}"); - } - - static string GetRuntimeOutputDestinationPath (Runtime runtime, bool debug) - { - var monoRuntime = EnsureRuntimeType (runtime, "Mono"); - return Path.Combine (GetRuntimeOutputDir (runtime), $"{monoRuntime.OutputRuntimeFilename}{GetDebugInfix (debug)}{monoRuntime.NativeLibraryExtension}"); - } - - static string GetMonoNativeOutputSourcePath (Runtime runtime) - { - var monoRuntime = EnsureRuntimeType (runtime, "Mono"); - if (IsAbi (runtime, AbiNames.HostJit.Darwin)) - return Path.Combine (GetAndroidInputLibDir (runtime), monoRuntime.NativeLibraryDirPrefix, $"libmono-native-compat{monoRuntime.NativeLibraryExtension}"); - - return Path.Combine (GetAndroidInputLibDir (runtime), monoRuntime.NativeLibraryDirPrefix, $"libmono-native{monoRuntime.NativeLibraryExtension}"); - } - - static string GetMonoNativeOutputDestinationPath (Runtime runtime, bool debug) - { - var monoRuntime = EnsureRuntimeType (runtime, "Mono"); - return Path.Combine (GetRuntimeOutputDir (runtime), $"libmono-native{GetDebugInfix (debug)}{monoRuntime.NativeLibraryExtension}"); - } - - static string GetDebugInfix (bool debug) - { - return debug ? Configurables.Defaults.DebugBinaryInfix : String.Empty; - } - - static bool IsHostOrTargetRuntime (Runtime runtime) - { - return IsRuntimeType (runtime) || IsRuntimeType (runtime); - } - - static T EnsureRuntimeType (Runtime runtime, string typeName) where T: Runtime - { - var ret = runtime.As (); - if (ret == null) - throw new InvalidOperationException ($"Runtime {runtime.Name} is not a {typeName} runtime"); - - return ret; - } - - static bool IsRuntimeType (Runtime runtime) where T: Runtime - { - return runtime.As() != null; - } - - static bool IsWindowsRuntime (Runtime runtime) - { - return String.Compare (runtime.ExeSuffix, Configurables.Defaults.WindowsExecutableSuffix, StringComparison.Ordinal) == 0; - } - - static bool IsAbi (Runtime runtime, string abiName, params string[] furtherAbiNames) - { - if (ExpectedAbi (abiName)) - return true; - - if (furtherAbiNames == null) - return false; - - foreach (string a in furtherAbiNames) { - if (ExpectedAbi (a)) - return true; - } - - return false; - - bool ExpectedAbi (string abi) - { - if (String.IsNullOrEmpty (abi)) - return false; - - return String.Compare (abi, runtime.Name ?? String.Empty, StringComparison.Ordinal) == 0; - } - } - - static string GetLlvmInputDir (Runtime runtime) - { - return GetLlvmInputRootDir (runtime); - } - - static string GetLlvmInputRootDir (Runtime runtime) - { - return Path.Combine (Configurables.Paths.MonoSDKSRelativeOutputDir, $"llvm-{runtime.PrefixedName}"); - } - - static string GetAndroidInputLibDir (Runtime runtime) - { - return Path.Combine (MonoRuntimesHelpers.GetRootDir (runtime), "lib"); - } - - static string GetRuntimeOutputDir (Runtime runtime) - { - return Path.Combine (Configurables.Paths.RuntimeInstallRelativeLibDir, runtime.PrefixedName); - } - - static bool IsLlvmRuntimeEnabled (Context ctx, string llvmAbi) - { - bool enabled = false; - bool windows = ctx.IsLlvmWindowsAbi (llvmAbi); - bool is64Bit = ctx.Is64BitLlvmAbi (llvmAbi); - - HashSet targets; - if (windows) - targets = is64Bit ? AbiNames.All64BitWindowsAotAbis : AbiNames.All32BitWindowsAotAbis; - else - targets = is64Bit ? AbiNames.All64BitHostAotAbis : AbiNames.All32BitHostAotAbis; - - foreach (string target in targets) { - if (Context.Instance.IsTargetAotAbiEnabled (target)) { - enabled = true; - break; - } - } - - return enabled && (!is64Bit || Context.Instance.OS.Is64Bit); - } - - public Runtimes () - { - Context c = ctx; - foreach (Runtime runtime in Items) { - runtime.Init (c); - } - - DesignerHostBclFilesToInstall = new List (); - DesignerWindowsBclFilesToInstall = new List (); - - PopulateDesignerBclFiles (DesignerHostBclFilesToInstall, DesignerWindowsBclFilesToInstall); - } - - List BclToDesigner (BclFileTarget ignoreForTarget) - { - return BclFilesToInstall.Where (bf => ShouldIncludeDesignerBcl (bf)).Select (bf => new BclFile (bf.Name, bf.Type, bf.ExcludeDebugSymbols, version: bf.Version, target: ignoreForTarget)).ToList (); - - bool ShouldIncludeDesignerBcl (BclFile bf) - { - if (DesignerIgnoreFiles == null || !DesignerIgnoreFiles.TryGetValue (bf.Name, out (BclFileType Type, BclFileTarget Target) bft)) { - return true; - } - - if (bf.Type != bft.Type || bft.Target != ignoreForTarget) - return true; - - Log.Instance.DebugLine ($"BCL file {bf.Name} will NOT be included in the installed Designer BCL files ({ignoreForTarget})"); - return false; - } - } - - partial void PopulateDesignerBclFiles (List designerHostBclFilesToInstall, List designerWindowsBclFilesToInstall); - } -} diff --git a/build-tools/xaprepare/xaprepare/ConfigAndData/Runtimes.Unix.cs b/build-tools/xaprepare/xaprepare/ConfigAndData/Runtimes.Unix.cs deleted file mode 100644 index 5bce3b9d360..00000000000 --- a/build-tools/xaprepare/xaprepare/ConfigAndData/Runtimes.Unix.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; - -namespace Xamarin.Android.Prepare -{ - partial class Runtimes - { - partial void PopulateDesignerBclFiles (List designerHostBclFilesToInstall, List designerWindowsBclFilesToInstall) - { - designerHostBclFilesToInstall.AddRange (BclToDesigner (BclFileTarget.DesignerHost)); - designerWindowsBclFilesToInstall.AddRange (BclToDesigner (BclFileTarget.DesignerWindows)); - } - } -} diff --git a/build-tools/xaprepare/xaprepare/ConfigAndData/Runtimes.Windows.cs b/build-tools/xaprepare/xaprepare/ConfigAndData/Runtimes.Windows.cs deleted file mode 100644 index 3740c880551..00000000000 --- a/build-tools/xaprepare/xaprepare/ConfigAndData/Runtimes.Windows.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; - -namespace Xamarin.Android.Prepare -{ - partial class Runtimes - { - partial void PopulateDesignerBclFiles (List designerHostBclFilesToInstall, List designerWindowsBclFilesToInstall) - { - designerWindowsBclFilesToInstall.AddRange (BclToDesigner (BclFileTarget.DesignerWindows)); - } - } -} diff --git a/build-tools/xaprepare/xaprepare/ConfigAndData/Runtimes.cs b/build-tools/xaprepare/xaprepare/ConfigAndData/Runtimes.cs deleted file mode 100644 index 92a0646928b..00000000000 --- a/build-tools/xaprepare/xaprepare/ConfigAndData/Runtimes.cs +++ /dev/null @@ -1,933 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; - -namespace Xamarin.Android.Prepare -{ - partial class Runtimes - { - public readonly List Items = new List { - new MonoJitRuntime ( - abiName: AbiNames.TargetJit.AndroidArmV7a, - interpreter: false, - enabledCheck: (Context ctx) => ctx.IsTargetJitAbiEnabled (AbiNames.TargetJit.AndroidArmV7a) - ), - - new MonoJitRuntime ( - abiName: AbiNames.TargetJit.AndroidArmV7a, - interpreter: true, - enabledCheck: (Context ctx) => ctx.IsTargetJitAbiEnabled (AbiNames.TargetJit.AndroidArmV7a) - ), - - new MonoJitRuntime ( - abiName: AbiNames.TargetJit.AndroidArmV8a, - interpreter: false, - enabledCheck: (Context ctx) => ctx.IsTargetJitAbiEnabled (AbiNames.TargetJit.AndroidArmV8a) - ), - - new MonoJitRuntime ( - abiName: AbiNames.TargetJit.AndroidArmV8a, - interpreter: true, - enabledCheck: (Context ctx) => ctx.IsTargetJitAbiEnabled (AbiNames.TargetJit.AndroidArmV8a) - ), - - new MonoJitRuntime ( - abiName: AbiNames.TargetJit.AndroidX86, - interpreter: false, - enabledCheck: (Context ctx) => ctx.IsTargetJitAbiEnabled (AbiNames.TargetJit.AndroidX86) - ), - - new MonoJitRuntime ( - abiName: AbiNames.TargetJit.AndroidX86, - interpreter: true, - enabledCheck: (Context ctx) => ctx.IsTargetJitAbiEnabled (AbiNames.TargetJit.AndroidX86) - ), - - new MonoJitRuntime ( - abiName: AbiNames.TargetJit.AndroidX86_64, - interpreter: false, - enabledCheck: (Context ctx) => ctx.IsTargetJitAbiEnabled (AbiNames.TargetJit.AndroidX86_64) - ), - - new MonoJitRuntime ( - abiName: AbiNames.TargetJit.AndroidX86_64, - interpreter: true, - enabledCheck: (Context ctx) => ctx.IsTargetJitAbiEnabled (AbiNames.TargetJit.AndroidX86_64) - ), - - new MonoHostRuntime ( - name: AbiNames.HostJit.Linux, - mingw: false, - enabledCheck: (Context ctx) => ctx.IsHostJitAbiEnabled (AbiNames.HostJit.Linux) - ), - - new MonoHostRuntime ( - name: AbiNames.HostJit.Darwin, - mingw: false, - enabledCheck: (Context ctx) => ctx.IsHostJitAbiEnabled (AbiNames.HostJit.Darwin) - ), - - new MonoHostRuntime ( - name: AbiNames.HostJit.Win32, - mingw: true, - enabledCheck: (Context ctx) => ctx.IsHostJitAbiEnabled (AbiNames.HostJit.Win32) - ), - - new MonoHostRuntime ( - name: AbiNames.HostJit.Win64, - mingw: true, - enabledCheck: (Context ctx) => ctx.IsHostJitAbiEnabled (AbiNames.HostJit.Win64) - ), - - new MonoCrossRuntime ( - name: AbiNames.CrossAot.ArmV7a, - enabledCheck: (Context ctx) => ctx.IsTargetAotAbiEnabled (AbiNames.TargetAot.ArmV7a) - ), - - new MonoCrossRuntime ( - name: AbiNames.CrossAot.ArmV8a, - enabledCheck: (Context ctx) => ctx.IsTargetAotAbiEnabled (AbiNames.TargetAot.ArmV8a) - ), - - new MonoCrossRuntime ( - name: AbiNames.CrossAot.X86, - enabledCheck: (Context ctx) => ctx.IsTargetAotAbiEnabled (AbiNames.TargetAot.X86) - ), - - new MonoCrossRuntime ( - name: AbiNames.CrossAot.X86_64, - enabledCheck: (Context ctx) => ctx.IsTargetAotAbiEnabled (AbiNames.TargetAot.X86_64) - ), - - new MonoCrossRuntime ( - name: AbiNames.CrossAot.WinArmV7a, - enabledCheck: (Context ctx) => ctx.IsTargetAotAbiEnabled (AbiNames.TargetAot.WinArmV7a) - ), - - new MonoCrossRuntime ( - name: AbiNames.CrossAot.WinArmV8a, - enabledCheck: (Context ctx) => ctx.IsTargetAotAbiEnabled (AbiNames.TargetAot.WinArmV8a) - ), - - new MonoCrossRuntime ( - name: AbiNames.CrossAot.WinX86, - enabledCheck: (Context ctx) => ctx.IsTargetAotAbiEnabled (AbiNames.TargetAot.WinX86) - ), - - new MonoCrossRuntime ( - name: AbiNames.CrossAot.WinX86_64, - enabledCheck: (Context ctx) => ctx.IsTargetAotAbiEnabled (AbiNames.TargetAot.WinX86_64) - ), - - new LlvmRuntime ( - name: AbiNames.Llvm.Host64Bit, - enabledCheck: (Context ctx) => IsLlvmRuntimeEnabled (ctx, AbiNames.Llvm.Host64Bit) - ), - - new LlvmRuntime ( - name: AbiNames.Llvm.Windows64Bit, - enabledCheck: (Context) => IsLlvmRuntimeEnabled (ctx, AbiNames.Llvm.Windows64Bit) - ), - }; - - public readonly List BclFilesToInstall = new List { - new BclFile ("I18N.dll", BclFileType.ProfileAssembly), - new BclFile ("I18N.CJK.dll", BclFileType.ProfileAssembly), - new BclFile ("I18N.MidEast.dll", BclFileType.ProfileAssembly), - new BclFile ("I18N.Other.dll", BclFileType.ProfileAssembly), - new BclFile ("I18N.Rare.dll", BclFileType.ProfileAssembly), - new BclFile ("I18N.West.dll", BclFileType.ProfileAssembly), - new BclFile ("Microsoft.CSharp.dll", BclFileType.ProfileAssembly), - new BclFile ("Mono.Btls.Interface.dll", BclFileType.ProfileAssembly), - new BclFile ("Mono.CompilerServices.SymbolWriter.dll", BclFileType.ProfileAssembly), - new BclFile ("Mono.CSharp.dll", BclFileType.ProfileAssembly), - new BclFile ("Mono.Data.Sqlite.dll", BclFileType.ProfileAssembly), - new BclFile ("Mono.Data.Tds.dll", BclFileType.ProfileAssembly), - new BclFile ("Mono.Posix.dll", BclFileType.ProfileAssembly), - new BclFile ("Mono.Security.dll", BclFileType.ProfileAssembly), - new BclFile ("mscorlib.dll", BclFileType.ProfileAssembly), - new BclFile ("System.dll", BclFileType.ProfileAssembly), - new BclFile ("System.ComponentModel.Composition.dll", BclFileType.ProfileAssembly), - new BclFile ("System.ComponentModel.DataAnnotations.dll", BclFileType.ProfileAssembly), - new BclFile ("System.Core.dll", BclFileType.ProfileAssembly), - new BclFile ("System.Data.dll", BclFileType.ProfileAssembly), - new BclFile ("System.Data.DataSetExtensions.dll", BclFileType.ProfileAssembly), - new BclFile ("System.Data.Services.Client.dll", BclFileType.ProfileAssembly), - new BclFile ("System.IdentityModel.dll", BclFileType.ProfileAssembly), - new BclFile ("System.IO.Compression.dll", BclFileType.ProfileAssembly), - new BclFile ("System.IO.Compression.FileSystem.dll", BclFileType.ProfileAssembly), - new BclFile ("System.Json.dll", BclFileType.ProfileAssembly), - new BclFile ("System.Net.dll", BclFileType.ProfileAssembly), - new BclFile ("System.Net.Http.dll", BclFileType.ProfileAssembly), - new BclFile ("System.Net.Http.WinHttpHandler.dll", BclFileType.ProfileAssembly), - new BclFile ("System.Numerics.dll", BclFileType.ProfileAssembly), - new BclFile ("System.Numerics.Vectors.dll", BclFileType.ProfileAssembly), - new BclFile ("System.Reflection.Context.dll", BclFileType.ProfileAssembly), - new BclFile ("System.Runtime.CompilerServices.Unsafe.dll", BclFileType.ProfileAssembly, excludeDebugSymbols: true), - new BclFile ("System.Runtime.Serialization.dll", BclFileType.ProfileAssembly), - new BclFile ("System.Security.dll", BclFileType.ProfileAssembly), - new BclFile ("System.ServiceModel.dll", BclFileType.ProfileAssembly), - new BclFile ("System.ServiceModel.Internals.dll", BclFileType.ProfileAssembly), - new BclFile ("System.ServiceModel.Web.dll", BclFileType.ProfileAssembly), - new BclFile ("System.Transactions.dll", BclFileType.ProfileAssembly), - new BclFile ("System.Web.Services.dll", BclFileType.ProfileAssembly), - new BclFile ("System.Windows.dll", BclFileType.ProfileAssembly, excludeDebugSymbols: true), - new BclFile ("System.Xml.dll", BclFileType.ProfileAssembly), - new BclFile ("System.Xml.Linq.dll", BclFileType.ProfileAssembly), - new BclFile ("System.Xml.Serialization.dll", BclFileType.ProfileAssembly, excludeDebugSymbols: true), - - new BclFile ("Microsoft.Win32.Primitives.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("Microsoft.Win32.Registry.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("Microsoft.Win32.Registry.AccessControl.dll", BclFileType.FacadeAssembly), - new BclFile ("netstandard.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.AppContext.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Buffers.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Collections.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Collections.Concurrent.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Collections.NonGeneric.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Collections.Specialized.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.ComponentModel.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.ComponentModel.Annotations.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.ComponentModel.EventBasedAsync.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.ComponentModel.Primitives.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.ComponentModel.TypeConverter.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Console.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Data.Common.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Data.SqlClient.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Diagnostics.Contracts.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Diagnostics.Debug.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Diagnostics.FileVersionInfo.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Diagnostics.Process.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Diagnostics.StackTrace.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Diagnostics.TextWriterTraceListener.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Diagnostics.Tools.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Diagnostics.TraceEvent.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Diagnostics.TraceSource.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Diagnostics.Tracing.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Drawing.Common.dll", BclFileType.FacadeAssembly), - new BclFile ("System.Drawing.Primitives.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Dynamic.Runtime.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Globalization.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Globalization.Calendars.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Globalization.Extensions.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.IO.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.IO.Compression.ZipFile.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.IO.FileSystem.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.IO.FileSystem.AccessControl.dll", BclFileType.FacadeAssembly), - new BclFile ("System.IO.FileSystem.DriveInfo.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.IO.FileSystem.Primitives.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.IO.FileSystem.Watcher.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.IO.IsolatedStorage.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.IO.MemoryMappedFiles.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.IO.Pipes.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.IO.UnmanagedMemoryStream.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Linq.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Linq.Expressions.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Linq.Parallel.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Linq.Queryable.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Memory.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Net.AuthenticationManager.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Net.Cache.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Net.HttpListener.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Net.Mail.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Net.NameResolution.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Net.NetworkInformation.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Net.Ping.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Net.Primitives.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Net.Requests.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Net.Security.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Net.ServicePoint.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Net.Sockets.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Net.Utilities.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Net.WebHeaderCollection.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Net.WebSockets.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Net.WebSockets.Client.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.ObjectModel.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Reflection.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Reflection.DispatchProxy.dll", BclFileType.FacadeAssembly), - new BclFile ("System.Reflection.Emit.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Reflection.Emit.ILGeneration.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Reflection.Emit.Lightweight.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Reflection.Extensions.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Reflection.Primitives.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Reflection.TypeExtensions.dll", BclFileType.FacadeAssembly), - new BclFile ("System.Resources.Reader.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Resources.ReaderWriter.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Resources.ResourceManager.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Resources.Writer.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Runtime.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Runtime.CompilerServices.VisualC.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Runtime.Extensions.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Runtime.Handles.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Runtime.InteropServices.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Runtime.InteropServices.RuntimeInformation.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Runtime.InteropServices.WindowsRuntime.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Runtime.Loader.dll", BclFileType.FacadeAssembly), - new BclFile ("System.Runtime.Numerics.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Runtime.Serialization.Formatters.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Runtime.Serialization.Json.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Runtime.Serialization.Primitives.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Runtime.Serialization.Xml.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Security.AccessControl.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Security.Claims.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Security.Cryptography.Algorithms.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Security.Cryptography.Cng.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Security.Cryptography.Csp.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Security.Cryptography.DeriveBytes.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Security.Cryptography.Encoding.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Security.Cryptography.Encryption.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Security.Cryptography.Encryption.Aes.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Security.Cryptography.Encryption.ECDiffieHellman.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Security.Cryptography.Encryption.ECDsa.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Security.Cryptography.Hashing.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Security.Cryptography.Hashing.Algorithms.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Security.Cryptography.OpenSsl.dll", BclFileType.FacadeAssembly), - new BclFile ("System.Security.Cryptography.Pkcs.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Security.Cryptography.Primitives.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Security.Cryptography.ProtectedData.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Security.Cryptography.RandomNumberGenerator.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Security.Cryptography.RSA.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Security.Cryptography.X509Certificates.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Security.Principal.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Security.Principal.Windows.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Security.SecureString.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.ServiceModel.Duplex.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.ServiceModel.Http.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.ServiceModel.NetTcp.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.ServiceModel.Primitives.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.ServiceModel.Security.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.ServiceProcess.ServiceController.dll", BclFileType.FacadeAssembly), - new BclFile ("System.Text.Encoding.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Text.Encoding.CodePages.dll", BclFileType.FacadeAssembly), - new BclFile ("System.Text.Encoding.Extensions.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Text.RegularExpressions.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Threading.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Threading.AccessControl.dll", BclFileType.FacadeAssembly), - new BclFile ("System.Threading.Overlapped.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Threading.Tasks.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Threading.Tasks.Extensions.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Threading.Tasks.Parallel.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Threading.Thread.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Threading.ThreadPool.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Threading.Timer.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.ValueTuple.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Xml.ReaderWriter.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Xml.XDocument.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Xml.XmlDocument.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Xml.XmlSerializer.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Xml.XPath.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Xml.XPath.XDocument.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - new BclFile ("System.Xml.XPath.XmlDocument.dll", BclFileType.FacadeAssembly), - new BclFile ("System.Xml.Xsl.Primitives.dll", BclFileType.FacadeAssembly, excludeDebugSymbols: true), - }; - - // These two are populated from BclFilesToInstall in the constructor - public readonly List DesignerHostBclFilesToInstall; - public readonly List DesignerWindowsBclFilesToInstall; - - public readonly List TestAssemblies = new List { - new TestAssembly ("BinarySerializationOverVersionsTest.dll", TestAssemblyType.NUnit), - new TestAssembly ("monodroid_corlib_test.dll", TestAssemblyType.NUnit), - new TestAssembly ("monodroid_corlib_xunit-test.dll", TestAssemblyType.XUnit), - new TestAssembly ("monodroid_I18N.CJK_test.dll", TestAssemblyType.NUnit), - new TestAssembly ("monodroid_I18N.MidEast_test.dll", TestAssemblyType.NUnit), - new TestAssembly ("monodroid_I18N.Other_test.dll", TestAssemblyType.NUnit), - new TestAssembly ("monodroid_I18N.Rare_test.dll", TestAssemblyType.NUnit), - new TestAssembly ("monodroid_I18N.West_test.dll", TestAssemblyType.NUnit), - new TestAssembly ("monodroid_Microsoft.CSharp_xunit-test.dll", TestAssemblyType.NUnit), - new TestAssembly ("monodroid_Mono.CSharp_test.dll", TestAssemblyType.NUnit), - new TestAssembly ("monodroid_Mono.Data.Sqlite_test.dll", TestAssemblyType.NUnit), - new TestAssembly ("monodroid_Mono.Data.Tds_test.dll", TestAssemblyType.NUnit), - new TestAssembly ("monodroid_Mono.Posix_test.dll", TestAssemblyType.NUnit), - new TestAssembly ("monodroid_Mono.Security_test.dll", TestAssemblyType.NUnit), - new TestAssembly ("monodroid_System.ComponentModel.Composition_xunit-test.dll", TestAssemblyType.XUnit), - new TestAssembly ("monodroid_System.ComponentModel.DataAnnotations_test.dll", TestAssemblyType.NUnit), - new TestAssembly ("monodroid_System.Core_test.dll", TestAssemblyType.NUnit), - new TestAssembly ("monodroid_System.Core_xunit-test.dll", TestAssemblyType.XUnit), - new TestAssembly ("monodroid_System.Data_test.dll", TestAssemblyType.NUnit), - new TestAssembly ("monodroid_System.Data_xunit-test.dll", TestAssemblyType.XUnit), - new TestAssembly ("monodroid_System.IO.Compression.FileSystem_test.dll", TestAssemblyType.NUnit), - new TestAssembly ("monodroid_System.IO.Compression_test.dll", TestAssemblyType.NUnit), - new TestAssembly ("monodroid_System.Json_test.dll", TestAssemblyType.NUnit), - new TestAssembly ("monodroid_System.Json_xunit-test.dll", TestAssemblyType.XUnit), - new TestAssembly ("monodroid_System.Net.Http_test.dll", TestAssemblyType.NUnit), - new TestAssembly ("monodroid_System.Net.Http.FunctionalTests_xunit-test.dll", TestAssemblyType.XUnit), - new TestAssembly ("monodroid_System.Net.Http.UnitTests_xunit-test.dll", TestAssemblyType.XUnit), - new TestAssembly ("monodroid_System.Numerics_test.dll", TestAssemblyType.NUnit), - new TestAssembly ("monodroid_System.Numerics_xunit-test.dll", TestAssemblyType.XUnit), - new TestAssembly ("monodroid_System.Runtime.CompilerServices.Unsafe_xunit-test.dll", TestAssemblyType.XUnit), - new TestAssembly ("monodroid_System.Runtime.Serialization_test.dll", TestAssemblyType.NUnit), - new TestAssembly ("monodroid_System.Runtime.Serialization_xunit-test.dll", TestAssemblyType.XUnit), - new TestAssembly ("monodroid_System.Security_test.dll", TestAssemblyType.NUnit), - new TestAssembly ("monodroid_System.Security_xunit-test.dll", TestAssemblyType.XUnit), - new TestAssembly ("monodroid_System.ServiceModel.Web_test.dll", TestAssemblyType.NUnit), - new TestAssembly ("monodroid_System.ServiceModel_test.dll", TestAssemblyType.NUnit), - new TestAssembly ("monodroid_System.Transactions_test.dll", TestAssemblyType.NUnit), - new TestAssembly ("monodroid_System.Web.Services_test.dll", TestAssemblyType.NUnit), - new TestAssembly ("monodroid_System.Xml.Linq_test.dll", TestAssemblyType.NUnit), - new TestAssembly ("monodroid_System.Xml.Linq_xunit-test.dll", TestAssemblyType.XUnit), - new TestAssembly ("monodroid_System.Xml_test.dll", TestAssemblyType.NUnit), - new TestAssembly ("monodroid_System.Xml_xunit-test.dll", TestAssemblyType.XUnit), - new TestAssembly ("monodroid_System_test.dll", TestAssemblyType.NUnit), - new TestAssembly ("monodroid_System_xunit-test.dll", TestAssemblyType.XUnit), - new TestAssembly ("System.Reflection.TestModule.dll", TestAssemblyType.NUnit, excludeDebugSymbols: true), - new TestAssembly ("TestLoadAssembly.dll", TestAssemblyType.NUnit), - - // Mono.CSharp testsuite dynamically loads Microsoft.CSharp - new TestAssembly ("Microsoft.CSharp.dll", TestAssemblyType.Reference), - - // This is referenced by monodroid_corlib_xunit-test.dll - new TestAssembly ("System.Runtime.CompilerServices.Unsafe.dll", TestAssemblyType.Reference, excludeDebugSymbols: true), - new TestAssembly ("Xunit.NetCore.Extensions.dll", TestAssemblyType.Satellite), - - // Satellite assemblies - new TestAssembly (Path.Combine ("es-ES", "monodroid_corlib_test.resources.dll"), TestAssemblyType.Satellite), - new TestAssembly (Path.Combine ("nn-NO", "monodroid_corlib_test.resources.dll"), TestAssemblyType.Satellite), - - // Other - new TestAssembly ("nunitlite.dll", TestAssemblyType.TestRunner), - }; - - public static readonly Dictionary FrameworkListVersionOverrides = new Dictionary (StringComparer.Ordinal) { - { "System.Buffers", "4.0.99.0" }, - { "System.Memory", "4.0.99.0" } - }; - - public static readonly string FrameworkListRedist = "MonoAndroid"; - public static readonly string FrameworkListName = "Xamarin.Android Base Class Libraries"; - - public readonly List UtilityFilesToInstall = new List { - new MonoUtilityFile ("mono-cil-strip.exe", targetName: "cil-strip.exe"), - new MonoUtilityFile ("illinkanalyzer.exe", remap: true), - new MonoUtilityFile ("mdoc.exe", remap: true), - new MonoUtilityFile ("mono-symbolicate.exe", remap: true), - new MonoUtilityFile ("mkbundle.exe", remap: true), - new MonoUtilityFile ("monodoc.dll"), - new MonoUtilityFile ("monodoc.dll.config", ignoreDebugInfo: true), - new MonoUtilityFile ("mono-api-html.exe", remap: true), - new MonoUtilityFile ("mono-api-info.exe", remap: true), - new MonoUtilityFile ("ICSharpCode.SharpZipLib.dll", remap: false), - new MonoUtilityFile ("Mono.CompilerServices.SymbolWriter.dll", remap: false), - new MonoUtilityFile ("aprofutil.exe", remap: false), - new MonoUtilityFile ("Mono.Profiler.Log.dll", remap: false), - }; - - /// - /// These are source:destination relative paths for source files we are to install. Sources are relative to - /// the mono submodule directory or absolute, while destinations are relative to or absolute. Note that the destination must include the - /// file name. - /// - public readonly List RuntimeFilesToInstall = new List { - new RuntimeFile ( - sourceCreator: (Runtime runtime) => Path.Combine (MonoRuntimesHelpers.GetRootDir (runtime), "share", "mono-2.0", "mono", "eglib", "eglib-config.h"), - destinationCreator: (Runtime runtime) => Path.Combine (Configurables.Paths.OutputIncludeDir, runtime.PrefixedName, "eglib", "eglib-config.h"), - shouldSkip: (Runtime runtime) => !IsHostOrTargetRuntime (runtime) - ), - - new RuntimeFile ( - sourceCreator: (Runtime runtime) => Path.Combine (MonoRuntimesHelpers.GetRootDir (runtime), Configurables.Paths.MonoSDKRelativeIncludeSourceDir, "cil", "opcode.def"), - destinationCreator: (Runtime runtime) => Path.Combine (Configurables.Paths.MonoSDKIncludeDestinationDir, "cil", "opcode.def"), - strip: false, - shared: true, - type: RuntimeFileType.SdkHeader - ), - - new RuntimeFile ( - sourceCreator: (Runtime runtime) => Path.Combine (MonoRuntimesHelpers.GetRootDir (runtime), Configurables.Paths.MonoSDKRelativeIncludeSourceDir, "jit", "jit.h"), - destinationCreator: (Runtime runtime) => Path.Combine (Configurables.Paths.MonoSDKIncludeDestinationDir, "jit", "jit.h"), - strip: false, - shared: true, - type: RuntimeFileType.SdkHeader - ), - - new RuntimeFile ( - sourceCreator: (Runtime runtime) => Path.Combine (MonoRuntimesHelpers.GetRootDir (runtime), Configurables.Paths.MonoSDKRelativeIncludeSourceDir, "metadata", "appdomain.h"), - destinationCreator: (Runtime runtime) => Path.Combine (Configurables.Paths.MonoSDKIncludeDestinationDir, "metadata", "appdomain.h"), - strip: false, - shared: true, - type: RuntimeFileType.SdkHeader - ), - - new RuntimeFile ( - sourceCreator: (Runtime runtime) => Path.Combine (MonoRuntimesHelpers.GetRootDir (runtime), Configurables.Paths.MonoSDKRelativeIncludeSourceDir, "metadata", "assembly.h"), - destinationCreator: (Runtime runtime) => Path.Combine (Configurables.Paths.MonoSDKIncludeDestinationDir, "metadata", "assembly.h"), - strip: false, - shared: true, - type: RuntimeFileType.SdkHeader - ), - - new RuntimeFile ( - sourceCreator: (Runtime runtime) => Path.Combine (MonoRuntimesHelpers.GetRootDir (runtime), Configurables.Paths.MonoSDKRelativeIncludeSourceDir, "metadata", "attrdefs.h"), - destinationCreator: (Runtime runtime) => Path.Combine (Configurables.Paths.MonoSDKIncludeDestinationDir, "metadata", "attrdefs.h"), - strip: false, - shared: true, - type: RuntimeFileType.SdkHeader - ), - - new RuntimeFile ( - sourceCreator: (Runtime runtime) => Path.Combine (MonoRuntimesHelpers.GetRootDir (runtime), Configurables.Paths.MonoSDKRelativeIncludeSourceDir, "metadata", "blob.h"), - destinationCreator: (Runtime runtime) => Path.Combine (Configurables.Paths.MonoSDKIncludeDestinationDir, "metadata", "blob.h"), - strip: false, - shared: true, - type: RuntimeFileType.SdkHeader - ), - - new RuntimeFile ( - sourceCreator: (Runtime runtime) => Path.Combine (MonoRuntimesHelpers.GetRootDir (runtime), Configurables.Paths.MonoSDKRelativeIncludeSourceDir, "metadata", "class.h"), - destinationCreator: (Runtime runtime) => Path.Combine (Configurables.Paths.MonoSDKIncludeDestinationDir, "metadata", "class.h"), - strip: false, - shared: true, - type: RuntimeFileType.SdkHeader - ), - - new RuntimeFile ( - sourceCreator: (Runtime runtime) => Path.Combine (MonoRuntimesHelpers.GetRootDir (runtime), Configurables.Paths.MonoSDKRelativeIncludeSourceDir, "metadata", "debug-helpers.h"), - destinationCreator: (Runtime runtime) => Path.Combine (Configurables.Paths.MonoSDKIncludeDestinationDir, "metadata", "debug-helpers.h"), - strip: false, - shared: true, - type: RuntimeFileType.SdkHeader - ), - - new RuntimeFile ( - sourceCreator: (Runtime runtime) => Path.Combine (MonoRuntimesHelpers.GetRootDir (runtime), Configurables.Paths.MonoSDKRelativeIncludeSourceDir, "metadata", "debug-mono-symfile.h"), - destinationCreator: (Runtime runtime) => Path.Combine (Configurables.Paths.MonoSDKIncludeDestinationDir, "metadata", "debug-mono-symfile.h"), - strip: false, - shared: true, - type: RuntimeFileType.SdkHeader - ), - - new RuntimeFile ( - sourceCreator: (Runtime runtime) => Path.Combine (MonoRuntimesHelpers.GetRootDir (runtime), Configurables.Paths.MonoSDKRelativeIncludeSourceDir, "metadata", "environment.h"), - destinationCreator: (Runtime runtime) => Path.Combine (Configurables.Paths.MonoSDKIncludeDestinationDir, "metadata", "environment.h"), - strip: false, - shared: true, - type: RuntimeFileType.SdkHeader - ), - - new RuntimeFile ( - sourceCreator: (Runtime runtime) => Path.Combine (MonoRuntimesHelpers.GetRootDir (runtime), Configurables.Paths.MonoSDKRelativeIncludeSourceDir, "metadata", "exception.h"), - destinationCreator: (Runtime runtime) => Path.Combine (Configurables.Paths.MonoSDKIncludeDestinationDir, "metadata", "exception.h"), - strip: false, - shared: true, - type: RuntimeFileType.SdkHeader - ), - - new RuntimeFile ( - sourceCreator: (Runtime runtime) => Path.Combine (MonoRuntimesHelpers.GetRootDir (runtime), Configurables.Paths.MonoSDKRelativeIncludeSourceDir, "metadata", "image.h"), - destinationCreator: (Runtime runtime) => Path.Combine (Configurables.Paths.MonoSDKIncludeDestinationDir, "metadata", "image.h"), - strip: false, - shared: true, - type: RuntimeFileType.SdkHeader - ), - - new RuntimeFile ( - sourceCreator: (Runtime runtime) => Path.Combine (MonoRuntimesHelpers.GetRootDir (runtime), Configurables.Paths.MonoSDKRelativeIncludeSourceDir, "metadata", "loader.h"), - destinationCreator: (Runtime runtime) => Path.Combine (Configurables.Paths.MonoSDKIncludeDestinationDir, "metadata", "loader.h"), - strip: false, - shared: true, - type: RuntimeFileType.SdkHeader - ), - - new RuntimeFile ( - sourceCreator: (Runtime runtime) => Path.Combine (MonoRuntimesHelpers.GetRootDir (runtime), Configurables.Paths.MonoSDKRelativeIncludeSourceDir, "metadata", "metadata.h"), - destinationCreator: (Runtime runtime) => Path.Combine (Configurables.Paths.MonoSDKIncludeDestinationDir, "metadata", "metadata.h"), - strip: false, - shared: true, - type: RuntimeFileType.SdkHeader - ), - - new RuntimeFile ( - sourceCreator: (Runtime runtime) => Path.Combine (MonoRuntimesHelpers.GetRootDir (runtime), Configurables.Paths.MonoSDKRelativeIncludeSourceDir, "metadata", "mono-config.h"), - destinationCreator: (Runtime runtime) => Path.Combine (Configurables.Paths.MonoSDKIncludeDestinationDir, "metadata", "mono-config.h"), - strip: false, - shared: true, - type: RuntimeFileType.SdkHeader - ), - - new RuntimeFile ( - sourceCreator: (Runtime runtime) => Path.Combine (MonoRuntimesHelpers.GetRootDir (runtime), Configurables.Paths.MonoSDKRelativeIncludeSourceDir, "metadata", "mono-debug.h"), - destinationCreator: (Runtime runtime) => Path.Combine (Configurables.Paths.MonoSDKIncludeDestinationDir, "metadata", "mono-debug.h"), - strip: false, - shared: true, - type: RuntimeFileType.SdkHeader - ), - - new RuntimeFile ( - sourceCreator: (Runtime runtime) => Path.Combine (MonoRuntimesHelpers.GetRootDir (runtime), Configurables.Paths.MonoSDKRelativeIncludeSourceDir, "metadata", "mono-gc.h"), - destinationCreator: (Runtime runtime) => Path.Combine (Configurables.Paths.MonoSDKIncludeDestinationDir, "metadata", "mono-gc.h"), - strip: false, - shared: true, - type: RuntimeFileType.SdkHeader - ), - - new RuntimeFile ( - sourceCreator: (Runtime runtime) => Path.Combine (MonoRuntimesHelpers.GetRootDir (runtime), Configurables.Paths.MonoSDKRelativeIncludeSourceDir, "metadata", "object-forward.h"), - destinationCreator: (Runtime runtime) => Path.Combine (Configurables.Paths.MonoSDKIncludeDestinationDir, "metadata", "object-forward.h"), - strip: false, - shared: true, - type: RuntimeFileType.SdkHeader - ), - - new RuntimeFile ( - sourceCreator: (Runtime runtime) => Path.Combine (MonoRuntimesHelpers.GetRootDir (runtime), Configurables.Paths.MonoSDKRelativeIncludeSourceDir, "metadata", "object.h"), - destinationCreator: (Runtime runtime) => Path.Combine (Configurables.Paths.MonoSDKIncludeDestinationDir, "metadata", "object.h"), - strip: false, - shared: true, - type: RuntimeFileType.SdkHeader - ), - - new RuntimeFile ( - sourceCreator: (Runtime runtime) => Path.Combine (MonoRuntimesHelpers.GetRootDir (runtime), Configurables.Paths.MonoSDKRelativeIncludeSourceDir, "metadata", "opcodes.h"), - destinationCreator: (Runtime runtime) => Path.Combine (Configurables.Paths.MonoSDKIncludeDestinationDir, "metadata", "opcodes.h"), - strip: false, - shared: true, - type: RuntimeFileType.SdkHeader - ), - - new RuntimeFile ( - sourceCreator: (Runtime runtime) => Path.Combine (MonoRuntimesHelpers.GetRootDir (runtime), Configurables.Paths.MonoSDKRelativeIncludeSourceDir, "metadata", "profiler-events.h"), - destinationCreator: (Runtime runtime) => Path.Combine (Configurables.Paths.MonoSDKIncludeDestinationDir, "metadata", "profiler-events.h"), - strip: false, - shared: true, - type: RuntimeFileType.SdkHeader - ), - - new RuntimeFile ( - sourceCreator: (Runtime runtime) => Path.Combine (MonoRuntimesHelpers.GetRootDir (runtime), Configurables.Paths.MonoSDKRelativeIncludeSourceDir, "metadata", "profiler.h"), - destinationCreator: (Runtime runtime) => Path.Combine (Configurables.Paths.MonoSDKIncludeDestinationDir, "metadata", "profiler.h"), - strip: false, - shared: true, - type: RuntimeFileType.SdkHeader - ), - - new RuntimeFile ( - sourceCreator: (Runtime runtime) => Path.Combine (MonoRuntimesHelpers.GetRootDir (runtime), Configurables.Paths.MonoSDKRelativeIncludeSourceDir, "metadata", "reflection.h"), - destinationCreator: (Runtime runtime) => Path.Combine (Configurables.Paths.MonoSDKIncludeDestinationDir, "metadata", "reflection.h"), - strip: false, - shared: true, - type: RuntimeFileType.SdkHeader - ), - - new RuntimeFile ( - sourceCreator: (Runtime runtime) => Path.Combine (MonoRuntimesHelpers.GetRootDir (runtime), Configurables.Paths.MonoSDKRelativeIncludeSourceDir, "metadata", "row-indexes.h"), - destinationCreator: (Runtime runtime) => Path.Combine (Configurables.Paths.MonoSDKIncludeDestinationDir, "metadata", "row-indexes.h"), - strip: false, - shared: true, - type: RuntimeFileType.SdkHeader - ), - - new RuntimeFile ( - sourceCreator: (Runtime runtime) => Path.Combine (MonoRuntimesHelpers.GetRootDir (runtime), Configurables.Paths.MonoSDKRelativeIncludeSourceDir, "metadata", "sgen-bridge.h"), - destinationCreator: (Runtime runtime) => Path.Combine (Configurables.Paths.MonoSDKIncludeDestinationDir, "metadata", "sgen-bridge.h"), - strip: false, - shared: true, - type: RuntimeFileType.SdkHeader - ), - - new RuntimeFile ( - sourceCreator: (Runtime runtime) => Path.Combine (MonoRuntimesHelpers.GetRootDir (runtime), Configurables.Paths.MonoSDKRelativeIncludeSourceDir, "metadata", "threads.h"), - destinationCreator: (Runtime runtime) => Path.Combine (Configurables.Paths.MonoSDKIncludeDestinationDir, "metadata", "threads.h"), - strip: false, - shared: true, - type: RuntimeFileType.SdkHeader - ), - - new RuntimeFile ( - sourceCreator: (Runtime runtime) => Path.Combine (MonoRuntimesHelpers.GetRootDir (runtime), Configurables.Paths.MonoSDKRelativeIncludeSourceDir, "metadata", "tokentype.h"), - destinationCreator: (Runtime runtime) => Path.Combine (Configurables.Paths.MonoSDKIncludeDestinationDir, "metadata", "tokentype.h"), - strip: false, - shared: true, - type: RuntimeFileType.SdkHeader - ), - - new RuntimeFile ( - sourceCreator: (Runtime runtime) => Path.Combine (MonoRuntimesHelpers.GetRootDir (runtime), Configurables.Paths.MonoSDKRelativeIncludeSourceDir, "metadata", "verify.h"), - destinationCreator: (Runtime runtime) => Path.Combine (Configurables.Paths.MonoSDKIncludeDestinationDir, "metadata", "verify.h"), - strip: false, - shared: true, - type: RuntimeFileType.SdkHeader - ), - - new RuntimeFile ( - sourceCreator: (Runtime runtime) => Path.Combine (MonoRuntimesHelpers.GetRootDir (runtime), Configurables.Paths.MonoSDKRelativeIncludeSourceDir, "utils", "mono-counters.h"), - destinationCreator: (Runtime runtime) => Path.Combine (Configurables.Paths.MonoSDKIncludeDestinationDir, "utils", "mono-counters.h"), - strip: false, - shared: true, - type: RuntimeFileType.SdkHeader - ), - - new RuntimeFile ( - sourceCreator: (Runtime runtime) => Path.Combine (MonoRuntimesHelpers.GetRootDir (runtime), Configurables.Paths.MonoSDKRelativeIncludeSourceDir, "utils", "mono-dl-fallback.h"), - destinationCreator: (Runtime runtime) => Path.Combine (Configurables.Paths.MonoSDKIncludeDestinationDir, "utils", "mono-dl-fallback.h"), - strip: false, - shared: true, - type: RuntimeFileType.SdkHeader - ), - - new RuntimeFile ( - sourceCreator: (Runtime runtime) => Path.Combine (MonoRuntimesHelpers.GetRootDir (runtime), Configurables.Paths.MonoSDKRelativeIncludeSourceDir, "utils", "mono-error.h"), - destinationCreator: (Runtime runtime) => Path.Combine (Configurables.Paths.MonoSDKIncludeDestinationDir, "utils", "mono-error.h"), - strip: false, - shared: true, - type: RuntimeFileType.SdkHeader - ), - - new RuntimeFile ( - sourceCreator: (Runtime runtime) => Path.Combine (MonoRuntimesHelpers.GetRootDir (runtime), Configurables.Paths.MonoSDKRelativeIncludeSourceDir, "utils", "mono-forward.h"), - destinationCreator: (Runtime runtime) => Path.Combine (Configurables.Paths.MonoSDKIncludeDestinationDir, "utils", "mono-forward.h"), - strip: false, - shared: true, - type: RuntimeFileType.SdkHeader - ), - - new RuntimeFile ( - sourceCreator: (Runtime runtime) => Path.Combine (MonoRuntimesHelpers.GetRootDir (runtime), Configurables.Paths.MonoSDKRelativeIncludeSourceDir, "utils", "mono-jemalloc.h"), - destinationCreator: (Runtime runtime) => Path.Combine (Configurables.Paths.MonoSDKIncludeDestinationDir, "utils", "mono-jemalloc.h"), - strip: false, - shared: true, - type: RuntimeFileType.SdkHeader - ), - - new RuntimeFile ( - sourceCreator: (Runtime runtime) => Path.Combine (MonoRuntimesHelpers.GetRootDir (runtime), Configurables.Paths.MonoSDKRelativeIncludeSourceDir, "utils", "mono-logger.h"), - destinationCreator: (Runtime runtime) => Path.Combine (Configurables.Paths.MonoSDKIncludeDestinationDir, "utils", "mono-logger.h"), - strip: false, - shared: true, - type: RuntimeFileType.SdkHeader - ), - - new RuntimeFile ( - sourceCreator: (Runtime runtime) => Path.Combine (MonoRuntimesHelpers.GetRootDir (runtime), Configurables.Paths.MonoSDKRelativeIncludeSourceDir, "utils", "mono-publib.h"), - destinationCreator: (Runtime runtime) => Path.Combine (Configurables.Paths.MonoSDKIncludeDestinationDir, "utils", "mono-publib.h"), - strip: false, - shared: true, - type: RuntimeFileType.SdkHeader - ), - - new RuntimeFile ( - sourceCreator: (Runtime runtime) => Path.Combine (Configurables.Paths.MonoProfileDir, "Consts.cs"), - destinationCreator: (Runtime runtime) => Path.Combine (Configurables.Paths.OutputIncludeDir, "Consts.cs"), - strip: false, - shared: true - ), - - // Xamarin.Android.Cecil.dll - new RuntimeFile ( - sourceCreator: (Runtime runtime) => Path.Combine (Configurables.Paths.BuildBinDir, "Xamarin.Android.Cecil.dll"), - destinationCreator: (Runtime runtime) => "Xamarin.Android.Cecil.dll", - strip: false, - shared: true - ), - - // Xamarin.Android.Cecil.pdb - new RuntimeFile ( - sourceCreator: (Runtime runtime) => Path.Combine (Configurables.Paths.BuildBinDir, "Xamarin.Android.Cecil.pdb"), - destinationCreator: (Runtime runtime) => "Xamarin.Android.Cecil.pdb", - strip: false, - shared: true - ), - - // Xamarin.Android.Cecil.Mdb.dll - new RuntimeFile ( - sourceCreator: (Runtime runtime) => Path.Combine (Configurables.Paths.BuildBinDir, "Xamarin.Android.Cecil.Mdb.dll"), - destinationCreator: (Runtime runtime) => "Xamarin.Android.Cecil.Mdb.dll", - strip: false, - shared: true - ), - - // Xamarin.Android.Cecil.Mdb.pdb - new RuntimeFile ( - sourceCreator: (Runtime runtime) => Path.Combine (Configurables.Paths.BuildBinDir, "Xamarin.Android.Cecil.Mdb.pdb"), - destinationCreator: (Runtime runtime) => "Xamarin.Android.Cecil.Mdb.pdb", - strip: false, - shared: true - ), - - new RuntimeFile ( - sourceCreator: (Runtime runtime) => Path.Combine (MonoRuntimesHelpers.GetRootDir (runtime), "lib", "libmonosgen-2.0.dll.a"), - destinationCreator: (Runtime runtime) => Path.Combine (GetRuntimeOutputDir (runtime), "libmonosgen-2.0.dll.a"), - shouldSkip: (Runtime runtime) => !IsAbi (runtime, AbiNames.HostJit.Win32, AbiNames.HostJit.Win64), - strip: false - ), - - // Stripped runtime - new RuntimeFile ( - sourceCreator: (Runtime runtime) => GetRuntimeOutputSourcePath (runtime), - destinationCreator: (Runtime runtime) => GetRuntimeOutputDestinationPath (runtime, debug: false), - shouldSkip: (Runtime runtime) => !IsHostOrTargetRuntime (runtime), - type: RuntimeFileType.StrippableBinary - ), - - // Unstripped runtime - new RuntimeFile ( - sourceCreator: (Runtime runtime) => GetRuntimeOutputSourcePath (runtime), - destinationCreator: (Runtime runtime) => GetRuntimeOutputDestinationPath (runtime, debug: true), - shouldSkip: (Runtime runtime) => !IsHostOrTargetRuntime (runtime), - type: RuntimeFileType.StrippableBinary, - strip: false - ), - - // Stripped libmono-native for Mac, copied from libmono-native-compat - new RuntimeFile ( - sourceCreator: (Runtime runtime) => GetMonoNativeOutputSourcePath (runtime), - destinationCreator: (Runtime runtime) => GetMonoNativeOutputDestinationPath (runtime, debug: false), - shouldSkip: (Runtime runtime) => !IsHostOrTargetRuntime (runtime) || !IsAbi (runtime, AbiNames.HostJit.Darwin), - type: RuntimeFileType.StrippableBinary - ), - - // Unstripped libmono-native for Mac, copied from libmono-native-compat - new RuntimeFile ( - sourceCreator: (Runtime runtime) => GetMonoNativeOutputSourcePath (runtime), - destinationCreator: (Runtime runtime) => GetMonoNativeOutputDestinationPath (runtime, debug: true), - shouldSkip: (Runtime runtime) => !IsHostOrTargetRuntime (runtime) || !IsAbi (runtime, AbiNames.HostJit.Darwin), - type: RuntimeFileType.StrippableBinary, - strip: false - ), - - // Stripped libmono-native for everything except: Mac, Win32, Win64, cross runtimes - new RuntimeFile ( - sourceCreator: (Runtime runtime) => GetMonoNativeOutputSourcePath (runtime), - destinationCreator: (Runtime runtime) => GetMonoNativeOutputDestinationPath (runtime, debug: false), - shouldSkip: (Runtime runtime) => !IsHostOrTargetRuntime (runtime) || IsAbi (runtime, AbiNames.HostJit.Darwin, AbiNames.HostJit.Win32, AbiNames.HostJit.Win64), - type: RuntimeFileType.StrippableBinary - ), - - // Untripped libmono-native for everything except: Mac, Win32, Win64, cross runtimes - new RuntimeFile ( - sourceCreator: (Runtime runtime) => GetMonoNativeOutputSourcePath (runtime), - destinationCreator: (Runtime runtime) => GetMonoNativeOutputDestinationPath (runtime, debug: true), - shouldSkip: (Runtime runtime) => !IsHostOrTargetRuntime (runtime) || IsAbi (runtime, AbiNames.HostJit.Darwin, AbiNames.HostJit.Win32, AbiNames.HostJit.Win64), - type: RuntimeFileType.StrippableBinary, - strip: false - ), - - // Unstripped host mono binary - new RuntimeFile ( - sourceCreator: (Runtime runtime) => Path.Combine (MonoRuntimesHelpers.GetRootDir (runtime), "bin", "mono"), - destinationCreator: (Runtime runtime) => Path.Combine (runtime.Name, "mono"), - shouldSkip: (Runtime runtime) => !IsRuntimeType (runtime) || IsAbi (runtime, AbiNames.HostJit.Win32, AbiNames.HostJit.Win64), - type: RuntimeFileType.StrippableBinary, - strip: false - ), - - // Stripped cross runtime - new RuntimeFile ( - sourceCreator: (Runtime runtime) => GetCrossRuntimeOutputSourcePath (runtime), - destinationCreator: (Runtime runtime) => GetCrossRuntimeOutputDestinationPath (runtime, debug: false), - shouldSkip: (Runtime runtime) => !IsRuntimeType (runtime), - type: RuntimeFileType.StrippableBinary - ), - - // Untripped cross runtime - new RuntimeFile ( - sourceCreator: (Runtime runtime) => GetCrossRuntimeOutputSourcePath (runtime), - destinationCreator: (Runtime runtime) => GetCrossRuntimeOutputDestinationPath (runtime, debug: true), - shouldSkip: (Runtime runtime) => !IsRuntimeType (runtime), - type: RuntimeFileType.StrippableBinary, - strip: false - ), - - // Stripped profiler - new RuntimeFile ( - sourceCreator: (Runtime runtime) => GetProfilerOutputSourcePath (runtime), - destinationCreator: (Runtime runtime) => GetProfilerOutputDestinationPath (runtime, debug: false), - shouldSkip: (Runtime runtime) => !IsHostOrTargetRuntime (runtime) || String.IsNullOrEmpty (runtime.As()?.OutputProfilerFilename), - type: RuntimeFileType.StrippableBinary - ), - - // Unstripped profiler - new RuntimeFile ( - sourceCreator: (Runtime runtime) => GetProfilerOutputSourcePath (runtime), - destinationCreator: (Runtime runtime) => GetProfilerOutputDestinationPath (runtime, debug: true), - shouldSkip: (Runtime runtime) => !IsHostOrTargetRuntime (runtime) || String.IsNullOrEmpty (runtime.As()?.OutputProfilerFilename), - type: RuntimeFileType.StrippableBinary, - strip: false - ), - - // Stripped AOT profiler - new RuntimeFile ( - sourceCreator: (Runtime runtime) => GetAotProfilerOutputSourcePath (runtime), - destinationCreator: (Runtime runtime) => GetAotProfilerOutputDestinationPath (runtime, debug: false), - shouldSkip: (Runtime runtime) => !IsHostOrTargetRuntime (runtime) || String.IsNullOrEmpty (runtime.As()?.OutputAotProfilerFilename), - type: RuntimeFileType.StrippableBinary - ), - - // Unstripped AOT profiler - new RuntimeFile ( - sourceCreator: (Runtime runtime) => GetAotProfilerOutputSourcePath (runtime), - destinationCreator: (Runtime runtime) => GetAotProfilerOutputDestinationPath (runtime, debug: true), - shouldSkip: (Runtime runtime) => !IsHostOrTargetRuntime (runtime) || String.IsNullOrEmpty (runtime.As()?.OutputAotProfilerFilename), - type: RuntimeFileType.StrippableBinary, - strip: false - ), - - // Stripped BTLS - new RuntimeFile ( - sourceCreator: (Runtime runtime) => GetMonoBtlsOutputSourcePath (runtime), - destinationCreator: (Runtime runtime) => GetMonoBtlsOutputDestinationPath (runtime, debug: false), - shouldSkip: (Runtime runtime) => !IsHostOrTargetRuntime (runtime) || String.IsNullOrEmpty (runtime.As()?.OutputMonoBtlsFilename), - type: RuntimeFileType.StrippableBinary - ), - - // Unstripped BTLS - new RuntimeFile ( - sourceCreator: (Runtime runtime) => GetMonoBtlsOutputSourcePath (runtime), - destinationCreator: (Runtime runtime) => GetMonoBtlsOutputDestinationPath (runtime, debug: true), - shouldSkip: (Runtime runtime) => !IsHostOrTargetRuntime (runtime) || String.IsNullOrEmpty (runtime.As()?.OutputMonoBtlsFilename), - type: RuntimeFileType.StrippableBinary, - strip: false - ), - - // Stripped MonoPosixHelper - new RuntimeFile ( - sourceCreator: (Runtime runtime) => GetMonoPosixHelperOutputSourcePath (runtime), - destinationCreator: (Runtime runtime) => GetMonoPosixHelperOutputDestinationPath (runtime, debug: false), - shouldSkip: (Runtime runtime) => !IsHostOrTargetRuntime (runtime) || String.IsNullOrEmpty (runtime.As()?.OutputMonoPosixHelperFilename), - type: RuntimeFileType.StrippableBinary - ), - - // Unstripped MonoPosixHelper - new RuntimeFile ( - sourceCreator: (Runtime runtime) => GetMonoPosixHelperOutputSourcePath (runtime), - destinationCreator: (Runtime runtime) => GetMonoPosixHelperOutputDestinationPath (runtime, debug: true), - shouldSkip: (Runtime runtime) => !IsHostOrTargetRuntime (runtime) || String.IsNullOrEmpty (runtime.As()?.OutputMonoPosixHelperFilename), - type: RuntimeFileType.StrippableBinary, - strip: false - ), - - // LLVM opt - new RuntimeFile ( - sourceCreator: (Runtime runtime) => Path.Combine (GetLlvmOutputSourcePath(runtime), $"opt{runtime.As()?.ExeSuffix}"), - destinationCreator: (Runtime runtime) => Path.Combine (GetLlvmOutputDestinationPath (runtime), $"opt{runtime.As()?.ExeSuffix}"), - shouldSkip: (Runtime runtime) => !IsRuntimeType (runtime) || !runtime.As()!.InstallBinaries || (Context.IsWindows && !IsWindowsRuntime (runtime)), - type: RuntimeFileType.StrippableBinary - ), - - // LLVM llc - new RuntimeFile ( - sourceCreator: (Runtime runtime) => Path.Combine (GetLlvmOutputSourcePath(runtime), $"llc{runtime.As()?.ExeSuffix}"), - destinationCreator: (Runtime runtime) => Path.Combine (GetLlvmOutputDestinationPath (runtime), $"llc{runtime.As()?.ExeSuffix}"), - shouldSkip: (Runtime runtime) => !IsRuntimeType (runtime) || !runtime.As()!.InstallBinaries || (Context.IsWindows && !IsWindowsRuntime (runtime)), - type: RuntimeFileType.StrippableBinary - ) - }; - - // If some assemblies don't exist in the Designer BCL set, list them here - static readonly Dictionary DesignerIgnoreFiles = new Dictionary { - { "Mono.Btls.Interface.dll", (Type: BclFileType.ProfileAssembly, Target: BclFileTarget.DesignerWindows) }, - }; - - /// - /// List of directories we'll be installing to. All the directories will be removed recursively before - /// installation starts. This is to ensure that no artifacts from previous builds remain. - /// - public readonly List OutputDirectories = new List { - Configurables.Paths.BCLTestsDestDir, - Configurables.Paths.InstallMSBuildDir, - Configurables.Paths.InstallBCLFrameworkDir, - Configurables.Paths.OutputIncludeDir, - }; - } -} diff --git a/build-tools/xaprepare/xaprepare/Main.cs b/build-tools/xaprepare/xaprepare/Main.cs index d7065f4c945..70f867d52b7 100644 --- a/build-tools/xaprepare/xaprepare/Main.cs +++ b/build-tools/xaprepare/xaprepare/Main.cs @@ -16,8 +16,6 @@ sealed class ParsedOptions public bool ShowHelp { get; set; } = false; public bool DumpProps { get; set; } = false; public bool NoEmoji { get; set; } = !Configurables.Defaults.UseEmoji; - public bool NoMingwW64 { get; set; } = false; - public bool ForceRuntimesBuild { get; set; } = false; public string? HashAlgorithm { get; set; } public uint MakeConcurrency { get; set; } = 0; public ExecutionMode ExecutionMode { get; set; } = Configurables.Defaults.ExecutionMode; @@ -31,8 +29,6 @@ sealed class ParsedOptions public bool AutoProvisionUsesSudo { get; set; } public bool IgnoreMaxMonoVersion { get; set; } public bool IgnoreMinMonoVersion { get; set; } - public string? MonoArchiveCustomUrl { get; set; } - public bool EnableAll { get; set; } public RefreshableComponent RefreshList { get; set; } public IEnumerable AndroidSdkPlatforms { get; set; } = Enumerable.Empty (); } @@ -95,9 +91,7 @@ static async Task Run (string[] args) {"d|dump-properties", "Dump values of all the defined properties to the screen", v => parsedOptions.DumpProps = true }, {"j|make-concurrency=", "Number of concurrent jobs for make to run. A positive integer or 0 for the default. Defaults to the number of CPUs/cores", v => parsedOptions.MakeConcurrency = EnsureUInt (v, "Invalid Make concurrency value") }, {"no-emoji", "Do not use any emoji characters in the output", v => parsedOptions.NoEmoji = true }, - {"no-mingw-w64", "Do not install mingw-w64 compiler", v => parsedOptions.NoMingwW64 = true }, {"r|run-mode=", $"Specify the execution mode: {GetExecutionModes()}. See documentation for mode descriptions. Default: {Configurables.Defaults.ExecutionMode}", v => parsedOptions.ExecutionMode = ParseExecutionMode (v)}, - {"f|build-runtimes", $"Build runtimes even if the bundle/archives are available.", v => parsedOptions.ForceRuntimesBuild = true }, {"H|hash-algorithm=", "Use the specified hash algorithm instead of the default {Configurables.Defaults.HashAlgorithm}", v => parsedOptions.HashAlgorithm = v?.Trim () }, {"D|debug-ext=", $"Extension of files with debug information for managed DLLs and executables. Default: {parsedOptions.DebugFileExtension}", v => parsedOptions.DebugFileExtension = v?.Trim () ?? String.Empty }, {"v|verbosity=", $"Set console log verbosity to {{LEVEL}}. Level name may be abbreviated to the smallest unique part (one of: {GetVerbosityLevels ()}). Default: {Context.Instance.LoggingVerbosity.ToString().ToLowerInvariant ()}", v => parsedOptions.Verbosity = ParseLogVerbosity (v) }, @@ -105,14 +99,12 @@ static async Task Run (string[] args) {"ls", "List names of all known scenarios", v => parsedOptions.ListScenarios = true }, {"cf=", $"{{NAME}} of the compression format to use for some archives (e.g. the XA bundle). One of: {GetCompressionFormatNames ()}; Default: {parsedOptions.CompressionFormat}", v => parsedOptions.CompressionFormat = v?.Trim () ?? String.Empty}, {"c|configuration=", $"Build {{CONFIGURATION}}. Default: {Context.Instance.Configuration}", v => parsedOptions.Configuration = v?.Trim ()}, - {"a|enable-all", "Enable preparation of all the supported targets, ABIs etc", v => parsedOptions.EnableAll = true}, {"refresh:", "[sdk,ndk] Comma separated list of components which should be reinstalled. Defaults to all supported components if no value is provided.", v => parsedOptions.RefreshList = ParseRefreshableComponents (v?.Trim () ?? String.Empty)}, "", {"auto-provision=", $"Automatically install software required by Xamarin.Android", v => parsedOptions.AutoProvision = ParseBoolean (v)}, {"auto-provision-uses-sudo=", $"Allow use of sudo(1) when provisioning", v => parsedOptions.AutoProvisionUsesSudo = ParseBoolean (v)}, {"ignore-max-mono-version=", $"Ignore the maximum supported Mono version restriction", v => parsedOptions.IgnoreMaxMonoVersion = ParseBoolean (v)}, {"ignore-min-mono-version=", $"Ignore the minimum supported Mono version restriction", v => parsedOptions.IgnoreMinMonoVersion = ParseBoolean (v)}, - {"mono-archive-url=", "Use a specific URL for the mono archive.", v => parsedOptions.MonoArchiveCustomUrl = v?.Trim () }, {"android-sdk-platforms=", "Comma separated list of Android SDK platform levels to be installed. Defaults to all if no value is provided.", v => parsedOptions.AndroidSdkPlatforms = ParseAndroidSdkPlatformLevels (v?.Trim () ?? String.Empty) }, "", {"h|help", "Show this help message", v => parsedOptions.ShowHelp = true }, @@ -138,17 +130,13 @@ static async Task Run (string[] args) Context.Instance.MakeConcurrency = parsedOptions.MakeConcurrency; Context.Instance.NoEmoji = parsedOptions.NoEmoji; - Context.Instance.NoMingwW64 = parsedOptions.NoMingwW64; Context.Instance.ExecutionMode = parsedOptions.ExecutionMode; - Context.Instance.ForceRuntimesBuild = parsedOptions.ForceRuntimesBuild; Context.Instance.LoggingVerbosity = parsedOptions.Verbosity; Context.Instance.DebugFileExtension = parsedOptions.DebugFileExtension; Context.Instance.AutoProvision = parsedOptions.AutoProvision; Context.Instance.AutoProvisionUsesSudo = parsedOptions.AutoProvisionUsesSudo; Context.Instance.IgnoreMaxMonoVersion = parsedOptions.IgnoreMaxMonoVersion; Context.Instance.IgnoreMinMonoVersion = parsedOptions.IgnoreMinMonoVersion; - Context.Instance.MonoArchiveCustomUrl = parsedOptions.MonoArchiveCustomUrl ?? String.Empty; - Context.Instance.EnableAllTargets = parsedOptions.EnableAll; Context.Instance.ComponentsToRefresh = parsedOptions.RefreshList; Context.Instance.AndroidSdkPlatforms = parsedOptions.AndroidSdkPlatforms; diff --git a/build-tools/xaprepare/xaprepare/OperatingSystems/MacOS.cs b/build-tools/xaprepare/xaprepare/OperatingSystems/MacOS.cs index 906fab974c9..01671c98fc0 100644 --- a/build-tools/xaprepare/xaprepare/OperatingSystems/MacOS.cs +++ b/build-tools/xaprepare/xaprepare/OperatingSystems/MacOS.cs @@ -72,12 +72,6 @@ unsafe bool GetProcessIsTranslated () return ret != 0; } - protected override void PopulateEnvironmentVariables () - { - base.PopulateEnvironmentVariables (); - EnvironmentVariables ["MACOSX_DEPLOYMENT_TARGET"] = Configurables.Defaults.MacOSDeploymentTarget; - } - protected override bool InitOS () { if (!base.InitOS ()) @@ -91,7 +85,6 @@ protected override bool InitOS () Context.MonoOptions.Add ("--arch=64"); Context.Instance.Tools.BrewPath = brewPath; - HomebrewPrefix = Utilities.GetStringFromStdout (brewPath, "--prefix"); (bool success, string bv) = Utilities.GetProgramVersion (brewPath); if (!success || !Version.TryParse (bv, out Version? brewVersion) || brewVersion == null) { @@ -101,14 +94,6 @@ protected override bool InitOS () HomebrewVersion = brewVersion; - // This is a hack since we have a chicken-and-egg problem. On mac, Configuration.props uses the - // `HostHomebrewPrefix` property which is defined in `Configuration.OperatingSystem.props` but we're here to - // *generate* the latter file, so when the bootstrapper is built `HostHomebrewPrefix` is empty and we can't - // access mingw utilities. So, we need to cheat here. - string? mxePath = Context.Instance.Properties.GetValue (KnownProperties.AndroidMxeFullPath); - if (String.IsNullOrEmpty (mxePath)) - Context.Instance.Properties.Set (KnownProperties.AndroidMxeFullPath, HomebrewPrefix); - return true; } diff --git a/build-tools/xaprepare/xaprepare/OperatingSystems/NoOS.cs b/build-tools/xaprepare/xaprepare/OperatingSystems/NoOS.cs index 4a16c5b45cf..fccda6d2296 100644 --- a/build-tools/xaprepare/xaprepare/OperatingSystems/NoOS.cs +++ b/build-tools/xaprepare/xaprepare/OperatingSystems/NoOS.cs @@ -28,11 +28,6 @@ protected override string AssertIsExecutable (string fullPath) throw new NotImplementedException (); } - protected override void DetectCompilers () - { - throw new NotImplementedException (); - } - protected override void InitializeDependencies () { throw new NotImplementedException (); diff --git a/build-tools/xaprepare/xaprepare/OperatingSystems/OS.cs b/build-tools/xaprepare/xaprepare/OperatingSystems/OS.cs index 8cdd8073401..370b798fdf4 100644 --- a/build-tools/xaprepare/xaprepare/OperatingSystems/OS.cs +++ b/build-tools/xaprepare/xaprepare/OperatingSystems/OS.cs @@ -84,57 +84,6 @@ abstract class OS : AppObject /// public string Architecture { get; protected set; } = String.Empty; - /// - /// Path to the C compiler to build binaries with the native OS bitness - /// - public string CC { get; set; } = String.Empty; - - /// - /// Path to the C compiler to build binaries with 32-bit bitness - /// - public string CC32 { get; set; } = String.Empty; - - /// - /// Path to the C compiler to build binaries with 64-bit bitness - /// - public string CC64 { get; set; } = String.Empty; - - /// - /// Path to the C++ compiler to build binaries with the native OS bitness - /// - public string CXX { get; set; } = String.Empty; - - /// - /// Path to the C+ compiler to build binaries with 32-bit bitness - /// - public string CXX32 { get; set; } = String.Empty; - - /// - /// Path to the C compiler to build binaries with 64-bit bitness - /// - public string CXX64 { get; set; } = String.Empty; - - /// - /// Default compiler target triple - /// - public string Triple { get; set; } = String.Empty; - - /// - /// 32-bit compiler target triple - /// - public string Triple32 { get; set; } = String.Empty; - - /// - /// 64-bit compiler target triple - /// - public string Triple64 { get; set; } = String.Empty; - - /// - /// Prefix where Homebrew is installed (relevant only on macOS, but present in all operating system for - /// compatibility reasons) - /// - public string HomebrewPrefix { get; set; } = String.Empty; - public virtual bool ProcessIsTranslated => false; /// @@ -210,11 +159,6 @@ protected virtual bool InitOS () /// protected abstract string AssertIsExecutable (string fullPath); - /// - /// Detect the required C and C++ compilers on the system. - /// - protected abstract void DetectCompilers (); - protected OS (Context context) { Context = context; @@ -369,77 +313,6 @@ void ConfigureEnvironment () Log.DebugLine ($"Setting environment variable: {name} = {value}"); Environment.SetEnvironmentVariable (name, value); } - - if (Context.SelectedScenario.NeedsCompilers) - DetectCompilers (); - } - - /// - /// Verifies whether the configured compilers can in fact be found, throws an exception if they aren't. - /// - protected void VerifyCompilersExist () - { - Log.DebugLine ($"Verifying {CC} compiler name is set"); - AssertCompilerSet (CC, "C"); - - Log.DebugLine ($"Verifying {CXX} compiler name is set"); - AssertCompilerSet (CXX, "C++"); - - Log.DebugLine ($"Verifying {CC} compiler exists"); - AssertCompilerFound (Which (CC), CC, "C"); - - Log.DebugLine ($"Verifying {CXX} compiler exists"); - AssertCompilerFound (Which (CXX), CXX, "C++"); - - void AssertCompilerFound (string path, string variable, string name) - { - if (String.IsNullOrEmpty (path)) - throw new InvalidOperationException ($"{name} compiler not found. Tried to find: {variable}"); - } - - void AssertCompilerSet (string variable, string name) - { - if (String.IsNullOrEmpty (variable)) - throw new InvalidOperationException ($"{name} compiler not set"); - } - } - - protected void LogCompilerDetails () - { - const ConsoleColor prefixColor = ConsoleColor.White; - const ConsoleColor languageColor = ConsoleColor.Yellow; - const ConsoleColor unsupportedColor = ConsoleColor.Red; - - LogCompiler (" Default", "C", CC); - LogCompiler (" 32-bit", "C", CC32); - LogCompiler (" 64-bit", "C", CC64); - - LogCompiler ("Default", "C++", CXX); - LogCompiler (" 32-bit", "C++", CXX32); - LogCompiler (" 64-bit", "C++", CXX64); - - Log.Status (" Default triple: ", prefixColor); - LogCompilerInfo (Triple); - Log.Status (" 32-bit triple: ", prefixColor); - LogCompilerInfo (Triple32); - Log.Status (" 64-bit triple: ", prefixColor); - LogCompilerInfo (Triple64); - - void LogCompiler (string variationName, string languageName, string compiler) - { - Log.Status ($"{variationName} ", prefixColor); - Log.Status (languageName, languageColor); - Log.Status (" compiler: ", prefixColor); - LogCompilerInfo (compiler); - } - - void LogCompilerInfo (string compiler) - { - if (String.IsNullOrEmpty (compiler)) - Log.StatusLine ("unsupported", unsupportedColor); - else - Log.StatusLine (compiler); - } } /// diff --git a/build-tools/xaprepare/xaprepare/OperatingSystems/Unix.cs b/build-tools/xaprepare/xaprepare/OperatingSystems/Unix.cs index ed1640d9fef..3e56688fda4 100644 --- a/build-tools/xaprepare/xaprepare/OperatingSystems/Unix.cs +++ b/build-tools/xaprepare/xaprepare/OperatingSystems/Unix.cs @@ -21,90 +21,6 @@ protected Unix (Context context) : base (context) DiskInformation = Utilities.GetStringFromStdout ("df", "-h").Trim (); } - string GetCompiler (string fromEnv, string defaultName) - { - if (!String.IsNullOrEmpty (fromEnv)) - return fromEnv; - return defaultName; - } - - protected override void DetectCompilers () - { - string cc = Environment.GetEnvironmentVariable ("CC")?.Trim () ?? String.Empty; - string cxx = Environment.GetEnvironmentVariable ("CXX")?.Trim () ?? String.Empty; - string defaultCompiler = String.Empty; - - if (!String.IsNullOrEmpty (cc)) { - Log.DebugLine ($"Unix C compiler read from environment variable CC: {cc}"); - defaultCompiler = cc; - } - - if (!String.IsNullOrEmpty (cxx)) { - Log.DebugLine ($"Unix C++ compiler read from environment variable CXX: {cxx}"); - if (String.IsNullOrEmpty (defaultCompiler)) - defaultCompiler = cxx; - } - - if (String.IsNullOrEmpty (defaultCompiler)) { - defaultCompiler = Configurables.Defaults.DefaultCompiler; - if (String.IsNullOrEmpty (defaultCompiler)) - throw new InvalidOperationException ("Default compiler not specified"); - } - - string ccVersion = Utilities.GetStringFromStdout (defaultCompiler, "--version"); - if (String.IsNullOrEmpty (ccVersion)) - throw new InvalidOperationException ($"Failed to obtain version information from the {defaultCompiler} compiler"); - - Log.DebugLine ($"Compiler {defaultCompiler} identifies as:"); - Log.DebugLine (ccVersion); - - bool clang = false; - if (ccVersion.IndexOf ("Free Software Foundation", StringComparison.OrdinalIgnoreCase) >= 0) { - CC = GetCompiler (cc, "gcc"); - CXX = GetCompiler (cxx, "g++"); - } else if (ccVersion.IndexOf ("clang", StringComparison.OrdinalIgnoreCase) >= 0) { - CC = GetCompiler (cc, "clang"); - CXX = GetCompiler (cxx, "clang++"); - clang = true; - } else { - CC = GetCompiler (cc, "cc"); - CXX = GetCompiler (cxx, "c++"); - } - - VerifyCompilersExist (); - - Triple = Utilities.GetStringFromStdout (CC, "-dumpmachine"); - if (String.IsNullOrEmpty (Triple)) - throw new InvalidOperationException ($"Failed to determine default target triple for compiler {CC}"); - - if (Is64Bit) { - CC64 = CC; - CXX64 = CXX; - CC32 = $"{CC} -m32"; - CXX32 = $"{CXX} -m32"; - - if (clang) - Triple32 = Utilities.GetStringFromStdout(CC, "-m32", "-dumpmachine"); - else { - if (!Triple.StartsWith ("x86_64-", StringComparison.OrdinalIgnoreCase)) - throw new InvalidOperationException ($"Unexpected 64-bit triple '{Triple}'"); - - Triple32 = Triple.Replace ("x86_64-", "i686-"); - } - - Triple64 = Triple; - } else { - CC64 = String.Empty; - CXX64 = String.Empty; - CC32 = CC; - CXX32 =CXX; - Triple32 = Triple; - Triple64 = String.Empty; - } - - LogCompilerDetails (); - } - protected override string AssertIsExecutable (string fullPath) { IsExecutable (fullPath, true); diff --git a/build-tools/xaprepare/xaprepare/OperatingSystems/Windows.cs b/build-tools/xaprepare/xaprepare/OperatingSystems/Windows.cs index e627c7cba96..968d25980f6 100644 --- a/build-tools/xaprepare/xaprepare/OperatingSystems/Windows.cs +++ b/build-tools/xaprepare/xaprepare/OperatingSystems/Windows.cs @@ -109,11 +109,6 @@ protected override bool InitOS () return true; } - protected override void DetectCompilers () - { - Log.Todo ("Implement compiler detection"); - } - string GetHomeDir () { string? homeDir = Environment.GetEnvironmentVariable ("USERPROFILE"); diff --git a/build-tools/xaprepare/xaprepare/Resources/Configuration.OperatingSystem.props.in b/build-tools/xaprepare/xaprepare/Resources/Configuration.OperatingSystem.props.in index c51c3ee2b8a..7b5a2e7bac5 100644 --- a/build-tools/xaprepare/xaprepare/Resources/Configuration.OperatingSystem.props.in +++ b/build-tools/xaprepare/xaprepare/Resources/Configuration.OperatingSystem.props.in @@ -4,22 +4,12 @@ @OS_NAME@ @HOST_OS_FLAVOR@ @OS_RELEASE@ - @HOST_TRIPLE@ - @HOST_TRIPLE32@ - @HOST_TRIPLE64@ @HOST_CPUS@ @ARCHITECTURE_BITS@ - @HOST_CC@ - @HOST_CXX@ - @HOST_CC32@ - @HOST_CC64@ - @HOST_CXX32@ - @HOST_CXX64@ @JavaSdkDirectory@ @javac@ @jar@ @java@ - @HOST_HOMEBREW_PREFIX@ @NDK_LLVM_TAG@ diff --git a/build-tools/xaprepare/xaprepare/Resources/MonoGitHash.props.in b/build-tools/xaprepare/xaprepare/Resources/MonoGitHash.props.in deleted file mode 100644 index d5aebc5fcc1..00000000000 --- a/build-tools/xaprepare/xaprepare/Resources/MonoGitHash.props.in +++ /dev/null @@ -1,6 +0,0 @@ - - - - <_BuildInfo_MonoCommit>@MONO_COMMIT_HASH@ - - diff --git a/build-tools/xaprepare/xaprepare/Scenarios/Scenario_PrepareImageDependencies.cs b/build-tools/xaprepare/xaprepare/Scenarios/Scenario_PrepareImageDependencies.cs deleted file mode 100644 index a7b20e548a3..00000000000 --- a/build-tools/xaprepare/xaprepare/Scenarios/Scenario_PrepareImageDependencies.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace Xamarin.Android.Prepare -{ - [Scenario (isDefault: false)] - class Scenario_PrepareImageDependencies : ScenarioNoStandardEndSteps - { - public Scenario_PrepareImageDependencies () : base ("PrepareImageDependencies", "Prepare provisioning dependencies") - {} - - protected override void AddSteps (Context context) - { - Steps.Add (new Step_PrepareImageDependencies ()); - - // disable installation of missing programs... - context.SetCondition (KnownConditions.AllowProgramInstallation, false); - - // ...but do not signal an error when any are missing - context.SetCondition (KnownConditions.IgnoreMissingPrograms, true); - } - } -} diff --git a/build-tools/xaprepare/xaprepare/Scenarios/Scenario_Standard.MacOS.cs b/build-tools/xaprepare/xaprepare/Scenarios/Scenario_Standard.MacOS.cs deleted file mode 100644 index f6a3f215721..00000000000 --- a/build-tools/xaprepare/xaprepare/Scenarios/Scenario_Standard.MacOS.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace Xamarin.Android.Prepare -{ - partial class Scenario_Standard - { - partial void AddRequiredMacOSSteps (bool beforeBundle) - { - if (beforeBundle) - return; - - Steps.Add (new Step_ChangeLibMonoSgenDylibID ()); - } - } -} diff --git a/build-tools/xaprepare/xaprepare/Scenarios/Scenario_Standard.Unix.cs b/build-tools/xaprepare/xaprepare/Scenarios/Scenario_Standard.Unix.cs deleted file mode 100644 index c9078206c1f..00000000000 --- a/build-tools/xaprepare/xaprepare/Scenarios/Scenario_Standard.Unix.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace Xamarin.Android.Prepare -{ - partial class Scenario_Standard - { - partial void AddRequiredOSSpecificSteps (bool beforeBundle) - { - AddRequiredMacOSSteps (beforeBundle); - - if (Context.Instance.WindowsJitAbisEnabled) { - Log.DebugLine ("Windows JIT ABIs ENABLED, ADDING MinGW dependencies build step (BEFORE bundle)"); - Steps.Add (new Step_BuildMingwDependencies ()); - } else { - Log.DebugLine ("Windows JIT ABis DISABLED, SKIPPING MinGW dependencies build step"); - } - } - - partial void AddRequiredMacOSSteps (bool beforeBundle); - } -} diff --git a/build-tools/xaprepare/xaprepare/Scenarios/Scenario_Standard.Windows.cs b/build-tools/xaprepare/xaprepare/Scenarios/Scenario_Standard.Windows.cs deleted file mode 100644 index 73aba8be5f6..00000000000 --- a/build-tools/xaprepare/xaprepare/Scenarios/Scenario_Standard.Windows.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; - -namespace Xamarin.Android.Prepare -{ - partial class Scenario_Standard - { - partial void AddRequiredOSSpecificSteps (bool beforeBundle) - { - } - } -} diff --git a/build-tools/xaprepare/xaprepare/Scenarios/Scenario_Standard.cs b/build-tools/xaprepare/xaprepare/Scenarios/Scenario_Standard.cs index 4cf061c1c5e..65b4db34443 100644 --- a/build-tools/xaprepare/xaprepare/Scenarios/Scenario_Standard.cs +++ b/build-tools/xaprepare/xaprepare/Scenarios/Scenario_Standard.cs @@ -18,26 +18,15 @@ protected override void AddSteps (Context context) if (context == null) throw new ArgumentNullException (nameof (context)); - Steps.Add (new Step_ShowEnabledRuntimes ()); Steps.Add (new Step_InstallDotNetPreview ()); Steps.Add (new Step_InstallAdoptOpenJDK8 ()); Steps.Add (new Step_InstallMicrosoftOpenJDK11 ()); Steps.Add (new Step_Android_SDK_NDK ()); Steps.Add (new Step_GenerateFiles (atBuildStart: true)); Steps.Add (new Step_PrepareProps ()); - Steps.Add (new Step_PrepareExternal ()); - Steps.Add (new Step_PrepareLocal ()); - Steps.Add (new Step_DownloadMonoArchive ()); - AddRequiredOSSpecificSteps (true); - Steps.Add (new Step_InstallMonoRuntimes ()); - - // The next two steps MUST be after InstallMonoRuntimes above since the latter cleans up the target - // directory where the NDK binutils are installed Steps.Add (new Step_InstallGNUBinutils ()); Steps.Add (new Step_GenerateCGManifest ()); Steps.Add (new Step_Get_Android_BuildTools ()); - - AddRequiredOSSpecificSteps (false); } protected override void AddEndSteps (Context context) @@ -46,6 +35,5 @@ protected override void AddEndSteps (Context context) Steps.Add (new Step_GenerateFiles (atBuildStart: false)); } - partial void AddRequiredOSSpecificSteps (bool beforeBundle); } } diff --git a/build-tools/xaprepare/xaprepare/Steps/Step_BuildMingwDependencies.cs b/build-tools/xaprepare/xaprepare/Steps/Step_BuildMingwDependencies.cs deleted file mode 100644 index 0e9b30be0f9..00000000000 --- a/build-tools/xaprepare/xaprepare/Steps/Step_BuildMingwDependencies.cs +++ /dev/null @@ -1,143 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Threading.Tasks; - -namespace Xamarin.Android.Prepare -{ - class Step_BuildMingwDependencies : Step - { - static readonly SortedDictionary dependencies = new SortedDictionary (StringComparer.Ordinal) { - { "mman-win32", (description: "mmap for Windows", libraryName: "libmman.a") }, - }; - - public Step_BuildMingwDependencies () : - base ("Build MinGW dependencies") - {} - - protected override async Task Execute (Context context) - { - if (context == null) - throw new ArgumentNullException (nameof (context)); - - if (!context.WindowsJitAbisEnabled) - throw new InvalidOperationException ("No Windows targets enabled, this step should not be called"); - - Log.StatusLine ("Dependencies:"); - foreach (var kvp in dependencies) { - string dependencyDir = kvp.Key; - (string dependencyDescription, string libraryName) = kvp.Value; - bool disabled, success; - - (disabled, success) = await ConfigureBuildAndInstall (context, AbiNames.HostJit.Win32, dependencyDir, dependencyDescription, libraryName); - if (!disabled && !success) - return false; - - (disabled, success) = await ConfigureBuildAndInstall (context, AbiNames.HostJit.Win64, dependencyDir, dependencyDescription, libraryName); - if (!disabled && !success) - return false; - } - - return true; - } - - async Task<(bool disabled, bool success)> ConfigureBuildAndInstall (Context context, string abiName, string dependencyDir, string dependencyDescription, string libraryName) - { - if (!context.IsHostJitAbiEnabled (abiName)) { - Log.DebugLine ($"Windows target {abiName} disabled, not building ${dependencyDescription}"); - return (true, true); - } - - Log.StatusLine ($" {context.Characters.Bullet} {dependencyDescription}"); - bool sixtyFourBit = context.Is64BitMingwHostAbi (abiName); - string sourceDir = Path.Combine (Configurables.Paths.ExternalDir, dependencyDir); - string buildDir = Path.Combine (Configurables.Paths.BuildBinDir, $"{dependencyDir}-{abiName}"); - - Log.DebugLine ($"{dependencyDir} source directory: {sourceDir}"); - Log.DebugLine ($"{dependencyDir} build directory: {buildDir}"); - - string outputDir; - if (sixtyFourBit) - outputDir = "x86_64"; - else - outputDir = "x86"; - outputDir = Path.Combine (context.Properties.GetRequiredValue (KnownProperties.MingwDependenciesRootDirectory), outputDir); - Log.DebugLine ($"{dependencyDir} output directory: {outputDir}"); - - string outputLibraryPath = Path.Combine (outputDir, "lib", libraryName); - Log.DebugLine ($"{dependencyDir} output file path: {outputLibraryPath}"); - - if (Utilities.FileExists (outputLibraryPath)) { - Log.StatusLine (" already built", Context.SuccessColor); - return (false, true); - } - - Utilities.DeleteDirectorySilent (buildDir); - Utilities.CreateDirectory (buildDir); - - Log.StatusLine (" configuring..."); - List arguments = GetCmakeArguments (context, buildDir, outputDir, sixtyFourBit); - string logTag = $"{dependencyDir}-{abiName}-configure"; - var cmake = new CMakeRunner (context); - bool result = await cmake.Run ( - logTag: logTag, - sourceDirectory: sourceDir, - workingDirectory: buildDir, - arguments: arguments - ); - - if (!result) - return (false, false); - - logTag = $"{dependencyDir}-{abiName}-build"; - Log.StatusLine (" building..."); - var ninja = new NinjaRunner (context); - result = await ninja.Run ( - logTag: logTag, - workingDirectory: buildDir - ); - - if (!result) - return (false, false); - - logTag = $"{dependencyDir}-{abiName}-install"; - Log.StatusLine (" installing..."); - result = await ninja.Run ( - logTag: logTag, - workingDirectory: buildDir, - arguments: new List { "install", "-v" } - ); - - if (!File.Exists (outputLibraryPath)) { - Log.ErrorLine ($"Installation of {dependencyDescription} failed"); - return (false, false); - } - - if (!result) - return (false, false); - - return (false, true); - } - - List GetCmakeArguments (Context context, string workingDirectory, string outputDirectory, bool sixtyFourBit) - { - string cmakeToolchainFile; - - if (sixtyFourBit) { - cmakeToolchainFile = Configurables.Paths.Mingw64CmakePath; - } else { - cmakeToolchainFile = Configurables.Paths.Mingw32CmakePath; - } - - return new List { - "-GNinja", - "-DCMAKE_MAKE_PROGRAM=ninja", - "-DBUILD_TESTS=OFF", - "-DBUILD_SHARED_LIBS=OFF", - $"-DCMAKE_INSTALL_PREFIX={outputDirectory}", - "-Wno-dev", // Hushes some warnings that are useless for us - $"-DCMAKE_TOOLCHAIN_FILE={Utilities.GetRelativePath (workingDirectory, cmakeToolchainFile)}", - }; - } - } -} diff --git a/build-tools/xaprepare/xaprepare/Steps/Step_BuildMonoRuntimes.Unix.cs b/build-tools/xaprepare/xaprepare/Steps/Step_BuildMonoRuntimes.Unix.cs deleted file mode 100644 index efbaef311d2..00000000000 --- a/build-tools/xaprepare/xaprepare/Steps/Step_BuildMonoRuntimes.Unix.cs +++ /dev/null @@ -1,545 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Net; -using System.Reflection; -using System.Threading.Tasks; -using System.Xml.Linq; - -namespace Xamarin.Android.Prepare -{ - class Step_BuildMonoRuntimes : StepWithDownloadProgress - { - const string StatusIndent = " "; - const string SubStatusIndent = " "; - - List? runtimeBuildMakeOptions; - List? runtimeBuildMakeTargets; - Runtimes? allRuntimes; - - public Step_BuildMonoRuntimes () - : base ("Preparing Mono runtimes") - { - Context.Instance.RuleGenerators.Add (MonoRuntime_RuleGenerator); - } - - protected override async Task Execute (Context context) - { - List enabledRuntimes = GetEnabledRuntimes (enableLogging: false); - if (enabledRuntimes.Count == 0) { - Log.StatusLine ("No runtimes to build/install"); - return true; - } - - if (!context.MonoArchiveDownloaded) { - List makeArguments = GetMakeArguments (context, enabledRuntimes); - if (!await BuildRuntimes (context, makeArguments)) { - Log.ErrorLine ("Mono runtime build failed"); - return false; - } - } - - CleanupBeforeInstall (); - Log.StatusLine (); - - string managedRuntime = context.Properties.GetRequiredValue (KnownProperties.ManagedRuntime); - bool haveManagedRuntime = !String.IsNullOrEmpty (managedRuntime); - if (!await ConjureXamarinCecilAndRemapRef (context, haveManagedRuntime, managedRuntime)) - return false; - - if (!await InstallRuntimes (context, enabledRuntimes)) - return false; - - if (!InstallBCL (context)) - return false; - - if (!InstallUtilities (context, haveManagedRuntime, managedRuntime)) - return false; - - Utilities.PropagateXamarinAndroidCecil (context); - - return true; - } - - void EnsureAllRuntimes () - { - if (allRuntimes == null) - throw new InvalidOperationException ("Step not initialized properly, allRuntimes is not set"); - } - - void CleanupBeforeInstall () - { - EnsureAllRuntimes (); - foreach (string dir in allRuntimes!.OutputDirectories) { - Utilities.DeleteDirectorySilent (dir); - } - } - - async Task ConjureXamarinCecilAndRemapRef (Context context, bool haveManagedRuntime, string managedRuntime) - { - StatusStep (context, "Building remap-assembly-ref"); - bool result = await Utilities.BuildRemapRef (context, haveManagedRuntime, managedRuntime, quiet: true); - if (!result) - return false; - - var msbuild = new MSBuildRunner (context); - StatusStep (context, "Building conjure-xamarin-android-cecil"); - string projectPath = Path.Combine (Configurables.Paths.BuildToolsDir, "conjure-xamarin-android-cecil", "conjure-xamarin-android-cecil.csproj"); - result = await msbuild.Run ( - projectPath: projectPath, - logTag: "conjure-xamarin-android-cecil", - binlogName: "build-conjure-xamarin-android-cecil" - ); - - if (!result) { - Log.ErrorLine ("Failed to build conjure-xamarin-android-cecil"); - return false; - } - - StatusStep (context, "Conjuring Xamarin.Android.Cecil and Xamari.Android.Cecil.Mdb"); - string conjurer = Path.Combine (Configurables.Paths.BuildBinDir, "conjure-xamarin-android-cecil.exe"); - string conjurerSourceDir = Configurables.Paths.MonoProfileToolsDir; - string conjurerDestDir = Configurables.Paths.BuildBinDir; - - result = Utilities.RunCommand ( - haveManagedRuntime ? managedRuntime : conjurer, // command - BuildPaths.XamarinAndroidSourceRoot, // workingDirectory - true, // ignoreEmptyArguments - - // arguments - haveManagedRuntime ? conjurer : String.Empty, - Configurables.Paths.MonoProfileToolsDir, // source dir - Configurables.Paths.BuildBinDir // destination dir - ); - - StatusStep (context, "Re-signing Xamarin.Android.Cecil.dll"); - var sn = new SnRunner (context); - string snkPath = Path.Combine (BuildPaths.XamarinAndroidSourceRoot, "mono.snk"); - string assemblyPath = Path.Combine (Configurables.Paths.BuildBinDir, "Xamarin.Android.Cecil.dll"); - result = await sn.ReSign (snkPath, assemblyPath, $"sign-xamarin-android-cecil"); - if (!result) { - Log.ErrorLine ("Failed to re-sign Xamarin.Android.Cecil.dll"); - return false; - } - - StatusStep (context, "Re-signing Xamarin.Android.Cecil.Mdb.dll"); - assemblyPath = Path.Combine (Configurables.Paths.BuildBinDir, "Xamarin.Android.Cecil.Mdb.dll"); - result = await sn.ReSign (snkPath, assemblyPath, $"sign-xamarin-android-cecil-mdb"); - if (!result) { - Log.ErrorLine ("Failed to re-sign Xamarin.Android.Cecil.Mdb.dll"); - return false; - } - - return true; - } - - bool InstallUtilities (Context context, bool haveManagedRuntime, string managedRuntime) - { - string destDir = MonoRuntimesHelpers.UtilitiesDestinationDir; - - Utilities.CreateDirectory (destDir); - - 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"); - EnsureAllRuntimes (); - 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; - } - - bool GenerateFrameworkList (Context contex, string filePath, string bclDir, string facadesDir) - { - Log.DebugLine ($"Generating {filePath}"); - - EnsureAllRuntimes (); - var contents = new XElement ( - "FileList", - new XAttribute ("Redist", Runtimes.FrameworkListRedist), - new XAttribute ("Name", Runtimes.FrameworkListName), - allRuntimes!.BclFilesToInstall.Where (f => f.Type == BclFileType.FacadeAssembly || f.Type == BclFileType.ProfileAssembly).Select (f => ToFileElement (f)) - ); - contents.Save (filePath); - return true; - - XElement ToFileElement (BclFile bcf) - { - Log.Debug ("Writing "); - string fullFilePath; - - switch (bcf.Type) { - case BclFileType.ProfileAssembly: - fullFilePath = Path.Combine (bclDir, bcf.Name); - Log.Debug ("profile"); - break; - - case BclFileType.FacadeAssembly: - Log.Debug ("facade"); - fullFilePath = Path.Combine (facadesDir, bcf.Name); - break; - - default: - Log.Debug ("unsupported"); - fullFilePath = String.Empty; - break; - } - - Log.DebugLine ($" BCL assembly {bcf.Name}"); - if (String.IsNullOrEmpty (fullFilePath)) - throw new InvalidOperationException ($"Unsupported BCL file type {bcf.Type}"); - - AssemblyName aname = AssemblyName.GetAssemblyName (fullFilePath); - string? version = bcf.Version ?? String.Empty; - if (String.IsNullOrEmpty (version) && !Runtimes.FrameworkListVersionOverrides.TryGetValue (bcf.Name, out version) || version == null) - version = aname.Version?.ToString () ?? "0.0.0"; - - return new XElement ( - "File", - new XAttribute ("AssemblyName", aname.Name ?? "Unknown"), - new XAttribute ("Version", version), - new XAttribute ("PublicKeyToken", String.Join (String.Empty, aname.GetPublicKeyToken ()?.Select (b => b.ToString ("x2")) ?? new string[]{})), - new XAttribute ("ProcessorArchitecture", aname.ProcessorArchitecture.ToString ()) - ); - } - } - - bool InstallBCL (Context context) - { - string redistListDir = MonoRuntimesHelpers.BCLRedistListDestinationDir; - - foreach (KeyValuePair kvp in MonoRuntimesHelpers.BCLDestinationDirs) { - Utilities.CreateDirectory (kvp.Value); - } - - foreach (KeyValuePair kvp in MonoRuntimesHelpers.BCLFacadesDestinationDirs) { - Utilities.CreateDirectory (kvp.Value); - } - - Utilities.CreateDirectory (redistListDir); - - StatusStep (context, "Installing Android BCL assemblies"); - EnsureAllRuntimes (); - InstallBCLFiles (allRuntimes!.BclFilesToInstall); - - StatusStep (context, "Installing Designer Host BCL assemblies"); - InstallBCLFiles (allRuntimes.DesignerHostBclFilesToInstall); - - StatusStep (context, "Installing Designer Windows BCL assemblies"); - InstallBCLFiles (allRuntimes.DesignerWindowsBclFilesToInstall); - - return GenerateFrameworkList ( - context, - MonoRuntimesHelpers.FrameworkListPath, - MonoRuntimesHelpers.BCLDestinationDirs [BclFileTarget.Android], - MonoRuntimesHelpers.BCLFacadesDestinationDirs [BclFileTarget.Android] - ); - } - - void InstallBCLFiles (List 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 InstallRuntimes (Context context, List enabledRuntimes) - { - StatusStep (context, "Installing tests"); - EnsureAllRuntimes (); - foreach (TestAssembly tasm in allRuntimes!.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.Length > 0) - 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 { "." })) { - 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 || src.Length == 0 || dst.Length == 0) - 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 (); - 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); - } - } - - async Task BuildRuntimes (Context context, List makeArguments) - { - var make = new MakeRunner (context); - - bool result = await make.Run ( - logTag: "mono-runtimes", - workingDirectory: GetWorkingDirectory (context), - arguments: makeArguments - ); - - if (!result) - return false; - - Utilities.SaveAbiChoice (context); - - return true; - } - - string GetWorkingDirectory (Context context) - { - return Path.Combine (context.Properties.GetRequiredValue (KnownProperties.MonoSourceFullPath), "sdks", "builds"); - } - - List GetMakeArguments (Context context, List enabledRuntimes) - { - string workingDirectory = GetWorkingDirectory (context); - return PrepareMakeArguments (context, workingDirectory, enabledRuntimes); - } - - List GetEnabledRuntimes (bool enableLogging) - { - var enabledRuntimes = new List (); - - if (allRuntimes == null) - allRuntimes = new Runtimes (); - return MonoRuntimesHelpers.GetEnabledRuntimes (allRuntimes, enableLogging); - } - - List PrepareMakeArguments (Context context, string workingDirectory, List runtimes) - { - string toolchainsPrefix = Path.Combine (GetProperty (KnownProperties.AndroidToolchainDirectory), "toolchains"); - - var ret = new List { - "ENABLE_ANDROID=1", - $"CONFIGURATION={Configurables.Defaults.MonoSdksConfiguration}", - "IGNORE_PROVISION_MXE=false", - "IGNORE_PROVISION_ANDROID=true", - $"ANDROID_CMAKE_VERSION={GetProperty (KnownProperties.AndroidCmakeVersionPath)}", - $"ANDROID_NDK_VERSION=r{BuildAndroidPlatforms.AndroidNdkVersion}", - $"ANDROID_SDK_VERSION_armeabi-v7a={BuildAndroidPlatforms.NdkMinimumAPILegacy32}", - $"ANDROID_SDK_VERSION_arm64-v8a={BuildAndroidPlatforms.NdkMinimumAPI}", - $"ANDROID_SDK_VERSION_x86={BuildAndroidPlatforms.NdkMinimumAPILegacy32}", - $"ANDROID_SDK_VERSION_x86_64={BuildAndroidPlatforms.NdkMinimumAPI}", - $"ANDROID_TOOLCHAIN_DIR={GetProperty (KnownProperties.AndroidToolchainDirectory)}", - $"ANDROID_TOOLCHAIN_CACHE_DIR={GetProperty (KnownProperties.AndroidToolchainCacheDirectory)}", - $"ANDROID_TOOLCHAIN_PREFIX={toolchainsPrefix}", - $"MXE_PREFIX_DIR={GetProperty (KnownProperties.AndroidToolchainDirectory)}", - $"MXE_SRC={Configurables.Paths.MxeSourceDir}" - }; - - runtimeBuildMakeOptions = new List (ret); - runtimeBuildMakeTargets = new List (); - - List? standardArgs = null; - var make = new MakeRunner (context); - make.GetStandardArguments (ref standardArgs, workingDirectory); - if (standardArgs != null && standardArgs.Count > 0) { - runtimeBuildMakeOptions.AddRange (standardArgs); - } - - AddHostTargets (runtimes.Where (r => r is MonoHostRuntime)); - AddPackageTargets (runtimes.Where (r => r is MonoJitRuntime)); - AddPackageTargets (runtimes.Where (r => r is MonoCrossRuntime)); - ret.Add ("package-android-bcl"); - AddTargets ("provision-llvm", runtimes.Where (r => r is LlvmRuntime)); - - return ret; - - void AddHostTargets (IEnumerable items) - { - AddTargets ("package-android-host", items); - } - - void AddPackageTargets (IEnumerable items) - { - AddTargets ("package-android", items); - } - - void AddTargets (string prefix, IEnumerable items) - { - foreach (Runtime runtime in items) { - string target = $"{prefix}-{runtime.Name}"; - ret.Add (target); - runtimeBuildMakeTargets!.Add (target); - } - } - - string GetProperty (string name) - { - return context.Properties.GetRequiredValue (name); - } - } - - void MonoRuntime_RuleGenerator (GeneratedMakeRulesFile file, StreamWriter ruleWriter) - { - const string OptionsVariableName = "MONO_RUNTIME_SDKS_MAKE_OPTIONS"; - - if (runtimeBuildMakeOptions == null || runtimeBuildMakeTargets == null) { - List enabledRuntimes = GetEnabledRuntimes (false); - GetMakeArguments (Context.Instance, enabledRuntimes); - - if (runtimeBuildMakeOptions == null || runtimeBuildMakeTargets == null) { - Log.DebugLine ("No rules to generate for Mono SDKs build"); - return; - } - } - - ruleWriter.Write ($"{OptionsVariableName} ="); - foreach (string opt in runtimeBuildMakeOptions) { - ruleWriter.WriteLine (" \\"); - ruleWriter.Write ($"\t{opt}"); - } - ruleWriter.WriteLine (); - - foreach (string target in runtimeBuildMakeTargets) { - ruleWriter.WriteLine (); - ruleWriter.WriteLine ($"sdks-{target}:"); - ruleWriter.WriteLine ($"\t$(MAKE) $({OptionsVariableName}) {target}"); - } - - ruleWriter.WriteLine (); - ruleWriter.WriteLine ("sdks-all:"); - - string allTargets = String.Join (" ", runtimeBuildMakeTargets); - ruleWriter.WriteLine ($"\t$(MAKE) $({OptionsVariableName}) {allTargets}"); - } - - void StatusMessage (Context context, string indent, string message) - { - Log.StatusLine ($"{indent}{context.Characters.Bullet} {message}"); - } - - void StatusStep (Context context, string name) - { - StatusMessage (context, StatusIndent, name);; - } - - void StatusSubStep (Context context, string name) - { - StatusMessage (context, SubStatusIndent, name);; - } - - bool CheckFileExists (string filePath, bool required) - { - if (File.Exists (filePath)) - return true; - - if (required) - throw new InvalidOperationException ($"Required file not found: {filePath}"); - - return false; - } - } -} diff --git a/build-tools/xaprepare/xaprepare/Steps/Step_ChangeLibMonoSgenDylibID.MacOS.cs b/build-tools/xaprepare/xaprepare/Steps/Step_ChangeLibMonoSgenDylibID.MacOS.cs deleted file mode 100644 index e4262374483..00000000000 --- a/build-tools/xaprepare/xaprepare/Steps/Step_ChangeLibMonoSgenDylibID.MacOS.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Threading.Tasks; - -namespace Xamarin.Android.Prepare -{ - class Step_ChangeLibMonoSgenDylibID : Step - { - public Step_ChangeLibMonoSgenDylibID () - : base ("Changing Mono dynamic library ID") - {} - - protected override async Task Execute (Context context) - { - string xcrun = context.OS.Which ("xcrun"); - - var libs = new string[] { - Path.Combine (Configurables.Paths.HostRuntimeDir, Configurables.Paths.UnstrippedLibMonoSgenName), - Path.Combine (Configurables.Paths.HostRuntimeDir, Configurables.Paths.StrippedLibMonoSgenName), - }; - - bool result = true; - Log.StatusLine ("Changing id for:"); - foreach (string libPath in libs) { - if (!Utilities.FileExists (libPath)) { - Log.StatusLine (" not found", ConsoleColor.Magenta); - continue; - } - - if (!await ChangeID (libPath)) { - Log.StatusLine (" failed", ConsoleColor.Magenta); - result = false; - } - } - - return result; - - Task ChangeID (string path) - { - return Task.Run(() => { - Log.DebugLine ($"Changing dylib id for {path}"); - Log.StatusLine ($" {context.Characters.Bullet} {Utilities.GetRelativePath (BuildPaths.XamarinAndroidSourceRoot, path)}"); - var runner = new ProcessRunner (xcrun, "install_name_tool", "-id", "@loader_path/libmonosgen-2.0.dylib", path); - return runner.Run (); - }); - } - } - } -} diff --git a/build-tools/xaprepare/xaprepare/Steps/Step_DownloadMonoArchive.cs b/build-tools/xaprepare/xaprepare/Steps/Step_DownloadMonoArchive.cs deleted file mode 100644 index ebe0278e49a..00000000000 --- a/build-tools/xaprepare/xaprepare/Steps/Step_DownloadMonoArchive.cs +++ /dev/null @@ -1,152 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Net; -using System.Reflection; -using System.Threading.Tasks; -using System.Xml.Linq; - -namespace Xamarin.Android.Prepare -{ - class Step_DownloadMonoArchive : StepWithDownloadProgress - { - public Step_DownloadMonoArchive () - : base ("Downloading Mono archive") - {} - - protected override async Task Execute (Context context) - { - bool success = await DownloadMonoArchive (context); - - if (!success) { - Log.InfoLine ("Mono archive not present"); - return true; - } else - Utilities.SaveAbiChoice (context); - - context.MonoArchiveDownloaded = success; - return true; - } - - async Task DownloadMonoArchive (Context context) - { - if (context.ForceRuntimesBuild) { - Log.StatusLine ("Mono runtime rebuild forced, Mono Archive download skipped"); - return false; - } - - Log.StatusLine ("Checking if all runtime files are present"); - var allRuntimes = new Runtimes (); - if (MonoRuntimesHelpers.AreRuntimeItemsInstalled (context, allRuntimes)) { - - // User might have changed the set of ABIs to build, we need to check and rebuild if necessary - if (!Utilities.AbiChoiceChanged (context)) { - Log.StatusLine ("Mono runtimes already present and complete. No need to download or build."); - return true; - } - - Log.StatusLine ("Mono already present, but the choice of ABIs changed since previous build, runtime refresh is necessary"); - } - Log.Instance.StatusLine ($" {Context.Instance.Characters.Bullet} some files are missing, download and extraction required"); - - string localPath, archiveFileName; - if (string.IsNullOrEmpty (context.MonoArchiveCustomUrl)) { - localPath = Configurables.Paths.MonoArchiveLocalPath; - archiveFileName = Configurables.Paths.MonoArchiveFileName; - } else { - var uri = new Uri (context.MonoArchiveCustomUrl); - archiveFileName = Path.GetFileName (uri.LocalPath); - localPath = Path.Combine (context.Properties.GetRequiredValue (KnownProperties.AndroidToolchainCacheDirectory), archiveFileName); - } - - bool result = false; - for (uint i = 0; i < 3; i++) { - result = await DownloadAndUpackIfNeeded ( - context, - "Mono", - context.MonoArchiveCustomUrl, - localPath, - archiveFileName, - Configurables.Paths.MonoSDKSOutputDir - ); - - if (result) - break; - } - - if (!result) - return false; - - for (uint i = 0; i < 3; i++) { - result = await DownloadAndUpackIfNeeded ( - context, - "Windows Mono", - customUrl: String.Empty, - localPath: Configurables.Paths.MonoArchiveWindowsLocalPath, - archiveFileName: Configurables.Paths.MonoArchiveWindowsFileName, - destinationDirectory: Configurables.Paths.BCLWindowsOutputDir - ); - - if (result) - break; - } - - return result; - } - - async Task DownloadAndUpackIfNeeded (Context context, string name, string customUrl, string localPath, string archiveFileName, string destinationDirectory) - { - if (File.Exists (localPath)) { - Log.StatusLine ($"{name} archive already downloaded"); - } else { - Utilities.DeleteFileSilent (localPath); - - var url = string.IsNullOrEmpty (customUrl) ? - new Uri (Configurables.Urls.MonoArchive_BaseUri, archiveFileName) : - new Uri (customUrl); - Log.StatusLine ($"Downloading {name} archive from {url}"); - - (bool success, ulong size, HttpStatusCode status) = await Utilities.GetDownloadSizeWithStatus (url); - if (!success) { - if (status == HttpStatusCode.NotFound) - Log.Info ($"{name} archive URL not found"); - else - Log.Info ($"Failed to obtain {name} archive size. HTTP status code: {status} ({(int)status})"); - Log.InfoLine (". Mono runtimes will be rebuilt"); - return false; - } - - DownloadStatus downloadStatus = Utilities.SetupDownloadStatus (context, size, context.InteractiveSession); - Log.StatusLine ($" {context.Characters.Link} {url}", ConsoleColor.White); - await Download (context, url, localPath, $"{name} Archive", archiveFileName, downloadStatus); - - if (!File.Exists (localPath)) { - Log.InfoLine ($"Download of {name} archive from {url} failed"); - return false; - } - } - - string tempDir = $"{destinationDirectory}.tmp"; - if (!await Utilities.Unpack (localPath, tempDir, cleanDestinatioBeforeUnpacking: true)) { - Utilities.DeleteFileSilent (localPath); - Utilities.DeleteDirectorySilent (destinationDirectory); - Log.WarningLine ($"Failed to unpack {name} archive {localPath}"); - Utilities.DeleteFileSilent (localPath); - return false; - } - - Log.DebugLine ($"Moving unpacked Mono archive from {tempDir} to {destinationDirectory}"); - try { - Utilities.MoveDirectoryContentsRecursively (tempDir, destinationDirectory, resetFileTimestamp: true); - } finally { - Utilities.DeleteDirectorySilent (tempDir); - // Clean up zip after extraction if running on a hosted azure pipelines agent. - if (context.IsRunningOnHostedAzureAgent) - Utilities.DeleteFileSilent (localPath); - } - - return true; - } - } -} diff --git a/build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.cs b/build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.cs index 2a29cfa14fd..aaa16fb9225 100644 --- a/build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.cs +++ b/build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.cs @@ -55,7 +55,6 @@ protected override async Task Execute (Context context) if (onlyRequired) { return new List { Get_SourceLink_Json (context), - Get_MonoGitHash_props (context), Get_Configuration_Generated_Props (context), Get_Cmake_XA_Build_Configuration (context), }; @@ -67,9 +66,6 @@ protected override async Task Execute (Context context) Get_Cmake_XA_Build_Configuration (context), Get_Ndk_projitems (context), Get_XABuildConfig_cs (context), - Get_mingw_32_cmake (context), - Get_mingw_64_cmake (context), - Get_MonoGitHash_props (context), Get_Omnisharp_Json (context), }; } @@ -79,7 +75,6 @@ protected override async Task Execute (Context context) return null; var steps = new List { - new GeneratedProfileAssembliesProjitemsFile (Configurables.Paths.ProfileAssembliesProjitemsPath), new GeneratedMonoAndroidProjitemsFile (), }; @@ -133,18 +128,8 @@ GeneratedFile Get_Configuration_OperatingSystem_props (Context context) { "@OS_NAME@", context.OS.Name ?? String.Empty }, { "@HOST_OS_FLAVOR@", context.OS.Flavor ?? String.Empty }, { "@OS_RELEASE@", context.OS.Release ?? String.Empty }, - { "@HOST_TRIPLE@", context.OS.Triple ?? String.Empty }, - { "@HOST_TRIPLE32@", context.OS.Triple32 ?? String.Empty }, - { "@HOST_TRIPLE64@", context.OS.Triple64 ?? String.Empty }, { "@HOST_CPUS@", context.OS.CPUCount.ToString () }, { "@ARCHITECTURE_BITS@", context.OS.Is64Bit ? "64" : "32" }, - { "@HOST_CC@", context.OS.CC ?? String.Empty }, - { "@HOST_CXX@", context.OS.CXX ?? String.Empty }, - { "@HOST_CC32@", context.OS.CC32 ?? String.Empty }, - { "@HOST_CC64@", context.OS.CC64 ?? String.Empty }, - { "@HOST_CXX32@", context.OS.CXX32 ?? String.Empty }, - { "@HOST_CXX64@", context.OS.CXX64 ?? String.Empty }, - { "@HOST_HOMEBREW_PREFIX@", context.OS.HomebrewPrefix ?? String.Empty }, { "@JavaSdkDirectory@", context.OS.JavaHome }, { "@javac@", context.OS.JavaCPath }, { "@java@", context.OS.JavaPath }, @@ -213,40 +198,6 @@ GeneratedFile Get_Ndk_projitems (Context context) ); } - GeneratedFile Get_mingw_32_cmake (Context context) - { - return Get_mingw_cmake (context, Configurables.Paths.Mingw32CmakeTemplatePath, Configurables.Paths.Mingw32CmakePath); - } - - GeneratedFile Get_mingw_64_cmake (Context context) - { - return Get_mingw_cmake (context, Configurables.Paths.Mingw64CmakeTemplatePath, Configurables.Paths.Mingw64CmakePath); - } - - GeneratedFile Get_mingw_cmake (Context context, string input, string output) - { - var replacements = new Dictionary (StringComparer.Ordinal) { - { "@HOMEBREW_PREFIX@", context.OS.HomebrewPrefix ?? String.Empty }, - }; - - return new GeneratedPlaceholdersFile (replacements, Path.Combine (input), Path.Combine (output)); - } - - public GeneratedFile Get_MonoGitHash_props (Context context) - { - const string OutputFileName = "MonoGitHash.props"; - - var replacements = new Dictionary (StringComparer.Ordinal) { - { "@MONO_COMMIT_HASH@", context.BuildInfo.MonoHash } - }; - - return new GeneratedPlaceholdersFile ( - replacements, - Path.Combine (Configurables.Paths.BootstrapResourcesDir, $"{OutputFileName}.in"), - Path.Combine (Configurables.Paths.BuildBinDir, OutputFileName) - ); - } - public GeneratedFile Get_Omnisharp_Json (Context context) { const string OutputFileName = "omnisharp.json"; diff --git a/build-tools/xaprepare/xaprepare/Steps/Step_InstallMonoRuntimes.cs b/build-tools/xaprepare/xaprepare/Steps/Step_InstallMonoRuntimes.cs deleted file mode 100644 index 287d5e56a67..00000000000 --- a/build-tools/xaprepare/xaprepare/Steps/Step_InstallMonoRuntimes.cs +++ /dev/null @@ -1,431 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Net; -using System.Reflection; -using System.Threading.Tasks; -using System.Xml.Linq; - -namespace Xamarin.Android.Prepare -{ - class Step_InstallMonoRuntimes : StepWithDownloadProgress - { - const string StatusIndent = " "; - const string SubStatusIndent = " "; - - Runtimes? allRuntimes; - - public Step_InstallMonoRuntimes () - : base ("Installing Mono runtimes") - { - } - - protected override async Task Execute (Context context) - { - List enabledRuntimes = GetEnabledRuntimes (enableLogging: false); - if (enabledRuntimes.Count == 0) { - Log.StatusLine ("No runtimes to build/install"); - return true; - } - - if (!context.MonoArchiveDownloaded) { - // https://github.com/xamarin/xamarin-android/pull/3816 - throw new NotImplementedException ("Unable to build mono runtimes from sources."); - } - - Log.StatusLine ("Checking if all runtime files are present"); - var allRuntimes = new Runtimes (); - if (MonoRuntimesHelpers.AreRuntimeItemsInstalled (context, allRuntimes)) { - - // User might have changed the set of ABIs to build, we need to check and rebuild if necessary - if (!Utilities.AbiChoiceChanged (context)) { - Log.StatusLine ("Mono runtimes already present and complete. No need to download or build."); - return true; - } - - Log.StatusLine ("Mono already present, but the choice of ABIs changed since previous build, runtime refresh is necessary"); - } - Log.Instance.StatusLine ($" {Context.Instance.Characters.Bullet} some files are missing, rebuild/reinstall forced"); - - CleanupBeforeInstall (); - Log.StatusLine (); - - string managedRuntime = context.Properties.GetRequiredValue (KnownProperties.ManagedRuntime); - bool haveManagedRuntime = !String.IsNullOrEmpty (managedRuntime); - if (!await ConjureXamarinCecilAndRemapRef (context, haveManagedRuntime, managedRuntime)) - return false; - - if (!await InstallRuntimes (context, enabledRuntimes)) - return false; - - if (!InstallBCL (context)) - return false; - - if (!InstallUtilities (context, haveManagedRuntime, managedRuntime)) - return false; - - Utilities.PropagateXamarinAndroidCecil (context); - - return true; - } - - void EnsureAllRuntimes () - { - if (allRuntimes == null) - throw new InvalidOperationException ("Step not initialized properly, allRuntimes is not set"); - } - - void CleanupBeforeInstall () - { - EnsureAllRuntimes (); - foreach (string dir in allRuntimes!.OutputDirectories) { - Utilities.DeleteDirectorySilent (dir); - } - } - - async Task ConjureXamarinCecilAndRemapRef (Context context, bool haveManagedRuntime, string managedRuntime) - { - StatusStep (context, "Building remap-assembly-ref"); - bool result = await Utilities.BuildRemapRef (context, haveManagedRuntime, managedRuntime, quiet: true); - if (!result) - return false; - - var msbuild = new MSBuildRunner (context); - StatusStep (context, "Building conjure-xamarin-android-cecil"); - string projectPath = Path.Combine (Configurables.Paths.BuildToolsDir, "conjure-xamarin-android-cecil", "conjure-xamarin-android-cecil.csproj"); - result = await msbuild.Run ( - projectPath: projectPath, - logTag: "conjure-xamarin-android-cecil", - binlogName: "build-conjure-xamarin-android-cecil" - ); - - if (!result) { - Log.ErrorLine ("Failed to build conjure-xamarin-android-cecil"); - return false; - } - - StatusStep (context, "Conjuring Xamarin.Android.Cecil and Xamari.Android.Cecil.Mdb"); - string conjurer = Path.Combine (Configurables.Paths.BuildBinDir, "conjure-xamarin-android-cecil.dll"); - - result = Utilities.RunManagedCommand ( - conjurer, // command - BuildPaths.XamarinAndroidSourceRoot, // workingDirectory - true, // ignoreEmptyArguments - - // arguments - Configurables.Paths.MonoProfileToolsDir, // source dir - Configurables.Paths.BuildBinDir // destination dir - ); - - StatusStep (context, "Re-signing Xamarin.Android.Cecil.dll"); - var sn = new SnRunner (context); - string snkPath = Path.Combine (BuildPaths.XamarinAndroidSourceRoot, "mono.snk"); - string assemblyPath = Path.Combine (Configurables.Paths.BuildBinDir, "Xamarin.Android.Cecil.dll"); - result = await sn.ReSign (snkPath, assemblyPath, $"sign-xamarin-android-cecil"); - if (!result) { - Log.ErrorLine ("Failed to re-sign Xamarin.Android.Cecil.dll"); - return false; - } - var classicInstallMSBuildDir = Path.Combine (Configurables.Paths.XAInstallPrefix, "xbuild", "Xamarin", "Android"); - Utilities.CreateDirectory (classicInstallMSBuildDir); - Utilities.CopyFile (assemblyPath, Path.Combine (classicInstallMSBuildDir, "Xamarin.Android.Cecil.dll")); - - StatusStep (context, "Re-signing Xamarin.Android.Cecil.Mdb.dll"); - assemblyPath = Path.Combine (Configurables.Paths.BuildBinDir, "Xamarin.Android.Cecil.Mdb.dll"); - result = await sn.ReSign (snkPath, assemblyPath, $"sign-xamarin-android-cecil-mdb"); - if (!result) { - Log.ErrorLine ("Failed to re-sign Xamarin.Android.Cecil.Mdb.dll"); - return false; - } - - Utilities.CopyFile (assemblyPath, Path.Combine (classicInstallMSBuildDir, "Xamarin.Android.Cecil.Mdb.dll")); - - return true; - } - - bool InstallUtilities (Context context, bool haveManagedRuntime, string managedRuntime) - { - string destDir = MonoRuntimesHelpers.UtilitiesDestinationDir; - - Utilities.CreateDirectory (destDir); - - 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"); - EnsureAllRuntimes (); - 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.RunManagedCommand ( - remapper, // command - BuildPaths.XamarinAndroidSourceRoot, // workingDirectory - true, // ignoreEmptyArguments - - // arguments - 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; - } - - bool GenerateFrameworkList (Context contex, string filePath, string bclDir, string facadesDir) - { - Log.DebugLine ($"Generating {filePath}"); - - EnsureAllRuntimes (); - var contents = new XElement ( - "FileList", - new XAttribute ("Redist", Runtimes.FrameworkListRedist), - new XAttribute ("Name", Runtimes.FrameworkListName), - allRuntimes!.BclFilesToInstall.Where (f => f.Type == BclFileType.FacadeAssembly || f.Type == BclFileType.ProfileAssembly).Select (f => ToFileElement (f)) - ); - contents.Save (filePath); - return true; - - XElement ToFileElement (BclFile bcf) - { - Log.Debug ("Writing "); - string fullFilePath; - - switch (bcf.Type) { - case BclFileType.ProfileAssembly: - fullFilePath = Path.Combine (bclDir, bcf.Name); - Log.Debug ("profile"); - break; - - case BclFileType.FacadeAssembly: - Log.Debug ("facade"); - fullFilePath = Path.Combine (facadesDir, bcf.Name); - break; - - default: - Log.Debug ("unsupported"); - fullFilePath = String.Empty; - break; - } - - Log.DebugLine ($" BCL assembly {bcf.Name}"); - if (String.IsNullOrEmpty (fullFilePath)) - throw new InvalidOperationException ($"Unsupported BCL file type {bcf.Type}"); - - AssemblyName aname = AssemblyName.GetAssemblyName (fullFilePath); - string? version = bcf.Version ?? String.Empty; - if (String.IsNullOrEmpty (version) && !Runtimes.FrameworkListVersionOverrides.TryGetValue (bcf.Name, out version) || version == null) - version = aname.Version?.ToString () ?? "0.0.0"; - - return new XElement ( - "File", - new XAttribute ("AssemblyName", aname.Name ?? "Unknown"), - new XAttribute ("Version", version), - new XAttribute ("PublicKeyToken", String.Join (String.Empty, aname.GetPublicKeyToken ()?.Select (b => b.ToString ("x2")) ?? new string[]{})), - new XAttribute ("ProcessorArchitecture", aname.ProcessorArchitecture.ToString ()) - ); - } - } - - bool InstallBCL (Context context) - { - string redistListDir = MonoRuntimesHelpers.BCLRedistListDestinationDir; - - foreach (KeyValuePair kvp in MonoRuntimesHelpers.BCLDestinationDirs) { - Utilities.CreateDirectory (kvp.Value); - } - - foreach (KeyValuePair kvp in MonoRuntimesHelpers.BCLFacadesDestinationDirs) { - Utilities.CreateDirectory (kvp.Value); - } - - Utilities.CreateDirectory (redistListDir); - - StatusStep (context, "Installing Android BCL assemblies"); - EnsureAllRuntimes (); - InstallBCLFiles (allRuntimes!.BclFilesToInstall); - - StatusStep (context, "Installing Designer Host BCL assemblies"); - InstallBCLFiles (allRuntimes.DesignerHostBclFilesToInstall); - - StatusStep (context, "Installing Designer Windows BCL assemblies"); - InstallBCLFiles (allRuntimes.DesignerWindowsBclFilesToInstall); - - return GenerateFrameworkList ( - context, - MonoRuntimesHelpers.FrameworkListPath, - MonoRuntimesHelpers.BCLDestinationDirs [BclFileTarget.Android], - MonoRuntimesHelpers.BCLFacadesDestinationDirs [BclFileTarget.Android] - ); - } - - void InstallBCLFiles (List 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 InstallRuntimes (Context context, List enabledRuntimes) - { - StatusStep (context, "Installing tests"); - EnsureAllRuntimes (); - foreach (TestAssembly tasm in allRuntimes!.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.Length > 0) - 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 { "." })) { - 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.DisplayName}"); - - 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 || src.Length == 0 || dst.Length == 0) - 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 (); - if (monoRuntime == null || !monoRuntime.CanStripNativeLibrary || !rtf.Strip) - return true; - - if (String.IsNullOrEmpty (monoRuntime.Strip)) { - Log.WarningLine ($"Binary stripping impossible, runtime {monoRuntime.DisplayName} doesn't define the strip command"); - return true; - } - - if (context.OS.IsWindows && (context.IsWindowsCrossAotAbi (monoRuntime.Name) || context.IsMingwHostAbi (monoRuntime.Name))) { - Log.WarningLine ($"Unable to strip '{monoRuntime.DisplayName}' on Windows."); - 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 {monoRuntime.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); - } - } - - List GetEnabledRuntimes (bool enableLogging) - { - var enabledRuntimes = new List (); - - if (allRuntimes == null) - allRuntimes = new Runtimes (); - return MonoRuntimesHelpers.GetEnabledRuntimes (allRuntimes, enableLogging); - } - - void StatusMessage (Context context, string indent, string message) - { - Log.StatusLine ($"{indent}{context.Characters.Bullet} {message}"); - } - - void StatusStep (Context context, string name) - { - StatusMessage (context, StatusIndent, name); - } - - void StatusSubStep (Context context, string name) - { - StatusMessage (context, SubStatusIndent, name); - } - - bool CheckFileExists (string filePath, bool required) - { - if (File.Exists (filePath)) - return true; - - if (required) - throw new InvalidOperationException ($"Required file not found: {filePath}"); - - return false; - } - } -} diff --git a/build-tools/xaprepare/xaprepare/Steps/Step_PrepareBundle.cs b/build-tools/xaprepare/xaprepare/Steps/Step_PrepareBundle.cs deleted file mode 100644 index 9de450bb0e3..00000000000 --- a/build-tools/xaprepare/xaprepare/Steps/Step_PrepareBundle.cs +++ /dev/null @@ -1,126 +0,0 @@ -using System; -using System.IO; -using System.Net; -using System.Threading.Tasks; - -namespace Xamarin.Android.Prepare -{ - partial class Step_PrepareBundle : StepWithDownloadProgress - { - static Uri BundleUriPrefix => Configurables.Urls.Bundle_XABundleDownloadPrefix; - static string BundleFileName => Configurables.Paths.XABundleFileName; - static bool osSupportsMonoBuild; - - public Step_PrepareBundle () - : base ("Preparing the binary bundle") - { - InitOS (); - } - - protected override async Task Execute (Context context) - { - if (context.ForceRuntimesBuild) { - if (osSupportsMonoBuild) { - Log.InfoLine ("Rebuilding Mono runtimes as requested"); - return false; - } - - Log.InfoLine ($"Forced Mono runtimes rebuild requested but rebuilding on {context.OS.Type} is currently not supported."); - } - - string localPackagePath = Configurables.Paths.BundleArchivePath; - Log.DebugLine ($"Local bundle path: {localPackagePath}"); - - if (File.Exists (localPackagePath)) { - Log.StatusLine ("Xamarin.Android Bundle archive already downloaded"); - } else { - if (!String.IsNullOrEmpty (context.XABundlePath)) { - // User indicated they wanted to use a specific bundle that's supposed to be on disk. It's not (or - // it's invalid) and that means we have no way of getting it - we can't download the default one - // since that was not the intention behind overriding the location. Thus, we error out. - Log.DebugLine ($"Bundle directory from command line: {context.XABundlePath}"); - throw new InvalidOperationException ($"Xamarin.Android bundle indicated on the command line does not exist ({context.XABundlePath})"); - } - - var bundleUrl = new Uri (BundleUriPrefix, BundleFileName); - - Log.StatusLine ("Bundle URL: ", $"{bundleUrl}", tailColor: ConsoleColor.Cyan); - - HttpStatusCode status; - bool success; - ulong size; - - (success, size, status) = await Utilities.GetDownloadSizeWithStatus (bundleUrl); - if (!success) { - if (status == HttpStatusCode.NotFound) { - if (osSupportsMonoBuild) - Log.StatusLine (" not found, will need to rebuild"); - else - Log.ErrorLine ($" not found, rebuilding on {context.OS.Type} is not currently supported"); - return false; - } - - if (String.IsNullOrEmpty (bundle404Message)) - throw new InvalidOperationException ($"Failed to access bundle at {bundleUrl} (HTTP status: {status})"); - else - throw new InvalidOperationException (bundle404Message); - } - - DownloadStatus downloadStatus = Utilities.SetupDownloadStatus (context, size, context.InteractiveSession); - Log.StatusLine ($" {context.Characters.Link} {bundleUrl}", ConsoleColor.White); - await Download (context, bundleUrl, localPackagePath, "Xamarin.Android Bundle", Path.GetFileName (localPackagePath), downloadStatus); - - if (!File.Exists (localPackagePath)) { - Log.ErrorLine ($"Download of Xamarin.Android Bundle from {bundleUrl} failed."); - return false; - } - } - - Log.StatusLine ($"Unpacking bundle to {Utilities.GetRelativePath (BuildPaths.XamarinAndroidSourceRoot, Configurables.Paths.BundleInstallDir)}"); - string tempDir = $"{Configurables.Paths.BundleInstallDir}-bundle.temp"; - try { - if (!await Utilities.Unpack (localPackagePath, tempDir, cleanDestinatioBeforeUnpacking: true)) { - Log.WarningLine ("Failed to unpack bundle, will need to rebuild"); - return false; - } - - Log.DebugLine ($"Moving unpacked bundle from {tempDir} to {Configurables.Paths.BundleInstallDir}"); - Utilities.MoveDirectoryContentsRecursively (tempDir, Configurables.Paths.BundleInstallDir, resetFileTimestamp: true, ignoreDeletionErrors: true); - } finally { - Utilities.DeleteDirectorySilent (tempDir); - } - - string managedRuntime = context.Properties.GetRequiredValue (KnownProperties.ManagedRuntime); - bool haveManagedRuntime = !String.IsNullOrEmpty (managedRuntime); - if (!await Utilities.BuildRemapRef (context, haveManagedRuntime, managedRuntime)) - return false; - - Utilities.PropagateXamarinAndroidCecil (context); - - if (String.IsNullOrEmpty (context.XABundleCopyDir)) - return HaveEverything (); - - string destPackagePath = Path.Combine (context.XABundleCopyDir, Path.GetFileName (localPackagePath)); - Log.DebugLine ($"Copy of the XA bundle was requested to be created at {destPackagePath}"); - if (Utilities.FileExists (destPackagePath)) { - Log.DebugLine ("Bundle copy already exists"); - return HaveEverything (); - } - - // Utilities.FileExists above will return `false` for a dangling symlink at `destPackagePath`, doesn't hurt - // to remove it here just in case - Utilities.DeleteFileSilent (destPackagePath); - Utilities.CopyFile (localPackagePath, destPackagePath); - - return HaveEverything (); - - bool HaveEverything () - { - bool ret = MonoRuntimesHelpers.AllBundleItemsPresent (new Runtimes ()); - if (!ret) - Log.Instance.StatusLine ($"Some bundle files are missing, download/rebuild/reinstall forced"); - return ret; - } - } - } -} diff --git a/build-tools/xaprepare/xaprepare/Steps/Step_PrepareExternal.cs b/build-tools/xaprepare/xaprepare/Steps/Step_PrepareExternal.cs deleted file mode 100644 index b49a3592d65..00000000000 --- a/build-tools/xaprepare/xaprepare/Steps/Step_PrepareExternal.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Collections.Generic; -using System.IO; -using System.Threading.Tasks; - -namespace Xamarin.Android.Prepare -{ - partial class Step_PrepareExternal : Step - { - public Step_PrepareExternal () - : base ("Preparing external components") - {} - - protected override async Task Execute (Context context) - { - var msbuild = new MSBuildRunner (context); - - string slnPath = Path.Combine (Configurables.Paths.ExternalDir, "debugger-libs", "debugger-libs.sln"); - bool result = await msbuild.Restore ( - projectPath: slnPath, - logTag: "debugger-libs-restore", - binlogName: "prepare-debugger-libs-restore" - ); - - if (!result) - return false; - - return await msbuild.Restore ( - projectPath: Configurables.Paths.ExternalXamarinAndroidToolsSln, - logTag: "xat-restore", - arguments: new List () { "--configfile", Path.Combine (Configurables.Paths.ExternalDir, "xamarin-android-tools", "NuGet.config") }, - binlogName: "prepare-xat-restore" - ); - } - - } -} diff --git a/build-tools/xaprepare/xaprepare/Steps/Step_PrepareExternalGitDependencies.cs b/build-tools/xaprepare/xaprepare/Steps/Step_PrepareExternalGitDependencies.cs index d625f11a4f5..94ad14a17b1 100644 --- a/build-tools/xaprepare/xaprepare/Steps/Step_PrepareExternalGitDependencies.cs +++ b/build-tools/xaprepare/xaprepare/Steps/Step_PrepareExternalGitDependencies.cs @@ -24,15 +24,6 @@ protected override async Task Execute (Context context) foreach (ExternalGitDependency egd in externalDependencies) { Log.StatusLine ($" {context.Characters.Bullet} {egd.Name}"); - if (egd.Owner == "mono" && egd.Name == "mono") { - var genFilesStep = new Step_GenerateFiles (false, true); - var monogitPropsFile = genFilesStep.Get_MonoGitHash_props (context); - Log.Status ("Generating "); - Log.Status (Utilities.GetRelativePath (BuildPaths.XamarinAndroidSourceRoot, monogitPropsFile.OutputPath), ConsoleColor.White); - monogitPropsFile.Generate (context); - continue; - } - string destDir = Path.Combine (Configurables.Paths.ExternalGitDepsDestDir, egd.Name); if (!Directory.Exists (destDir)) { var egdUrl = await GetGitHubURL (egd, git); diff --git a/build-tools/xaprepare/xaprepare/Steps/Step_PrepareImageDependencies.MacOS.cs b/build-tools/xaprepare/xaprepare/Steps/Step_PrepareImageDependencies.MacOS.cs deleted file mode 100644 index 3233740cc8c..00000000000 --- a/build-tools/xaprepare/xaprepare/Steps/Step_PrepareImageDependencies.MacOS.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace Xamarin.Android.Prepare -{ - partial class Step_PrepareImageDependencies - { - partial void GatherMacPackages (List brewTaps, List brewPackages, List pkgUrls) - { - foreach (Program p in Context.Instance.OS.Dependencies) { - var homebrewProgram = p as HomebrewProgram; - if (homebrewProgram == null) - continue; - - if (!String.IsNullOrEmpty (homebrewProgram.HomebrewTapName)) - brewTaps.Add (homebrewProgram.HomebrewTapName); - - if (homebrewProgram.HomebrewFormulaUrl != null) - brewPackages.Add (homebrewProgram.HomebrewFormulaUrl.ToString ()); - else - brewPackages.Add (homebrewProgram.Name); - } - - pkgUrls.Add (Context.Instance.Properties.GetRequiredValue (KnownProperties.MonoDarwinPackageUrl)); - } - } -} diff --git a/build-tools/xaprepare/xaprepare/Steps/Step_PrepareImageDependencies.cs b/build-tools/xaprepare/xaprepare/Steps/Step_PrepareImageDependencies.cs deleted file mode 100644 index 5bbe324e578..00000000000 --- a/build-tools/xaprepare/xaprepare/Steps/Step_PrepareImageDependencies.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using System.Threading.Tasks; - -namespace Xamarin.Android.Prepare -{ - partial class Step_PrepareImageDependencies : Step - { - public Step_PrepareImageDependencies () - : base ("Preparing image dependency script") - {} - -#pragma warning disable CS1998 - protected override async Task Execute (Context context) - { - var toolchainDirs = new List { - Path.GetFileName (context.Properties.GetRequiredValue (KnownProperties.AndroidSdkDirectory)), - Path.GetFileName (context.Properties.GetRequiredValue (KnownProperties.AndroidNdkDirectory)), - }; - - var androidToolchain = new AndroidToolchain (); - var androidPackages = new List (); - foreach (AndroidToolchainComponent component in androidToolchain.Components) { - if (component == null) - continue; - - Uri pkgUrl; - if (component.RelativeUrl != null) - pkgUrl = new Uri (AndroidToolchain.AndroidUri, component.RelativeUrl); - else - pkgUrl = AndroidToolchain.AndroidUri; - pkgUrl = new Uri (pkgUrl, $"{component.Name}.zip"); - androidPackages.Add ($"{pkgUrl} {component.DestDir}"); - } - - var brewTaps = new List (); - var brewPackages = new List (); - var pkgUrls = new List (); - - GatherMacPackages (brewTaps, brewPackages, pkgUrls); - - var sb = new StringBuilder (File.ReadAllText (Configurables.Paths.PackageImageDependenciesTemplate)); - sb.Replace ("@TOOLCHAIN_DIRS@", MakeLines (toolchainDirs)); - sb.Replace ("@PACKAGES@", MakeLines (androidPackages)); - sb.Replace ("@BREW_TAPS@", MakeLines (brewTaps)); - sb.Replace ("@BREWS@", MakeLines (brewPackages)); - sb.Replace ("@PKG_URLS@", MakeLines (pkgUrls)); - - string outputFile = Configurables.Paths.PackageImageDependenciesOutput; - Log.StatusLine ($"Generating ", outputFile, tailColor: ConsoleColor.White); - File.WriteAllText (outputFile, sb.ToString ()); - - return Utilities.MakeExecutable (outputFile, throwOnError: false); - - string MakeLines (List list) - { - return String.Join ("\n", list); - } - } -#pragma warning restore CS1998 - - partial void GatherMacPackages (List brewTaps, List brewPackages, List pkgUrls); - } -} diff --git a/build-tools/xaprepare/xaprepare/Steps/Step_PrepareLocal.cs b/build-tools/xaprepare/xaprepare/Steps/Step_PrepareLocal.cs deleted file mode 100644 index e9ec7ff5f5d..00000000000 --- a/build-tools/xaprepare/xaprepare/Steps/Step_PrepareLocal.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System.Collections.Generic; -using System.IO; -using System.Threading.Tasks; - -namespace Xamarin.Android.Prepare -{ - class Step_PrepareLocal : Step - { - public Step_PrepareLocal () - : base ("Preparing local components") - {} - - - protected override async Task Execute(Context context) - { - var msbuild = new MSBuildRunner (context); - string xfTestPath = Path.Combine (BuildPaths.XamarinAndroidSourceRoot, "tests", "Xamarin.Forms-Performance-Integration", "Xamarin.Forms.Performance.Integration.csproj"); - - return await msbuild.Restore (projectPath: xfTestPath, logTag: "xfperf", binlogName: "prepare-local"); - } - } -} diff --git a/build-tools/xaprepare/xaprepare/Steps/Step_PrepareMSBuild.cs b/build-tools/xaprepare/xaprepare/Steps/Step_PrepareMSBuild.cs deleted file mode 100644 index 73b077b3a54..00000000000 --- a/build-tools/xaprepare/xaprepare/Steps/Step_PrepareMSBuild.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.Collections.Generic; -using System.IO; -using System.Threading.Tasks; - -namespace Xamarin.Android.Prepare -{ - class Step_PrepareMSBuild : Step - { - public Step_PrepareMSBuild () - : base ("Preparing MSbuild") - {} - -#pragma warning disable CS1998 - protected override async Task Execute (Context context) - { - Log.StatusLine (".:! NOT IMPLEMENTED YET !:. (Possibly not needed?)"); - return true; - } -#pragma warning restore CS1998 - } -} diff --git a/build-tools/xaprepare/xaprepare/Steps/Step_PrepareProps.cs b/build-tools/xaprepare/xaprepare/Steps/Step_PrepareProps.cs index 1a85e9cf4b9..75da0887772 100644 --- a/build-tools/xaprepare/xaprepare/Steps/Step_PrepareProps.cs +++ b/build-tools/xaprepare/xaprepare/Steps/Step_PrepareProps.cs @@ -16,18 +16,8 @@ public Step_PrepareProps () #pragma warning disable CS1998 protected override async Task Execute (Context context) { - string monoSourceDir = Configurables.Paths.MonoSourceFullPath; string javaInteropDir = Configurables.Paths.ExternalJavaInteropDir; - LogStep (context, "Copying Mono.Cecil files"); - Utilities.CopyFilesSimple ( - Directory.EnumerateFiles (Path.Combine (javaInteropDir, "external"), "Mono.Cecil*"), - Path.Combine (monoSourceDir, "external") - ); - - LogStep (context, "Copying code signing keys"); - Utilities.CopyFileToDir (Path.Combine (javaInteropDir, "product.snk"), monoSourceDir); - LogStep (context, "Configuring Java.Interop property overrides"); var jiOverrideProps = new GeneratedPlaceholdersFile ( new Dictionary (StringComparer.Ordinal) { diff --git a/build-tools/xaprepare/xaprepare/Steps/Step_ShowEnabledRuntimes.cs b/build-tools/xaprepare/xaprepare/Steps/Step_ShowEnabledRuntimes.cs deleted file mode 100644 index 15595002eec..00000000000 --- a/build-tools/xaprepare/xaprepare/Steps/Step_ShowEnabledRuntimes.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Net; -using System.Reflection; -using System.Threading.Tasks; -using System.Xml.Linq; - -namespace Xamarin.Android.Prepare -{ - class Step_ShowEnabledRuntimes : Step - { - public Step_ShowEnabledRuntimes () - : base ("Configured targets") - { - } - - protected override Task Execute (Context context) - { - List enabledRuntimes = MonoRuntimesHelpers.GetEnabledRuntimes (new Runtimes (), enableLogging: true); - if (enabledRuntimes.Count == 0) - Log.StatusLine ("No runtimes to build/install"); - - return Task.FromResult (true); - } - } -} diff --git a/build-tools/xaprepare/xaprepare/ThirdPartyNotices/mono.cs b/build-tools/xaprepare/xaprepare/ThirdPartyNotices/mono.cs index 742a1d38b64..2a549a76210 100644 --- a/build-tools/xaprepare/xaprepare/ThirdPartyNotices/mono.cs +++ b/build-tools/xaprepare/xaprepare/ThirdPartyNotices/mono.cs @@ -10,268 +10,73 @@ class mono_External_Dependencies_Group : ThirdPartyNoticeGroup protected override bool ShouldInclude (bool includeExternalDeps, bool includeBuildDeps) => includeExternalDeps; public override List Notices => new List { - new mono_mono_mono_TPN (), new mono_mono_cecil_TPN (), - new mono_mono_boringssl_TPN (), - new mono_mono_ikdasm_TPN (), - new mono_mono_ikvm_fork_TPN (), new mono_mono_linker_TPN (), - new mono_mono_NuGet_BuildTasks_TPN (), - new mono_mono_NUnitLite_TPN (), - new mono_mono_rx_net_TPN (), - new mono_mono_Ix_net_TPN (), - new mono_llvm_Group (), }; } class mono_mono_cecil_TPN : ThirdPartyNotice { static readonly Uri url = new Uri ("https://github.com/mono/cecil/"); - static readonly string licenseFile = Path.Combine (Configurables.Paths.MonoSdksTpnPath, "external", "cecil", "LICENSE.txt"); + static readonly string licenseFile = String.Empty; public override string LicenseFile => licenseFile; public override string Name => "mono/cecil"; public override Uri SourceUrl => url; - public override string LicenseText => String.Empty; - } - - class mono_mono_mono_TPN : ThirdPartyNotice - { - static readonly Uri url = new Uri ("https://github.com/mono/"); - static readonly string licenseFile = Path.Combine (Configurables.Paths.MonoSdksTpnPath, "LICENSE"); - - public override string LicenseFile => licenseFile; - public override string Name => "mono/mono"; - public override Uri SourceUrl => url; - public override string LicenseText => String.Empty; - } - - class mono_mono_aspnetwebstack_TPN : ThirdPartyNotice - { - static readonly Uri url = new Uri ("https://github.com/mono/aspnetwebstack/"); - static readonly string licenseFile = Path.Combine (Configurables.Paths.MonoSdksTpnPath, "aspnetwebstack", "License.txt"); - - public override string LicenseFile => licenseFile; - public override string Name => "mono/aspnetwebstack"; - public override Uri SourceUrl => url; - public override string LicenseText => String.Empty; - - public override bool Include (bool includeExternalDeps, bool includeBuildDeps) => includeExternalDeps && includeBuildDeps; - } - - class mono_mono_boringssl_TPN : ThirdPartyNotice - { - static readonly Uri url = new Uri ("https://github.com/mono/boringssl"); - static readonly string licenseFile = Path.Combine (Configurables.Paths.MonoSdksTpnExternalPath, "boringssl", "LICENSE"); - - public override string LicenseFile => licenseFile; - public override string Name => "mono/boringssl"; - public override Uri SourceUrl => url; - public override string LicenseText => String.Empty; - - public override bool Include (bool includeExternalDeps, bool includeBuildDeps) => includeExternalDeps; - } - - class mono_mono_ikdasm_TPN : ThirdPartyNotice - { - static readonly Uri url = new Uri ("https://github.com/mono/ikdasm"); - - public override string LicenseFile => String.Empty; - public override string Name => "mono/ikdasm"; - public override Uri SourceUrl => url; - public override string LicenseText => @" -Copyright (C) 2012 Jeroen Frijters - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. - -Jeroen Frijters -jeroen@frijters.net + public override string LicenseText => @"Copyright (c) 2008 - 2015 Jb Evain +Copyright (c) 2008 - 2011 Novell, Inc. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +""Software""), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. "; - - public override bool Include (bool includeExternalDeps, bool includeBuildDeps) => includeExternalDeps && includeBuildDeps; - } - - class mono_mono_ikvm_fork_TPN : ThirdPartyNotice - { - static readonly Uri url = new Uri ("https://github.com/mono/ikvm-fork/"); - static readonly string licenseFile = Path.Combine (Configurables.Paths.MonoSdksTpnExternalPath, "ikvm", "LICENSE"); - - public override string LicenseFile => licenseFile; - public override string Name => "mono/ikvm-fork"; - public override Uri SourceUrl => url; - public override string LicenseText => String.Empty; - - public override bool Include (bool includeExternalDeps, bool includeBuildDeps) => includeExternalDeps && includeBuildDeps; } class mono_mono_linker_TPN : ThirdPartyNotice { static readonly Uri url = new Uri ("https://github.com/mono/linker/"); - static readonly string licenseFile = Path.Combine (Configurables.Paths.MonoSdksTpnExternalPath, "linker", "LICENSE"); + static readonly string licenseFile = String.Empty; public override string LicenseFile => licenseFile; public override string Name => "mono/linker"; public override Uri SourceUrl => url; - public override string LicenseText => String.Empty; - } - - class mono_mono_NuGet_BuildTasks_TPN : ThirdPartyNotice - { - static readonly Uri url = new Uri ("https://github.com/mono/NuGet.BuildTasks/"); - static readonly string licenseFile = Path.Combine (Configurables.Paths.MonoSdksTpnExternalPath, "nuget-buildtasks", "LICENSE.txt"); - - public override string LicenseFile => licenseFile; - public override string Name => "mono/NuGet.BuildTasks"; - public override Uri SourceUrl => url; - public override string LicenseText => String.Empty; - - public override bool Include (bool includeExternalDeps, bool includeBuildDeps) => includeExternalDeps && includeBuildDeps; - } - - class mono_mono_NUnitLite_TPN : ThirdPartyNotice - { - static readonly Uri url = new Uri ("https://github.com/mono/NUnitLite/"); - static readonly string licenseFile = Path.Combine (Configurables.Paths.MonoSdksTpnExternalPath, "nunit-lite", "NUnitLite-1.0.0", "LICENSE.txt"); - - public override string LicenseFile => licenseFile; - public override string Name => "mono/NUnitLite"; - public override Uri SourceUrl => url; - public override string LicenseText => String.Empty; - - public override bool Include (bool includeExternalDeps, bool includeBuildDeps) => includeExternalDeps; - } - - class mono_mono_rx_net_TPN : ThirdPartyNotice - { - static readonly Uri url = new Uri ("https://github.com/mono/rx/"); - static readonly string licenseFile = Path.Combine (Configurables.Paths.MonoSdksTpnExternalPath, "rx", "Rx", "NET", "Source", "license.txt"); - - public override string LicenseFile => licenseFile; - public override string Name => "mono/rx.net"; - public override Uri SourceUrl => url; - public override string LicenseText => String.Empty; - - public override bool Include (bool includeExternalDeps, bool includeBuildDeps) => includeExternalDeps && includeBuildDeps; - } - - class mono_mono_Ix_net_TPN : ThirdPartyNotice - { - static readonly Uri url = new Uri ("https://github.com/mono/rx/"); - static readonly string licenseFile = Path.Combine (Configurables.Paths.MonoSdksTpnExternalPath, "rx", "Ix", "NET", "license.txt"); - - public override string LicenseFile => licenseFile; - public override string Name => "mono/Ix.net"; - public override Uri SourceUrl => url; - public override string LicenseText => String.Empty; - - public override bool Include (bool includeExternalDeps, bool includeBuildDeps) => includeExternalDeps && includeBuildDeps; - } - - class mono_llvm_Group : ThirdPartyNoticeGroup - { - protected override bool ShouldInclude (bool includeExternalDeps, bool includeBuildDeps) => includeExternalDeps && (includeBuildDeps || Context.Instance.TargetAotAbisEnabled); - - public override List Notices => new List { - new mono_llvm_llvm_TPN (), - new mono_llvm_google_test_TPN (), - new mono_llvm_openbsd_regex_TPN (), - new mono_llvm_pyyaml_tests_TPN (), - new mono_llvm_arm_contributions_TPN (), - new mono_llvm_md5_contributions_TPN (), - }; - } - - class mono_llvm_llvm_TPN : ThirdPartyNotice - { - static readonly Uri url = new Uri ("https://github.com/mono/llvm/"); - static readonly string licenseFile = Path.Combine (Configurables.Paths.MonoLlvmTpnPath, "LICENSE.TXT"); - - public override string LicenseFile => licenseFile; - public override string Name => "mono/llvm"; - public override Uri SourceUrl => url; - public override string LicenseText => String.Empty; - } - - class mono_llvm_google_test_TPN : ThirdPartyNotice - { - static readonly Uri url = new Uri ("https://github.com/mono/llvm/tree/master/utils/unittest/googletest/"); - static readonly string licenseFile = Path.Combine (Configurables.Paths.MonoLlvmTpnPath, "utils", "unittest", "googletest", "LICENSE.TXT"); - - public override string LicenseFile => licenseFile; - public override string Name => "mono/llvm Google Test"; - public override Uri SourceUrl => url; - public override string LicenseText => String.Empty; - } - - class mono_llvm_openbsd_regex_TPN : ThirdPartyNotice - { - static readonly Uri url = new Uri ("https://github.com/mono/llvm/tree/master/lib/Support/"); - static readonly string licenseFile = Path.Combine (Configurables.Paths.MonoLlvmTpnPath, "lib", "Support", "COPYRIGHT.regex"); - - public override string LicenseFile => licenseFile; - public override string Name => "mono/llvm OpenBSD Regex"; - public override Uri SourceUrl => url; - public override string LicenseText => String.Empty; - } - - class mono_llvm_pyyaml_tests_TPN : ThirdPartyNotice - { - static readonly Uri url = new Uri ("https://github.com/mono/llvm/tree/master/test/YAMLParser/"); - static readonly string licenseFile = Path.Combine (Configurables.Paths.MonoLlvmTpnPath, "test", "YAMLParser", "LICENSE.txt"); - - public override string LicenseFile => licenseFile; - public override string Name => "mono/llvm pyyaml tests"; - public override Uri SourceUrl => url; - public override string LicenseText => String.Empty; - } - - class mono_llvm_arm_contributions_TPN : ThirdPartyNotice - { - static readonly Uri url = new Uri ("https://github.com/mono/llvm/tree/master/lib/Target/ARM/"); - static readonly string licenseFile = Path.Combine (Configurables.Paths.MonoLlvmTpnPath, "lib", "Target", "ARM", "LICENSE.TXT"); - - public override string LicenseFile => licenseFile; - public override string Name => "mono/llvm ARM contributions"; - public override Uri SourceUrl => url; - public override string LicenseText => String.Empty; - } - - class mono_llvm_md5_contributions_TPN : ThirdPartyNotice - { - static readonly Uri url = new Uri ("https://github.com/mono/llvm/blob/master/lib/Support/MD5.cpp"); - - public override string LicenseFile => String.Empty; - public override string Name => "mono/llvm md5 contributions"; - public override Uri SourceUrl => url; + public override string LicenseText => @"The MIT License (MIT) +Copyright (c) .NET Foundation and Contributors - public override string LicenseText => @" - This software was written by Alexander Peslyak in 2001. No copyright is - claimed, and the software is hereby placed in the public domain. - In case this attempt to disclaim copyright and place the software in the - public domain is deemed null and void, then the software is - Copyright (c) 2001 Alexander Peslyak and it is hereby released to the - general public under the following terms: +All rights reserved. - Redistribution and use in source and binary forms, with or without - modification, are permitted. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the ""Software""), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: - There's ABSOLUTELY NO WARRANTY, express or implied. +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. - (This is a heavily cut-down ""BSD license"".) +THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. "; } } diff --git a/build-tools/xaprepare/xaprepare/ThirdPartyNotices/witwall_mman.cs b/build-tools/xaprepare/xaprepare/ThirdPartyNotices/witwall_mman.cs deleted file mode 100644 index b2dc080d1b7..00000000000 --- a/build-tools/xaprepare/xaprepare/ThirdPartyNotices/witwall_mman.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; - -namespace Xamarin.Android.Prepare -{ - [TPN] - class witwall_mman_TPN : ThirdPartyNotice - { - static readonly Uri url = new Uri ("https://github.com/witwall/mman-win32/"); - - public override string LicenseFile => string.Empty; - public override string Name => "witwall/mman-win32"; - public override Uri SourceUrl => url; - public override string LicenseText => @" -MIT License - -Copyright (c) 2018 Steven Lee - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the ""Software""), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -"; - - public override bool Include (bool includeExternalDeps, bool includeBuildDeps) => includeExternalDeps; - } -} diff --git a/build-tools/xaprepare/xaprepare/xaprepare.csproj b/build-tools/xaprepare/xaprepare/xaprepare.csproj index 6730c7adae9..41766677fdd 100644 --- a/build-tools/xaprepare/xaprepare/xaprepare.csproj +++ b/build-tools/xaprepare/xaprepare/xaprepare.csproj @@ -12,10 +12,6 @@ - - - - diff --git a/build-tools/xaprepare/xaprepare/xaprepare.targets b/build-tools/xaprepare/xaprepare/xaprepare.targets index 0201bbf4a34..1afe7e363b1 100644 --- a/build-tools/xaprepare/xaprepare/xaprepare.targets +++ b/build-tools/xaprepare/xaprepare/xaprepare.targets @@ -47,11 +47,9 @@ - - @@ -80,12 +78,6 @@ - - - - - - @@ -95,7 +87,6 @@ - diff --git a/external/mman-win32 b/external/mman-win32 deleted file mode 160000 index 2d1c576e62b..00000000000 --- a/external/mman-win32 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2d1c576e62b99e85d99407e1a88794c6e44c3310 diff --git a/mono.snk b/mono.snk deleted file mode 100644 index 380116c18fc..00000000000 Binary files a/mono.snk and /dev/null differ diff --git a/src/Microsoft.Android.Sdk.ILLink/Microsoft.Android.Sdk.ILLink.csproj b/src/Microsoft.Android.Sdk.ILLink/Microsoft.Android.Sdk.ILLink.csproj index dca5c11d629..ecbd4f4c7fe 100644 --- a/src/Microsoft.Android.Sdk.ILLink/Microsoft.Android.Sdk.ILLink.csproj +++ b/src/Microsoft.Android.Sdk.ILLink/Microsoft.Android.Sdk.ILLink.csproj @@ -13,32 +13,26 @@ - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - + diff --git a/src/Microsoft.Android.Sdk.ILLink/SetupStep.cs b/src/Microsoft.Android.Sdk.ILLink/SetupStep.cs index c8f56b575be..53ee2f3017f 100644 --- a/src/Microsoft.Android.Sdk.ILLink/SetupStep.cs +++ b/src/Microsoft.Android.Sdk.ILLink/SetupStep.cs @@ -5,7 +5,6 @@ using Mono.Cecil; using Mono.Linker; using Mono.Linker.Steps; -using Mono.Tuner; using MonoDroid.Tuner; namespace Microsoft.Android.Sdk.ILLink diff --git a/src/Xamarin.Android.Build.Tasks/Linker/External/Linker.Steps/BaseStep.cs b/src/Xamarin.Android.Build.Tasks/Linker/External/Linker.Steps/BaseStep.cs new file mode 100644 index 00000000000..39210adc9ee --- /dev/null +++ b/src/Xamarin.Android.Build.Tasks/Linker/External/Linker.Steps/BaseStep.cs @@ -0,0 +1,83 @@ +// +// BaseStep.cs +// +// Author: +// Jb Evain (jbevain@novell.com) +// +// (C) 2007 Novell, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using Mono.Cecil; + +namespace Mono.Linker.Steps { + + public abstract class BaseStep : IStep { + + private LinkContext _context; + + public LinkContext Context { + get { return _context; } + } + + public AnnotationStore Annotations { + get { return _context.Annotations; } + } + + public Tracer Tracer { + get { return _context.Tracer; } + } + + public MarkingHelpers MarkingHelpers => _context.MarkingHelpers; + + public void Process (LinkContext context) + { + _context = context; + + if (!ConditionToProcess ()) + return; + + Process (); + + foreach (AssemblyDefinition assembly in context.GetAssemblies ()) + ProcessAssembly (assembly); + + EndProcess (); + } + + protected virtual bool ConditionToProcess () + { + return true; + } + + protected virtual void Process () + { + } + + protected virtual void EndProcess () + { + } + + protected virtual void ProcessAssembly (AssemblyDefinition assembly) + { + } + } +} diff --git a/src/Xamarin.Android.Build.Tasks/Linker/External/Linker.Steps/IStep.cs b/src/Xamarin.Android.Build.Tasks/Linker/External/Linker.Steps/IStep.cs new file mode 100644 index 00000000000..c01ef1e6b3f --- /dev/null +++ b/src/Xamarin.Android.Build.Tasks/Linker/External/Linker.Steps/IStep.cs @@ -0,0 +1,34 @@ +// +// IStep.cs +// +// Author: +// Jb Evain (jbevain@gmail.com) +// +// (C) 2006 Jb Evain +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +namespace Mono.Linker.Steps { + + public interface IStep { + void Process (LinkContext context); + } +} diff --git a/src/Xamarin.Android.Build.Tasks/Linker/External/Linker/Annotations.cs b/src/Xamarin.Android.Build.Tasks/Linker/External/Linker/Annotations.cs new file mode 100644 index 00000000000..95bc5eb5b15 --- /dev/null +++ b/src/Xamarin.Android.Build.Tasks/Linker/External/Linker/Annotations.cs @@ -0,0 +1,452 @@ +// +// Annotations.cs +// +// Author: +// Jb Evain (jbevain@novell.com) +// +// (C) 2007 Novell, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Collections.Generic; +using Mono.Cecil; +using Mono.Cecil.Cil; + +namespace Mono.Linker { + + public partial class AnnotationStore { + + protected readonly LinkContext context; + + protected readonly Dictionary assembly_actions = new Dictionary (); + protected readonly Dictionary method_actions = new Dictionary (); + protected readonly Dictionary method_stub_values = new Dictionary (); + protected readonly Dictionary field_values = new Dictionary (); + protected readonly HashSet field_init = new HashSet (); + protected readonly HashSet fieldType_init = new HashSet (); + protected readonly HashSet marked = new HashSet (); + protected readonly HashSet processed = new HashSet (); + protected readonly Dictionary preserved_types = new Dictionary (); + protected readonly Dictionary> preserved_methods = new Dictionary> (); + protected readonly HashSet public_api = new HashSet (); + protected readonly Dictionary> override_methods = new Dictionary> (); + protected readonly Dictionary> base_methods = new Dictionary> (); + protected readonly Dictionary symbol_readers = new Dictionary (); + protected readonly Dictionary> class_type_base_hierarchy = new Dictionary> (); + protected readonly Dictionary> derived_interfaces = new Dictionary>(); + + protected readonly Dictionary> custom_annotations = new Dictionary> (); + protected readonly Dictionary> resources_to_remove = new Dictionary> (); + protected readonly HashSet marked_attributes = new HashSet (); + readonly HashSet marked_types_with_cctor = new HashSet (); + protected readonly HashSet marked_instantiated = new HashSet (); + protected readonly HashSet indirectly_called = new HashSet(); + + + public AnnotationStore (LinkContext context) => this.context = context; + + public bool ProcessSatelliteAssemblies { get; set; } + + protected Tracer Tracer { + get { + return context.Tracer; + } + } + + public ICollection GetAssemblies () + { + return assembly_actions.Keys; + } + + public AssemblyAction GetAction (AssemblyDefinition assembly) + { + AssemblyAction action; + if (assembly_actions.TryGetValue (assembly, out action)) + return action; + + throw new InvalidOperationException($"No action for the assembly {assembly.Name} defined"); + } + + public MethodAction GetAction (MethodDefinition method) + { + MethodAction action; + if (method_actions.TryGetValue (method, out action)) + return action; + + return MethodAction.Nothing; + } + + public void SetAction (AssemblyDefinition assembly, AssemblyAction action) + { + assembly_actions [assembly] = action; + } + + public bool HasAction (AssemblyDefinition assembly) + { + return assembly_actions.ContainsKey (assembly); + } + + public void SetAction (MethodDefinition method, MethodAction action) + { + method_actions [method] = action; + } + + public void SetMethodStubValue (MethodDefinition method, object value) + { + method_stub_values [method] = value; + } + + public void SetFieldValue (FieldDefinition field, object value) + { + field_values [field] = value; + } + + public void SetSubstitutedInit (FieldDefinition field) + { + field_init.Add (field); + } + + public bool HasSubstitutedInit (FieldDefinition field) + { + return field_init.Contains (field); + } + + public void SetSubstitutedInit (TypeDefinition type) + { + fieldType_init.Add (type); + } + + public bool HasSubstitutedInit (TypeDefinition type) + { + return fieldType_init.Contains (type); + } + + public void Mark (IMetadataTokenProvider provider) + { + marked.Add (provider); + Tracer.AddDependency (provider, true); + } + + public void Mark (CustomAttribute attribute) + { + marked_attributes.Add (attribute); + } + + public void MarkAndPush (IMetadataTokenProvider provider) + { + Mark (provider); + Tracer.Push (provider, false); + } + + public bool IsMarked (IMetadataTokenProvider provider) + { + return marked.Contains (provider); + } + + public bool IsMarked (CustomAttribute attribute) + { + return marked_attributes.Contains (attribute); + } + + public void MarkIndirectlyCalledMethod (MethodDefinition method) + { + if (!context.AddReflectionAnnotations) + return; + + indirectly_called.Add (method); + } + + public bool HasMarkedAnyIndirectlyCalledMethods () + { + return indirectly_called.Count != 0; + } + + public bool IsIndirectlyCalled (MethodDefinition method) + { + return indirectly_called.Contains (method); + } + + public void MarkInstantiated (TypeDefinition type) + { + marked_instantiated.Add (type); + } + + public bool IsInstantiated (TypeDefinition type) + { + return marked_instantiated.Contains (type); + } + + public void Processed (IMetadataTokenProvider provider) + { + processed.Add (provider); + } + + public bool IsProcessed (IMetadataTokenProvider provider) + { + return processed.Contains (provider); + } + + public bool IsPreserved (TypeDefinition type) + { + return preserved_types.ContainsKey (type); + } + + public void SetPreserve (TypeDefinition type, TypePreserve preserve) + { + TypePreserve existing; + if (preserved_types.TryGetValue (type, out existing)) + preserved_types [type] = ChoosePreserveActionWhichPreservesTheMost (existing, preserve); + else + preserved_types.Add (type, preserve); + } + + public static TypePreserve ChoosePreserveActionWhichPreservesTheMost (TypePreserve leftPreserveAction, TypePreserve rightPreserveAction) + { + if (leftPreserveAction == rightPreserveAction) + return leftPreserveAction; + + if (leftPreserveAction == TypePreserve.All || rightPreserveAction == TypePreserve.All) + return TypePreserve.All; + + if (leftPreserveAction == TypePreserve.Nothing) + return rightPreserveAction; + + if (rightPreserveAction == TypePreserve.Nothing) + return leftPreserveAction; + + if ((leftPreserveAction == TypePreserve.Methods && rightPreserveAction == TypePreserve.Fields) || + (leftPreserveAction == TypePreserve.Fields && rightPreserveAction == TypePreserve.Methods)) + return TypePreserve.All; + + return rightPreserveAction; + } + + public TypePreserve GetPreserve (TypeDefinition type) + { + TypePreserve preserve; + if (preserved_types.TryGetValue (type, out preserve)) + return preserve; + + throw new NotSupportedException ($"No type preserve information for `{type}`"); + } + + public bool TryGetPreserve (TypeDefinition type, out TypePreserve preserve) + { + return preserved_types.TryGetValue (type, out preserve); + } + + public bool TryGetMethodStubValue (MethodDefinition method, out object value) + { + return method_stub_values.TryGetValue (method, out value); + } + + public bool TryGetFieldUserValue (FieldDefinition field, out object value) + { + return field_values.TryGetValue (field, out value); + } + + public HashSet GetResourcesToRemove (AssemblyDefinition assembly) + { + HashSet resources; + if (resources_to_remove.TryGetValue (assembly, out resources)) + return resources; + + return null; + } + + public void AddResourceToRemove (AssemblyDefinition assembly, string name) + { + HashSet resources; + if (!resources_to_remove.TryGetValue (assembly, out resources)) { + resources = resources_to_remove [assembly] = new HashSet (); + } + + resources.Add (name); + } + + public void SetPublic (IMetadataTokenProvider provider) + { + public_api.Add (provider); + } + + public bool IsPublic (IMetadataTokenProvider provider) + { + return public_api.Contains (provider); + } + + public void AddOverride (MethodDefinition @base, MethodDefinition @override, InterfaceImplementation matchingInterfaceImplementation = null) + { + var methods = GetOverrides (@base); + if (methods == null) { + methods = new List (); + override_methods [@base] = methods; + } + + methods.Add (new OverrideInformation (@base, @override, matchingInterfaceImplementation)); + } + + public List GetOverrides (MethodDefinition method) + { + List overrides; + if (override_methods.TryGetValue (method, out overrides)) + return overrides; + + return null; + } + + public void AddBaseMethod (MethodDefinition method, MethodDefinition @base) + { + var methods = GetBaseMethods (method); + if (methods == null) { + methods = new List (); + base_methods [method] = methods; + } + + methods.Add (@base); + } + + public List GetBaseMethods (MethodDefinition method) + { + List bases; + if (base_methods.TryGetValue (method, out bases)) + return bases; + + return null; + } + + public List GetPreservedMethods (TypeDefinition type) + { + return GetPreservedMethods (type as IMemberDefinition); + } + + public void AddPreservedMethod (TypeDefinition type, MethodDefinition method) + { + AddPreservedMethod (type as IMemberDefinition, method); + } + + public List GetPreservedMethods (MethodDefinition method) + { + return GetPreservedMethods (method as IMemberDefinition); + } + + public void AddPreservedMethod (MethodDefinition key, MethodDefinition method) + { + AddPreservedMethod (key as IMemberDefinition, method); + } + + List GetPreservedMethods (IMemberDefinition definition) + { + List preserved; + if (preserved_methods.TryGetValue (definition, out preserved)) + return preserved; + + return null; + } + + void AddPreservedMethod (IMemberDefinition definition, MethodDefinition method) + { + var methods = GetPreservedMethods (definition); + if (methods == null) { + methods = new List (); + preserved_methods [definition] = methods; + } + + methods.Add (method); + } + + public void AddSymbolReader (AssemblyDefinition assembly, ISymbolReader symbolReader) + { + symbol_readers [assembly] = symbolReader; + } + + public void CloseSymbolReader (AssemblyDefinition assembly) + { + ISymbolReader symbolReader; + if (!symbol_readers.TryGetValue (assembly, out symbolReader)) + return; + + symbol_readers.Remove (assembly); + symbolReader.Dispose (); + } + + public Dictionary GetCustomAnnotations (object key) + { + Dictionary slots; + if (custom_annotations.TryGetValue (key, out slots)) + return slots; + + slots = new Dictionary (); + custom_annotations.Add (key, slots); + return slots; + } + + public bool HasPreservedStaticCtor (TypeDefinition type) + { + return marked_types_with_cctor.Contains (type); + } + + public bool SetPreservedStaticCtor (TypeDefinition type) + { + return marked_types_with_cctor.Add (type); + } + + public void SetClassHierarchy (TypeDefinition type, List bases) + { + class_type_base_hierarchy [type] = bases; + } + + public List GetClassHierarchy (TypeDefinition type) + { + if (class_type_base_hierarchy.TryGetValue (type, out List bases)) + return bases; + + return null; + } + + public void AddDerivedInterfaceForInterface (TypeDefinition @base, TypeDefinition derived) + { + if (!@base.IsInterface) + throw new ArgumentException ($"{nameof (@base)} must be an interface"); + + if (!derived.IsInterface) + throw new ArgumentException ($"{nameof (derived)} must be an interface"); + + List derivedInterfaces; + if (!derived_interfaces.TryGetValue (@base, out derivedInterfaces)) + derived_interfaces [@base] = derivedInterfaces = new List (); + + derivedInterfaces.Add(derived); + } + + public List GetDerivedInterfacesForInterface (TypeDefinition @interface) + { + if (!@interface.IsInterface) + throw new ArgumentException ($"{nameof (@interface)} must be an interface"); + + List derivedInterfaces; + if (derived_interfaces.TryGetValue (@interface, out derivedInterfaces)) + return derivedInterfaces; + + return null; + } + } +} diff --git a/src/Xamarin.Android.Build.Tasks/Linker/External/Linker/AssemblyAction.cs b/src/Xamarin.Android.Build.Tasks/Linker/External/Linker/AssemblyAction.cs new file mode 100644 index 00000000000..341339cd159 --- /dev/null +++ b/src/Xamarin.Android.Build.Tasks/Linker/External/Linker/AssemblyAction.cs @@ -0,0 +1,55 @@ +// +// AssemblyAction.cs +// +// Author: +// Jb Evain (jbevain@gmail.com) +// +// (C) 2006 Jb Evain +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +namespace Mono.Linker { + + public enum AssemblyAction { + // Ignore the assembly + Skip, + // Copy the existing files, assembly and symbols, into the output destination. E.g. .dll and .mdb + // The linker still analyzes the assemblies (to know what they require) but does not modify them. + Copy, + // Copy the existing files, assembly and symbols, into the output destination if and only if + // anything from the assembly is used. + // The linker still analyzes the assemblies (to know what they require) but does not modify them. + CopyUsed, + // Link the assembly + Link, + // Remove the assembly from the output + Delete, + // Save the assembly/symbols in memory without linking it. + // E.g. useful to remove unneeded assembly references (as done in SweepStep), + // resolving [TypeForwardedTo] attributes (like PCL) to their final location + Save, + // Keep all types, methods, and fields but add System.Runtime.BypassNGenAttribute to unmarked methods. + AddBypassNGen, + // Keep all types, methods, and fields in marked assemblies but add System.Runtime.BypassNGenAttribute to unmarked methods. + // Delete unmarked assemblies. + AddBypassNGenUsed + } +} diff --git a/src/Xamarin.Android.Build.Tasks/Linker/External/Linker/AssemblyResolver.cs b/src/Xamarin.Android.Build.Tasks/Linker/External/Linker/AssemblyResolver.cs new file mode 100644 index 00000000000..143a7559f1b --- /dev/null +++ b/src/Xamarin.Android.Build.Tasks/Linker/External/Linker/AssemblyResolver.cs @@ -0,0 +1,157 @@ +// +// AssemblyResolver.cs +// +// Author: +// Jb Evain (jbevain@novell.com) +// +// (C) 2007 Novell, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Collections.Generic; +using System.IO; +using Mono.Cecil; +using Mono.Collections.Generic; + +namespace Mono.Linker { + +#if FEATURE_ILLINK + public class AssemblyResolver : DirectoryAssemblyResolver { +#else + public class AssemblyResolver : BaseAssemblyResolver { +#endif + + readonly Dictionary _assemblies; + HashSet _unresolvedAssemblies; + bool _ignoreUnresolved; + LinkContext _context; + readonly Collection _references; + + + public IDictionary AssemblyCache { + get { return _assemblies; } + } + + public AssemblyResolver () + : this (new Dictionary (StringComparer.OrdinalIgnoreCase)) + { + } + + public AssemblyResolver (Dictionary assembly_cache) + { + _assemblies = assembly_cache; + _references = new Collection () { }; + } + + public bool IgnoreUnresolved { + get { return _ignoreUnresolved; } + set { _ignoreUnresolved = value; } + } + + public LinkContext Context { + get { return _context; } + set { _context = value; } + } + +#if !FEATURE_ILLINK + // The base class's definition of GetAssembly is visible when using DirectoryAssemblyResolver. + AssemblyDefinition GetAssembly (string file, ReaderParameters parameters) + { + if (parameters.AssemblyResolver == null) + parameters.AssemblyResolver = this; + + return ModuleDefinition.ReadModule (file, parameters).Assembly; + } +#endif + + AssemblyDefinition ResolveFromReferences (AssemblyNameReference name, Collection references, ReaderParameters parameters) + { + var fileName = name.Name + ".dll"; + foreach (var reference in references) { + if (Path.GetFileName (reference) != fileName) + continue; + try { + return GetAssembly (reference, parameters); + } catch (BadImageFormatException) { + continue; + } + } + + return null; + } + + public override AssemblyDefinition Resolve (AssemblyNameReference name, ReaderParameters parameters) + { + // Validate arguments, similarly to how the base class does it. + if (name == null) + throw new ArgumentNullException ("name"); + if (parameters == null) + throw new ArgumentNullException ("parameters"); + + AssemblyDefinition asm = null; + if (!_assemblies.TryGetValue (name.Name, out asm) && (_unresolvedAssemblies == null || !_unresolvedAssemblies.Contains (name.Name))) { + try { + // Any full path explicit reference takes precedence over other look up logic + asm = ResolveFromReferences (name, _references, parameters); + + // Fall back to the base class resolution logic + if (asm == null) + asm = base.Resolve (name, parameters); + + _assemblies [name.Name] = asm; + } catch (AssemblyResolutionException) { + if (!_ignoreUnresolved) + throw; + _context.LogMessage ($"warning: Ignoring unresolved assembly '{name.Name}'."); + if (_unresolvedAssemblies == null) + _unresolvedAssemblies = new HashSet (); + _unresolvedAssemblies.Add (name.Name); + } + } + + return asm; + } + + public virtual AssemblyDefinition CacheAssembly (AssemblyDefinition assembly) + { + _assemblies [assembly.Name.Name] = assembly; + base.AddSearchDirectory (Path.GetDirectoryName (assembly.MainModule.FileName)); + return assembly; + } + + public void AddReferenceAssembly (string referencePath) + { + _references.Add (referencePath); + } + + protected override void Dispose (bool disposing) + { + foreach (var asm in _assemblies.Values) { + asm.Dispose (); + } + + _assemblies.Clear (); + if (_unresolvedAssemblies != null) + _unresolvedAssemblies.Clear (); + } + } +} diff --git a/src/Xamarin.Android.Build.Tasks/Linker/External/Linker/ConsoleLogger.cs b/src/Xamarin.Android.Build.Tasks/Linker/External/Linker/ConsoleLogger.cs new file mode 100644 index 00000000000..f7059f2b89f --- /dev/null +++ b/src/Xamarin.Android.Build.Tasks/Linker/External/Linker/ConsoleLogger.cs @@ -0,0 +1,11 @@ +using System; +namespace Mono.Linker +{ + public class ConsoleLogger : ILogger + { + public void LogMessage (MessageImportance importance, string message, params object[] values) + { + Console.WriteLine (message, values); + } + } +} diff --git a/src/Xamarin.Android.Build.Tasks/Linker/External/Linker/IDependencyRecorder.cs b/src/Xamarin.Android.Build.Tasks/Linker/External/Linker/IDependencyRecorder.cs new file mode 100644 index 00000000000..de4e4616e94 --- /dev/null +++ b/src/Xamarin.Android.Build.Tasks/Linker/External/Linker/IDependencyRecorder.cs @@ -0,0 +1,44 @@ +// +// IDependencyRecorder.cs +// +// Copyright (C) 2017 Microsoft Corporation (http://www.microsoft.com) +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +namespace Mono.Linker +{ + /// + /// Abstraction exposed by the linker (mostly MarkStep, but not only) - it will call this interface + /// every time it finds a dependency between two parts of the dependency graph. + /// + public interface IDependencyRecorder + { + /// + /// Reports a dependency detected by the linker. + /// + /// The source of the dependency (for example the caller method). + /// The target of the dependency (for example the callee method). + /// true if the target is also marked by the MarkStep. + /// The source and target are typically Cecil metadata objects (MethodDefinition, TypeDefinition, ...) + /// but they can also be the linker steps or really any other object. + void RecordDependency (object source, object target, bool marked); + } +} diff --git a/src/Xamarin.Android.Build.Tasks/Linker/External/Linker/ILogger.cs b/src/Xamarin.Android.Build.Tasks/Linker/External/Linker/ILogger.cs new file mode 100644 index 00000000000..d4f610fbb53 --- /dev/null +++ b/src/Xamarin.Android.Build.Tasks/Linker/External/Linker/ILogger.cs @@ -0,0 +1,15 @@ +using System; +namespace Mono.Linker +{ + public enum MessageImportance + { + High, + Low, + Normal, + } + + public interface ILogger + { + void LogMessage (MessageImportance importance, string message, params object[] values); + } +} diff --git a/src/Xamarin.Android.Build.Tasks/Linker/External/Linker/IReflectionPatternRecorder.cs b/src/Xamarin.Android.Build.Tasks/Linker/External/Linker/IReflectionPatternRecorder.cs new file mode 100644 index 00000000000..b3aae2b2ea7 --- /dev/null +++ b/src/Xamarin.Android.Build.Tasks/Linker/External/Linker/IReflectionPatternRecorder.cs @@ -0,0 +1,62 @@ +// +// IReflectionPatternRecorder.cs +// +// Copyright (C) 2017 Microsoft Corporation (http://www.microsoft.com) +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using Mono.Cecil; + +namespace Mono.Linker +{ + /// + /// Interface which is called every time the linker inspects a pattern of code involving reflection to determine a more complex + /// dependency. + /// + /// + /// The rules are such that if a given callsite of a "reflectionMethod" gets examined + /// linker will always report it one way or another: + /// - it will either call RecognizedReflectionAccessPattern method when it can figure out exactly the dependency. + /// - or it will call UnrecognizedReflectionAccessPattern with an optional message describing why it could not recognize + /// the pattern. + /// + public interface IReflectionPatternRecorder + { + /// + /// Called when the linker recognized a reflection access pattern (and thus was able to correctly apply marking to the accessed item). + /// + /// The method which contains the reflection access pattern. + /// The reflection method which is at the heart of the access pattern. + /// The item accessed through reflection. This can be one of: + /// TypeDefinition, MethodDefinition, PropertyDefinition, FieldDefinition, EventDefinition. + void RecognizedReflectionAccessPattern (MethodDefinition sourceMethod, MethodDefinition reflectionMethod, IMemberDefinition accessedItem); + + /// + /// Called when the linker detected a reflection access but was not able to recognize the entire pattern. + /// + /// The method which contains the reflection access code. + /// The reflection method which is at the heart of the access code. + /// Humanly readable message describing what failed during the pattern recognition. + /// This effectively means that there's a potential hole in the linker marking - some items which are accessed only through + /// reflection may not be marked correctly and thus may fail at runtime. + void UnrecognizedReflectionAccessPattern (MethodDefinition sourceMethod, MethodDefinition reflectionMethod, string message); + } +} diff --git a/src/Xamarin.Android.Build.Tasks/Linker/External/Linker/KnownMembers.cs b/src/Xamarin.Android.Build.Tasks/Linker/External/Linker/KnownMembers.cs new file mode 100644 index 00000000000..02dcf6469ad --- /dev/null +++ b/src/Xamarin.Android.Build.Tasks/Linker/External/Linker/KnownMembers.cs @@ -0,0 +1,31 @@ +using Mono.Cecil; + +namespace Mono.Linker +{ + public class KnownMembers + { + public MethodDefinition NotSupportedExceptionCtorString { get; set; } + public MethodDefinition DisablePrivateReflectionAttributeCtor { get; set; } + public MethodDefinition ObjectCtor { get; set; } + + public static bool IsNotSupportedExceptionCtorString (MethodDefinition method) + { + if (!method.IsConstructor || method.IsStatic || !method.HasParameters) + return false; + + if (method.Parameters.Count != 1 || method.Parameters [0].ParameterType.MetadataType != MetadataType.String) + return false; + + return true; + } + + public static bool IsSatelliteAssemblyMarker (MethodDefinition method) + { + if (!method.IsConstructor || method.IsStatic) + return false; + + var declaringType = method.DeclaringType; + return declaringType.Name == "ResourceManager" && declaringType.Namespace == "System.Resources"; + } + } +} diff --git a/src/Xamarin.Android.Build.Tasks/Linker/External/Linker/LinkContext.cs b/src/Xamarin.Android.Build.Tasks/Linker/External/Linker/LinkContext.cs new file mode 100644 index 00000000000..b05afc29cb7 --- /dev/null +++ b/src/Xamarin.Android.Build.Tasks/Linker/External/Linker/LinkContext.cs @@ -0,0 +1,447 @@ +// +// LinkContext.cs +// +// Author: +// Jb Evain (jbevain@gmail.com) +// +// (C) 2006 Jb Evain +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Collections.Generic; +using System.IO; +using Mono.Cecil; +using Mono.Cecil.Cil; + +namespace Mono.Linker { + + public class UnintializedContextFactory { + virtual public AnnotationStore CreateAnnotationStore (LinkContext context) => new AnnotationStore (context); + virtual public MarkingHelpers CreateMarkingHelpers (LinkContext context) => new MarkingHelpers (context); + virtual public Tracer CreateTracer (LinkContext context) => new Tracer (context); + } + + public class LinkContext : IDisposable { + + Pipeline _pipeline; + AssemblyAction _coreAction; + AssemblyAction _userAction; + Dictionary _actions; + string _outputDirectory; + readonly Dictionary _parameters; + bool _linkSymbols; + bool _keepTypeForwarderOnlyAssemblies; + bool _keepMembersForDebugger; + bool _ignoreUnresolved; + + AssemblyResolver _resolver; + + ReaderParameters _readerParameters; + ISymbolReaderProvider _symbolReaderProvider; + ISymbolWriterProvider _symbolWriterProvider; + + AnnotationStore _annotations; + + public Pipeline Pipeline { + get { return _pipeline; } + } + + public AnnotationStore Annotations { + get { return _annotations; } + } + + public bool DeterministicOutput { get; set; } + + public string OutputDirectory { + get { return _outputDirectory; } + set { _outputDirectory = value; } + } + + public AssemblyAction CoreAction { + get { return _coreAction; } + set { _coreAction = value; } + } + + public AssemblyAction UserAction { + get { return _userAction; } + set { _userAction = value; } + } + + public bool LinkSymbols { + get { return _linkSymbols; } + set { _linkSymbols = value; } + } + + public bool KeepTypeForwarderOnlyAssemblies + { + get { return _keepTypeForwarderOnlyAssemblies; } + set { _keepTypeForwarderOnlyAssemblies = value; } + } + + public bool KeepMembersForDebugger + { + get { return _keepMembersForDebugger; } + set { _keepMembersForDebugger = value; } + } + + public bool IgnoreUnresolved + { + get { return _ignoreUnresolved; } + set { _ignoreUnresolved = value; } + } + + public bool EnableReducedTracing { get; set; } + + public bool KeepUsedAttributeTypesOnly { get; set; } + + public bool KeepDependencyAttributes { get; set; } + + public bool StripResources { get; set; } + + public List Substitutions { get; private set; } + + public System.Collections.IDictionary Actions { + get { return _actions; } + } + + public AssemblyResolver Resolver { + get { return _resolver; } + } + + public ReaderParameters ReaderParameters { + get { return _readerParameters; } + } + + public ISymbolReaderProvider SymbolReaderProvider { + get { return _symbolReaderProvider; } + set { _symbolReaderProvider = value; } + } + + public ISymbolWriterProvider SymbolWriterProvider { + get { return _symbolWriterProvider; } + set { _symbolWriterProvider = value; } + } + + public bool LogMessages { get; set; } + + public ILogger Logger { private get; set; } = new ConsoleLogger (); + + public MarkingHelpers MarkingHelpers { get; private set; } + + public KnownMembers MarkedKnownMembers { get; private set; } + + public Tracer Tracer { get; private set; } + + public IReflectionPatternRecorder ReflectionPatternRecorder { get; set; } + + public string [] ExcludedFeatures { get; set; } + + public CodeOptimizations DisabledOptimizations { get; set; } + + public bool AddReflectionAnnotations { get; set; } + + public string AssemblyListFile { get; set; } + + public LinkContext (Pipeline pipeline) + : this (pipeline, new AssemblyResolver ()) + { + } + + public LinkContext (Pipeline pipeline, AssemblyResolver resolver) + : this(pipeline, resolver, new ReaderParameters + { + AssemblyResolver = resolver + }, new UnintializedContextFactory ()) + { + } + + public LinkContext (Pipeline pipeline, AssemblyResolver resolver, ReaderParameters readerParameters, UnintializedContextFactory factory) + { + _pipeline = pipeline; + _resolver = resolver; + _resolver.Context = this; + _actions = new Dictionary (); + _parameters = new Dictionary (); + _readerParameters = readerParameters; + + SymbolReaderProvider = new DefaultSymbolReaderProvider (false); + + if (factory == null) + throw new ArgumentNullException (nameof (factory)); + + _annotations = factory.CreateAnnotationStore (this); + MarkingHelpers = factory.CreateMarkingHelpers (this); + Tracer = factory.CreateTracer (this); + ReflectionPatternRecorder = new LoggingReflectionPatternRecorder (this); + MarkedKnownMembers = new KnownMembers (); + StripResources = true; + + // See https://github.com/mono/linker/issues/612 + DisabledOptimizations |= CodeOptimizations.UnreachableBodies; + DisabledOptimizations |= CodeOptimizations.ClearInitLocals; + DisabledOptimizations |= CodeOptimizations.IPConstantPropagation; + } + + public void AddSubstitutionFile (string file) + { + if (Substitutions == null) { + Substitutions = new List (); + Substitutions.Add (file); + return; + } + + if (Substitutions.Contains (file)) + return; + + Substitutions.Add (file); + } + + public AssemblyDefinition Resolve (string name) + { + if (File.Exists (name)) { + try { + AssemblyDefinition assembly = AssemblyDefinition.ReadAssembly (name, _readerParameters); + return _resolver.CacheAssembly (assembly); + } catch (Exception e) { + throw new AssemblyResolutionException (new AssemblyNameReference (name, new Version ()), e); + } + } + + return Resolve (new AssemblyNameReference (name, new Version ())); + } + + public AssemblyDefinition Resolve (IMetadataScope scope) + { + AssemblyNameReference reference = GetReference (scope); + try { + AssemblyDefinition assembly = _resolver.Resolve (reference, _readerParameters); + + if (assembly != null) + RegisterAssembly (assembly); + + return assembly; + } + catch (Exception e) { + throw new AssemblyResolutionException (reference, e); + } + } + + public void RegisterAssembly (AssemblyDefinition assembly) + { + if (SeenFirstTime (assembly)) { + SafeReadSymbols (assembly); + SetDefaultAction (assembly); + } + } + + protected bool SeenFirstTime (AssemblyDefinition assembly) + { + return !_annotations.HasAction (assembly); + } + + public virtual void SafeReadSymbols (AssemblyDefinition assembly) + { + if (assembly.MainModule.HasSymbols) + return; + + if (_symbolReaderProvider == null) + throw new ArgumentNullException (nameof (_symbolReaderProvider)); + + try { + var symbolReader = _symbolReaderProvider.GetSymbolReader ( + assembly.MainModule, + assembly.MainModule.FileName); + + if (symbolReader == null) + return; + + try { + assembly.MainModule.ReadSymbols (symbolReader); + } catch { + symbolReader.Dispose (); + return; + } + + // Add symbol reader to annotations only if we have successfully read it + _annotations.AddSymbolReader (assembly, symbolReader); + } catch { } + } + + public virtual ICollection ResolveReferences (AssemblyDefinition assembly) + { + List references = new List (); + if (assembly == null) + return references; + foreach (AssemblyNameReference reference in assembly.MainModule.AssemblyReferences) { + AssemblyDefinition definition = Resolve (reference); + if (definition != null) + references.Add (definition); + } + return references; + } + + static AssemblyNameReference GetReference (IMetadataScope scope) + { + AssemblyNameReference reference; + if (scope is ModuleDefinition) { + AssemblyDefinition asm = ((ModuleDefinition) scope).Assembly; + reference = asm.Name; + } else + reference = (AssemblyNameReference) scope; + + return reference; + } + + public void SetAction (AssemblyDefinition assembly, AssemblyAction defaultAction) + { + RegisterAssembly (assembly); + + if (!_actions.TryGetValue (assembly.Name.Name, out AssemblyAction action)) + action = defaultAction; + + Annotations.SetAction (assembly, action); + } + + protected void SetDefaultAction (AssemblyDefinition assembly) + { + AssemblyAction action; + + AssemblyNameDefinition name = assembly.Name; + + if (_actions.TryGetValue (name.Name, out action)) { + } else if (IsCore (name)) { + action = _coreAction; + } else { + action = _userAction; + } + + _annotations.SetAction (assembly, action); + } + + public static bool IsCore (AssemblyNameReference name) + { + switch (name.Name) { + case "mscorlib": + case "Accessibility": + case "Mono.Security": + // WPF + case "PresentationFramework": + case "PresentationCore": + case "WindowsBase": + case "UIAutomationProvider": + case "UIAutomationTypes": + case "PresentationUI": + case "ReachFramework": + case "netstandard": + return true; + default: + return name.Name.StartsWith ("System") + || name.Name.StartsWith ("Microsoft"); + } + } + + public virtual AssemblyDefinition [] GetAssemblies () + { + var cache = _resolver.AssemblyCache; + AssemblyDefinition [] asms = new AssemblyDefinition [cache.Count]; + cache.Values.CopyTo (asms, 0); + return asms; + } + + public void SetParameter (string key, string value) + { + _parameters [key] = value; + } + + public bool HasParameter (string key) + { + return _parameters.ContainsKey (key); + } + + public string GetParameter (string key) + { + string val = null; + _parameters.TryGetValue (key, out val); + return val; + } + + public void Dispose () + { + _resolver.Dispose (); + } + + public bool IsFeatureExcluded (string featureName) + { + return ExcludedFeatures != null && Array.IndexOf (ExcludedFeatures, featureName) >= 0; + } + + public bool IsOptimizationEnabled (CodeOptimizations optimization) + { + return (DisabledOptimizations & optimization) == 0; + } + + public void LogMessage (string message) + { + LogMessage (MessageImportance.Normal, message); + } + + public void LogMessage (MessageImportance importance, string message) + { + if (LogMessages && Logger != null) + Logger.LogMessage (importance, "{0}", message); + } + } + + [Flags] + public enum CodeOptimizations + { + BeforeFieldInit = 1 << 0, + + /// + /// Option to disable removal of overrides of virtual methods when a type is never instantiated + /// + /// Being able to disable this optimization is helpful when trying to troubleshoot problems caused by types created via reflection or from native + /// that do not get an instance constructor marked. + /// + OverrideRemoval = 1 << 1, + + /// + /// Option to disable delaying marking of instance methods until an instance of that type could exist + /// + UnreachableBodies = 1 << 2, + + /// + /// Option to clear the initlocals flag on methods + /// + ClearInitLocals = 1 << 3, + + /// + /// Option to remove .interfaceimpl for interface types that are not used + /// + UnusedInterfaces = 1 << 4, + + /// + /// Option to do interprocedural constant propagation on return values + /// + IPConstantPropagation = 1 << 5 + } +} diff --git a/src/Xamarin.Android.Build.Tasks/Linker/External/Linker/LoggingReflectionPatternRecorder.cs b/src/Xamarin.Android.Build.Tasks/Linker/External/Linker/LoggingReflectionPatternRecorder.cs new file mode 100644 index 00000000000..f9c0d89e938 --- /dev/null +++ b/src/Xamarin.Android.Build.Tasks/Linker/External/Linker/LoggingReflectionPatternRecorder.cs @@ -0,0 +1,49 @@ +// +// LoggingReflectionPatternRecorder.cs +// +// Copyright (C) 2017 Microsoft Corporation (http://www.microsoft.com) +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using Mono.Cecil; + +namespace Mono.Linker +{ + class LoggingReflectionPatternRecorder : IReflectionPatternRecorder + { + private readonly LinkContext _context; + + public LoggingReflectionPatternRecorder (LinkContext context) + { + _context = context; + } + + public void RecognizedReflectionAccessPattern (MethodDefinition sourceMethod, MethodDefinition reflectionMethod, IMemberDefinition accessedItem) + { + // Do nothing - there's no logging for successfully recognized patterns + } + + public void UnrecognizedReflectionAccessPattern (MethodDefinition sourceMethod, MethodDefinition reflectionMethod, string message) + { + _context.LogMessage (MessageImportance.Low, message); + } + } +} diff --git a/src/Xamarin.Android.Build.Tasks/Linker/External/Linker/MarkingHelpers.cs b/src/Xamarin.Android.Build.Tasks/Linker/External/Linker/MarkingHelpers.cs new file mode 100644 index 00000000000..b477a5ce389 --- /dev/null +++ b/src/Xamarin.Android.Build.Tasks/Linker/External/Linker/MarkingHelpers.cs @@ -0,0 +1,20 @@ +using System; +using Mono.Cecil; + +namespace Mono.Linker { + public class MarkingHelpers { + protected readonly LinkContext _context; + + public MarkingHelpers (LinkContext context) + { + _context = context; + } + + public void MarkExportedType (ExportedType type, ModuleDefinition module) + { + _context.Annotations.Mark (type); + if (_context.KeepTypeForwarderOnlyAssemblies) + _context.Annotations.Mark (module); + } + } +} diff --git a/src/Xamarin.Android.Build.Tasks/Linker/External/Linker/MethodAction.cs b/src/Xamarin.Android.Build.Tasks/Linker/External/Linker/MethodAction.cs new file mode 100644 index 00000000000..a3550e78396 --- /dev/null +++ b/src/Xamarin.Android.Build.Tasks/Linker/External/Linker/MethodAction.cs @@ -0,0 +1,38 @@ +// +// MethodAction.cs +// +// Author: +// Jb Evain (jbevain@gmail.com) +// +// (C) 2006 Jb Evain +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +namespace Mono.Linker { + + public enum MethodAction { + Nothing, + Parse, + ForceParse, + ConvertToStub, + ConvertToThrow, + } +} diff --git a/src/Xamarin.Android.Build.Tasks/Linker/External/Linker/OverrideInformation.cs b/src/Xamarin.Android.Build.Tasks/Linker/External/Linker/OverrideInformation.cs new file mode 100644 index 00000000000..f73d8bc1c63 --- /dev/null +++ b/src/Xamarin.Android.Build.Tasks/Linker/External/Linker/OverrideInformation.cs @@ -0,0 +1,43 @@ +using System.Diagnostics; +using Mono.Cecil; + +namespace Mono.Linker { + [DebuggerDisplay ("{Override}")] + public class OverrideInformation { + public readonly MethodDefinition Base; + public readonly MethodDefinition Override; + public readonly InterfaceImplementation MatchingInterfaceImplementation; + + public OverrideInformation (MethodDefinition @base, MethodDefinition @override, InterfaceImplementation matchingInterfaceImplementation = null) + { + Base = @base; + Override = @override; + MatchingInterfaceImplementation = matchingInterfaceImplementation; + } + + public bool IsOverrideOfInterfaceMember + { + get + { + if (MatchingInterfaceImplementation != null) + return true; + + return Base.DeclaringType.IsInterface; + } + } + + public TypeDefinition InterfaceType + { + get + { + if (!IsOverrideOfInterfaceMember) + return null; + + if (MatchingInterfaceImplementation != null) + return MatchingInterfaceImplementation.InterfaceType.Resolve (); + + return Base.DeclaringType; + } + } + } +} \ No newline at end of file diff --git a/src/Xamarin.Android.Build.Tasks/Linker/External/Linker/Pipeline.cs b/src/Xamarin.Android.Build.Tasks/Linker/External/Linker/Pipeline.cs new file mode 100644 index 00000000000..a28de3ba1b2 --- /dev/null +++ b/src/Xamarin.Android.Build.Tasks/Linker/External/Linker/Pipeline.cs @@ -0,0 +1,152 @@ +// +// Pipeline.cs +// +// Author: +// Jb Evain (jbevain@gmail.com) +// +// (C) 2006 Jb Evain +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Collections.Generic; + +using Mono.Linker.Steps; + +namespace Mono.Linker { + + public class Pipeline { + + readonly List _steps; + + public Pipeline () + { + _steps = new List(); + } + + public void PrependStep (IStep step) + { + _steps.Insert (0, step); + } + + public void AppendStep (IStep step) + { + _steps.Add (step); + } + + public void AddStepBefore (Type target, IStep step) + { + for (int i = 0; i < _steps.Count; i++) { + if (target.IsInstanceOfType (_steps [i])) { + _steps.Insert (i, step); + return; + } + } + string msg = String.Format ("Step {0} could not be inserted before (not found) {1}", step, target); + throw new InvalidOperationException (msg); + } + + public void AddStepBefore (IStep target, IStep step) + { + for (int i = 0; i < _steps.Count; i++) { + if (_steps [i] == target) { + _steps.Insert (i, step); + return; + } + } + } + + public void ReplaceStep (Type target, IStep step) + { + AddStepBefore (target, step); + RemoveStep (target); + } + + public void AddStepAfter (Type target, IStep step) + { + for (int i = 0; i < _steps.Count; i++) { + if (target.IsInstanceOfType (_steps [i])) { + if (i == _steps.Count - 1) + _steps.Add (step); + else + _steps.Insert (i + 1, step); + return; + } + } + string msg = String.Format ("Step {0} could not be inserted after (not found) {1}", step, target); + throw new InvalidOperationException (msg); + } + + public void AddStepAfter (IStep target, IStep step) + { + for (int i = 0; i < _steps.Count; i++) { + if (_steps [i] == target) { + if (i == _steps.Count - 1) + _steps.Add (step); + else + _steps.Insert (i + 1, step); + return; + } + } + } + + public void RemoveStep (Type target) + { + for (int i = 0; i < _steps.Count; i++) { + if (_steps [i].GetType () != target) + continue; + + _steps.RemoveAt (i); + break; + } + } + + public void Process (LinkContext context) + { + while (_steps.Count > 0) { + IStep step = _steps [0]; + ProcessStep (context, step); + _steps.Remove (step); + } + } + + protected virtual void ProcessStep (LinkContext context, IStep step) + { + context.Tracer.Push (step); + step.Process (context); + context.Tracer.Pop (); + } + + public IStep [] GetSteps () + { + return _steps.ToArray (); + } + + public bool ContainsStep (Type type) + { + foreach (IStep step in _steps) + if (step.GetType () == type) + return true; + + return false; + } + } +} diff --git a/src/Xamarin.Android.Build.Tasks/Linker/External/Linker/Tracer.cs b/src/Xamarin.Android.Build.Tasks/Linker/External/Linker/Tracer.cs new file mode 100644 index 00000000000..1a6b7109fe9 --- /dev/null +++ b/src/Xamarin.Android.Build.Tasks/Linker/External/Linker/Tracer.cs @@ -0,0 +1,115 @@ +// +// Tracer.cs +// +// Author: +// Radek Doulik +// +// Copyright (C) 2017 Microsoft Corporation (http://www.microsoft.com) +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Collections.Generic; + +namespace Mono.Linker +{ + public class Tracer + { + protected readonly LinkContext context; + + Stack dependency_stack; + List recorders; + + public Tracer (LinkContext context) + { + this.context = context; + dependency_stack = new Stack (); + } + + public void Finish () + { + dependency_stack = null; + if (recorders != null) { + foreach (var recorder in recorders) { + if (recorder is IDisposable disposableRecorder) + disposableRecorder.Dispose (); + } + } + + recorders = null; + } + + public void AddRecorder (IDependencyRecorder recorder) + { + if (recorders == null) { + recorders = new List (); + } + + recorders.Add (recorder); + } + + public void Push (object o, bool addDependency = true) + { + if (!IsRecordingEnabled ()) + return; + + if (addDependency && dependency_stack.Count > 0) + AddDependency (o); + + dependency_stack.Push (o); + } + + public void Pop () + { + if (!IsRecordingEnabled ()) + return; + + dependency_stack.Pop (); + } + + bool IsRecordingEnabled () + { + return recorders != null; + } + + public void AddDirectDependency (object b, object e) + { + ReportDependency (b, e, false); + } + + public void AddDependency (object o, bool marked = false) + { + if (!IsRecordingEnabled ()) + return; + + ReportDependency (dependency_stack.Count > 0 ? dependency_stack.Peek () : null, o, marked); + } + + private void ReportDependency (object source, object target, bool marked) + { + if (IsRecordingEnabled ()) { + foreach (IDependencyRecorder recorder in recorders) { + recorder.RecordDependency (source, target, marked); + } + } + } + } +} diff --git a/src/Xamarin.Android.Build.Tasks/Linker/External/Linker/TypePreserve.cs b/src/Xamarin.Android.Build.Tasks/Linker/External/Linker/TypePreserve.cs new file mode 100644 index 00000000000..bc743c65a18 --- /dev/null +++ b/src/Xamarin.Android.Build.Tasks/Linker/External/Linker/TypePreserve.cs @@ -0,0 +1,38 @@ +// +// TypePreserve.cs +// +// Author: +// Jb Evain (jb@nurv.fr) +// +// (C) 2007 Novell, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +namespace Mono.Linker { + + public enum TypePreserve + { + Nothing, // This is actually Declaration + All, + Fields, + Methods + } +} diff --git a/src/Xamarin.Android.Build.Tasks/Linker/External/Mono.Tuner/CecilRocks.cs b/src/Xamarin.Android.Build.Tasks/Linker/External/Mono.Tuner/CecilRocks.cs new file mode 100644 index 00000000000..69958598dda --- /dev/null +++ b/src/Xamarin.Android.Build.Tasks/Linker/External/Mono.Tuner/CecilRocks.cs @@ -0,0 +1,519 @@ +// +// MethodBodyRocks.cs +// +// Author: +// Jb Evain (jbevain@gmail.com) +// +// Copyright (c) 2008 - 2011 Jb Evain +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Collections.Generic; +using System.Linq; + +using Mono.Cecil; +using Mono.Cecil.Cil; + +namespace Mono.Tuner { + + public static class MethodBodyRocks { + + public static IEnumerable GetAllTypes (this ModuleDefinition self) + { + return self.Types.SelectMany (t => t.GetAllTypes ()); + } + + static IEnumerable GetAllTypes (this TypeDefinition self) + { + yield return self; + + if (!self.HasNestedTypes) + yield break; + + foreach (var type in self.NestedTypes.SelectMany (t => t.GetAllTypes ())) + yield return type; + } + + public static IEnumerable GetMethods (this TypeDefinition self) + { + return self.Methods.Where (m => !m.IsConstructor); + } + + public static IEnumerable GetConstructors (this TypeDefinition self) + { + return self.Methods.Where (m => m.IsConstructor); + } + + public static MethodDefinition GetTypeConstructor (this TypeDefinition self) + { + return self.GetConstructors ().FirstOrDefault (c => c.IsStatic); + } + + public static void SimplifyMacros (this MethodBody self) + { + if (self == null) + throw new ArgumentNullException ("self"); + + foreach (var instruction in self.Instructions) { + if (instruction.OpCode.OpCodeType != OpCodeType.Macro) + continue; + + switch (instruction.OpCode.Code) { + case Code.Ldarg_0: + ExpandMacro (instruction, OpCodes.Ldarg, self.GetParameter (0)); + break; + case Code.Ldarg_1: + ExpandMacro (instruction, OpCodes.Ldarg, self.GetParameter (1)); + break; + case Code.Ldarg_2: + ExpandMacro (instruction, OpCodes.Ldarg, self.GetParameter (2)); + break; + case Code.Ldarg_3: + ExpandMacro (instruction, OpCodes.Ldarg, self.GetParameter (3)); + break; + case Code.Ldloc_0: + ExpandMacro (instruction, OpCodes.Ldloc, self.Variables [0]); + break; + case Code.Ldloc_1: + ExpandMacro (instruction, OpCodes.Ldloc, self.Variables [1]); + break; + case Code.Ldloc_2: + ExpandMacro (instruction, OpCodes.Ldloc, self.Variables [2]); + break; + case Code.Ldloc_3: + ExpandMacro (instruction, OpCodes.Ldloc, self.Variables [3]); + break; + case Code.Stloc_0: + ExpandMacro (instruction, OpCodes.Stloc, self.Variables [0]); + break; + case Code.Stloc_1: + ExpandMacro (instruction, OpCodes.Stloc, self.Variables [1]); + break; + case Code.Stloc_2: + ExpandMacro (instruction, OpCodes.Stloc, self.Variables [2]); + break; + case Code.Stloc_3: + ExpandMacro (instruction, OpCodes.Stloc, self.Variables [3]); + break; + case Code.Ldarg_S: + instruction.OpCode = OpCodes.Ldarg; + break; + case Code.Ldarga_S: + instruction.OpCode = OpCodes.Ldarga; + break; + case Code.Starg_S: + instruction.OpCode = OpCodes.Starg; + break; + case Code.Ldloc_S: + instruction.OpCode = OpCodes.Ldloc; + break; + case Code.Ldloca_S: + instruction.OpCode = OpCodes.Ldloca; + break; + case Code.Stloc_S: + instruction.OpCode = OpCodes.Stloc; + break; + case Code.Ldc_I4_M1: + ExpandMacro (instruction, OpCodes.Ldc_I4, -1); + break; + case Code.Ldc_I4_0: + ExpandMacro (instruction, OpCodes.Ldc_I4, 0); + break; + case Code.Ldc_I4_1: + ExpandMacro (instruction, OpCodes.Ldc_I4, 1); + break; + case Code.Ldc_I4_2: + ExpandMacro (instruction, OpCodes.Ldc_I4, 2); + break; + case Code.Ldc_I4_3: + ExpandMacro (instruction, OpCodes.Ldc_I4, 3); + break; + case Code.Ldc_I4_4: + ExpandMacro (instruction, OpCodes.Ldc_I4, 4); + break; + case Code.Ldc_I4_5: + ExpandMacro (instruction, OpCodes.Ldc_I4, 5); + break; + case Code.Ldc_I4_6: + ExpandMacro (instruction, OpCodes.Ldc_I4, 6); + break; + case Code.Ldc_I4_7: + ExpandMacro (instruction, OpCodes.Ldc_I4, 7); + break; + case Code.Ldc_I4_8: + ExpandMacro (instruction, OpCodes.Ldc_I4, 8); + break; + case Code.Ldc_I4_S: + ExpandMacro (instruction, OpCodes.Ldc_I4, (int) (sbyte) instruction.Operand); + break; + case Code.Br_S: + instruction.OpCode = OpCodes.Br; + break; + case Code.Brfalse_S: + instruction.OpCode = OpCodes.Brfalse; + break; + case Code.Brtrue_S: + instruction.OpCode = OpCodes.Brtrue; + break; + case Code.Beq_S: + instruction.OpCode = OpCodes.Beq; + break; + case Code.Bge_S: + instruction.OpCode = OpCodes.Bge; + break; + case Code.Bgt_S: + instruction.OpCode = OpCodes.Bgt; + break; + case Code.Ble_S: + instruction.OpCode = OpCodes.Ble; + break; + case Code.Blt_S: + instruction.OpCode = OpCodes.Blt; + break; + case Code.Bne_Un_S: + instruction.OpCode = OpCodes.Bne_Un; + break; + case Code.Bge_Un_S: + instruction.OpCode = OpCodes.Bge_Un; + break; + case Code.Bgt_Un_S: + instruction.OpCode = OpCodes.Bgt_Un; + break; + case Code.Ble_Un_S: + instruction.OpCode = OpCodes.Ble_Un; + break; + case Code.Blt_Un_S: + instruction.OpCode = OpCodes.Blt_Un; + break; + case Code.Leave_S: + instruction.OpCode = OpCodes.Leave; + break; + } + } + } + + static void ExpandMacro (Instruction instruction, OpCode opcode, object operand) + { + instruction.OpCode = opcode; + instruction.Operand = operand; + } + + static void MakeMacro (Instruction instruction, OpCode opcode) + { + instruction.OpCode = opcode; + instruction.Operand = null; + } + + public static void OptimizeMacros (this MethodBody self) + { + if (self == null) + throw new ArgumentNullException ("self"); + + var method = self.Method; + + foreach (var instruction in self.Instructions) { + int index; + switch (instruction.OpCode.Code) { + case Code.Ldarg: + index = ((ParameterDefinition) instruction.Operand).Index; + if (index == -1 && instruction.Operand == self.ThisParameter) + index = 0; + else if (method.HasThis) + index++; + + switch (index) { + case 0: + MakeMacro (instruction, OpCodes.Ldarg_0); + break; + case 1: + MakeMacro (instruction, OpCodes.Ldarg_1); + break; + case 2: + MakeMacro (instruction, OpCodes.Ldarg_2); + break; + case 3: + MakeMacro (instruction, OpCodes.Ldarg_3); + break; + default: + if (index < 256) + ExpandMacro (instruction, OpCodes.Ldarg_S, instruction.Operand); + break; + } + break; + case Code.Ldloc: + index = ((VariableDefinition) instruction.Operand).Index; + switch (index) { + case 0: + MakeMacro (instruction, OpCodes.Ldloc_0); + break; + case 1: + MakeMacro (instruction, OpCodes.Ldloc_1); + break; + case 2: + MakeMacro (instruction, OpCodes.Ldloc_2); + break; + case 3: + MakeMacro (instruction, OpCodes.Ldloc_3); + break; + default: + if (index < 256) + ExpandMacro (instruction, OpCodes.Ldloc_S, instruction.Operand); + break; + } + break; + case Code.Stloc: + index = ((VariableDefinition) instruction.Operand).Index; + switch (index) { + case 0: + MakeMacro (instruction, OpCodes.Stloc_0); + break; + case 1: + MakeMacro (instruction, OpCodes.Stloc_1); + break; + case 2: + MakeMacro (instruction, OpCodes.Stloc_2); + break; + case 3: + MakeMacro (instruction, OpCodes.Stloc_3); + break; + default: + if (index < 256) + ExpandMacro (instruction, OpCodes.Stloc_S, instruction.Operand); + break; + } + break; + case Code.Ldarga: + index = ((ParameterDefinition) instruction.Operand).Index; + if (index == -1 && instruction.Operand == self.ThisParameter) + index = 0; + else if (method.HasThis) + index++; + if (index < 256) + ExpandMacro (instruction, OpCodes.Ldarga_S, instruction.Operand); + break; + case Code.Ldloca: + if (((VariableDefinition) instruction.Operand).Index < 256) + ExpandMacro (instruction, OpCodes.Ldloca_S, instruction.Operand); + break; + case Code.Ldc_I4: + int i = (int) instruction.Operand; + switch (i) { + case -1: + MakeMacro (instruction, OpCodes.Ldc_I4_M1); + break; + case 0: + MakeMacro (instruction, OpCodes.Ldc_I4_0); + break; + case 1: + MakeMacro (instruction, OpCodes.Ldc_I4_1); + break; + case 2: + MakeMacro (instruction, OpCodes.Ldc_I4_2); + break; + case 3: + MakeMacro (instruction, OpCodes.Ldc_I4_3); + break; + case 4: + MakeMacro (instruction, OpCodes.Ldc_I4_4); + break; + case 5: + MakeMacro (instruction, OpCodes.Ldc_I4_5); + break; + case 6: + MakeMacro (instruction, OpCodes.Ldc_I4_6); + break; + case 7: + MakeMacro (instruction, OpCodes.Ldc_I4_7); + break; + case 8: + MakeMacro (instruction, OpCodes.Ldc_I4_8); + break; + default: + if (i >= -128 && i < 128) + ExpandMacro (instruction, OpCodes.Ldc_I4_S, (sbyte) i); + break; + } + break; + } + } + + OptimizeBranches (self); + } + + static void OptimizeBranches (MethodBody body) + { + ComputeOffsets (body); + + foreach (var instruction in body.Instructions) { + if (instruction.OpCode.OperandType != OperandType.InlineBrTarget) + continue; + + if (OptimizeBranch (instruction)) + ComputeOffsets (body); + } + } + + static bool OptimizeBranch (Instruction instruction) + { + var offset = ((Instruction) instruction.Operand).Offset - (instruction.Offset + instruction.OpCode.Size + 4); + if (!(offset >= -128 && offset <= 127)) + return false; + + switch (instruction.OpCode.Code) { + case Code.Br: + instruction.OpCode = OpCodes.Br_S; + break; + case Code.Brfalse: + instruction.OpCode = OpCodes.Brfalse_S; + break; + case Code.Brtrue: + instruction.OpCode = OpCodes.Brtrue_S; + break; + case Code.Beq: + instruction.OpCode = OpCodes.Beq_S; + break; + case Code.Bge: + instruction.OpCode = OpCodes.Bge_S; + break; + case Code.Bgt: + instruction.OpCode = OpCodes.Bgt_S; + break; + case Code.Ble: + instruction.OpCode = OpCodes.Ble_S; + break; + case Code.Blt: + instruction.OpCode = OpCodes.Blt_S; + break; + case Code.Bne_Un: + instruction.OpCode = OpCodes.Bne_Un_S; + break; + case Code.Bge_Un: + instruction.OpCode = OpCodes.Bge_Un_S; + break; + case Code.Bgt_Un: + instruction.OpCode = OpCodes.Bgt_Un_S; + break; + case Code.Ble_Un: + instruction.OpCode = OpCodes.Ble_Un_S; + break; + case Code.Blt_Un: + instruction.OpCode = OpCodes.Blt_Un_S; + break; + case Code.Leave: + instruction.OpCode = OpCodes.Leave_S; + break; + } + + return true; + } + + static void ComputeOffsets (MethodBody body) + { + var offset = 0; + foreach (var instruction in body.Instructions) { + instruction.Offset = offset; + offset += instruction.GetSize (); + } + } + + public static ParameterDefinition GetParameter (this MethodBody self, int index) + { + var method = self.Method; + + if (method.HasThis) { + if (index == 0) + return self.ThisParameter; + + index--; + } + + var parameters = method.Parameters; + + if (index < 0 || index >= parameters.Count) + return null; + + return parameters [index]; + } + + public static bool Implements (this TypeReference self, string interfaceName) + { + if (interfaceName == null) + throw new ArgumentNullException ("interfaceName"); + if (self == null) + return false; + + TypeDefinition type = self.Resolve (); + if (type == null) + return false; // not enough information available + + // special case, check if we implement ourselves + if (type.IsInterface && (type.FullName == interfaceName)) + return true; + + return Implements (type, interfaceName, (interfaceName.IndexOf ('`') >= 0)); + } + + public static bool Implements (TypeDefinition type, string interfaceName, bool generic) + { + while (type != null) { + // does the type implements it itself + if (type.HasInterfaces) { + foreach (var iface in type.Interfaces) { + string fullname = (generic) ? iface.InterfaceType.GetElementType ().FullName : iface.InterfaceType.FullName; + if (fullname == interfaceName) + return true; + //if not, then maybe one of its parent interfaces does + if (Implements (iface.InterfaceType.Resolve (), interfaceName, generic)) + return true; + } + } + + type = type.BaseType != null ? type.BaseType.Resolve () : null; + } + return false; + } + + public static bool Inherits (this TypeReference self, string @namespace, string name) + { + if (@namespace == null) + throw new ArgumentNullException ("namespace"); + if (name == null) + throw new ArgumentNullException ("name"); + if (self == null) + return false; + + TypeReference current = self.Resolve (); + while (current != null) { + if (current.Is (@namespace, name)) + return true; + if (current.Is ("System", "Object")) + return false; + + TypeDefinition td = current.Resolve (); + if (td == null) + return false; // could not resolve type + current = td.BaseType; + } + return false; + } + } +} diff --git a/src/Microsoft.Android.Sdk.ILLink/Mono.Tuner/Extensions.cs b/src/Xamarin.Android.Build.Tasks/Linker/External/Mono.Tuner/Extensions.cs similarity index 92% rename from src/Microsoft.Android.Sdk.ILLink/Mono.Tuner/Extensions.cs rename to src/Xamarin.Android.Build.Tasks/Linker/External/Mono.Tuner/Extensions.cs index f6af83d8b95..3e3b312133b 100644 --- a/src/Microsoft.Android.Sdk.ILLink/Mono.Tuner/Extensions.cs +++ b/src/Xamarin.Android.Build.Tasks/Linker/External/Mono.Tuner/Extensions.cs @@ -5,11 +5,10 @@ using Mono.Linker; -namespace Mono.Tuner -{ +namespace Mono.Tuner { + + public static partial class Extensions { - public static partial class Extensions - { public static bool TryGetLinkedAssembly (this LinkContext context, string name, out AssemblyDefinition assembly) { assembly = GetAssembly (context, name); diff --git a/src/Xamarin.Android.Build.Tasks/Linker/External/Mono.Tuner/Profile.cs b/src/Xamarin.Android.Build.Tasks/Linker/External/Mono.Tuner/Profile.cs new file mode 100644 index 00000000000..54cfffa64f1 --- /dev/null +++ b/src/Xamarin.Android.Build.Tasks/Linker/External/Mono.Tuner/Profile.cs @@ -0,0 +1,78 @@ +using System; +using System.Collections.Generic; + +using Mono.Cecil; + +namespace Mono.Tuner { + + public abstract class Profile { + + static Profile current; + + public static Profile Current { + get { + if (current != null) + return current; + + current = CreateProfile ("MonoTouch"); + if (current != null) + return current; + + current = CreateProfile ("MonoDroid"); + if (current != null) + return current; + + current = CreateProfile ("MonoMac"); + if (current != null) + return current; + + throw new NotSupportedException ("No active profile"); + } + set { + current = value; + } + } + + static Profile CreateProfile (string name) + { + var type = Type.GetType (string.Format ("{0}.Tuner.{0}Profile", name)); + if (type == null) + return null; + + return (Profile) Activator.CreateInstance (type); + } + + public static bool IsSdkAssembly (AssemblyDefinition assembly) + { + return Current.IsSdk (assembly); + } + + public static bool IsSdkAssembly (string assemblyName) + { + return Current.IsSdk (assemblyName); + } + + public static bool IsProductAssembly (AssemblyDefinition assembly) + { + return Current.IsProduct (assembly); + } + + public static bool IsProductAssembly (string assemblyName) + { + return Current.IsProduct (assemblyName); + } + + protected virtual bool IsSdk (AssemblyDefinition assembly) + { + return IsSdk (assembly.Name.Name); + } + + protected virtual bool IsProduct (AssemblyDefinition assembly) + { + return IsProduct (assembly.Name.Name); + } + + protected abstract bool IsSdk (string assemblyName); + protected abstract bool IsProduct (string assemblyName); + } +} diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Xamarin.Android.Build.Tests.csproj b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Xamarin.Android.Build.Tests.csproj index ad22a1aeaed..2b0eb2702ea 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Xamarin.Android.Build.Tests.csproj +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Xamarin.Android.Build.Tests.csproj @@ -16,9 +16,7 @@ - - $(MicrosoftAndroidSdkOutDir)Xamarin.Android.Cecil.dll - + $(MicrosoftAndroidSdkOutDir)Xamarin.Android.Build.Debugging.Tasks.dll diff --git a/src/Xamarin.Android.Build.Tasks/Utilities/ManifestDocumentElement.cs b/src/Xamarin.Android.Build.Tasks/Utilities/ManifestDocumentElement.cs index 6b685a996c9..cf51a75094f 100644 --- a/src/Xamarin.Android.Build.Tasks/Utilities/ManifestDocumentElement.cs +++ b/src/Xamarin.Android.Build.Tasks/Utilities/ManifestDocumentElement.cs @@ -8,7 +8,6 @@ using Monodroid; using MonoDroid.Tuner; -using MonoDroid.Utils; using Java.Interop.Tools.Cecil; using Java.Interop.Tools.TypeNameMappings; diff --git a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj index 5aad65dfbb1..b274f6b5bc1 100644 --- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj +++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj @@ -23,18 +23,7 @@ - - $(MicrosoftAndroidSdkOutDir)Mono.CompilerServices.SymbolWriter.dll - - - $(MicrosoftAndroidSdkOutDir)Xamarin.Android.Cecil.dll - - - $(MicrosoftAndroidSdkOutDir)Xamarin.Android.Cecil.Mdb.dll - - - - + @@ -54,195 +43,40 @@ - - Linker\Mono.Tuner\AdjustVisibility.cs - - - Linker\Mono.Tuner\CecilRocks.cs - - - Linker\Mono.Tuner\CheckVisibility.cs - - - Linker\Linker\Annotations.cs - - - Linker\Linker\AssemblyAction.cs - - - Linker\Linker\AssemblyResolver.cs - - - Linker\Linker\AssemblyUtilities.cs - - - Linker\Linker\I18nAssemblies.cs - - - Linker\Linker\Inflater.cs - - - Linker\Linker\IXApiVisitor.cs - - - Linker\Linker\LinkContext.cs - - - Linker\Linker\MethodAction.cs - - - Linker\Linker\MethodReferenceExtensions.cs - - - Linker\Linker\OutputException.cs - - - Linker\Linker\OverrideInformation.cs - - - Linker\Linker\Pipeline.cs - - - Linker\Linker\TypeNameParser.cs - - - Linker\Linker\TypePreserve.cs - - - Linker\Linker\TypeReferenceExtensions.cs - - - Linker\Linker\XApiReader.cs - - - Linker\Linker.Steps\BlacklistStep.cs - - - Linker\Linker.Steps\BaseStep.cs - - - Linker\Linker.Steps\CleanStep.cs - - - Linker\Linker.Steps\IStep.cs - - - Linker\Linker.Steps\LoadI18nAssemblies.cs - - - Linker\Linker.Steps\LoadReferencesStep.cs - - - Linker\Linker.Steps\OutputStep.cs - - - Linker\Linker.Steps\RegenerateGuidStep.cs - - - Linker\Linker.Steps\ResolveFromAssemblyStep.cs - - - Linker\Linker.Steps\ResolveFromXApiStep.cs - - - Linker\Linker.Steps\ResolveFromXmlStep.cs - - - Linker\Linker.Steps\ResolveStep.cs - - - Linker\Linker.Steps\TypeMapStep.cs - - - Linker\Linker.Steps\SweepStep.cs - - - Linker\Linker.Steps\MarkStep.cs - - - Linker\Linker.Steps\PreserveDependencyLookupStep.cs - - - Linker\Linker.Steps\BodySubstituterStep.cs - - - Linker\Linker\IDependencyRecorder.cs - - - Linker\Linker\IReflectionPatternRecorder.cs - - - Linker\Linker\LoggingReflectionPatternRecorder.cs - - - Linker\Linker\XmlDependencyRecorder.cs - - - Linker\Linker\LoadException.cs - - - Linker\Linker\MarkException.cs - - - Linker\Linker\ConsoleLogger.cs - - - Linker\Linker\ILogger.cs - - - Linker\Linker\Tracer.cs - - - Linker\Linker\MarkingHelpers.cs - - - Linker\Linker\KnownMembers.cs - - - Linker\Linker\MethodDefinitionExtensions.cs - - - Linker\Linker\MethodBodyScanner.cs - - - Linker\Linker\TypeDefinitionExtensions.cs - - - Linker\Linker\BCL.cs - - - Linker\Mono.Tuner\ApplyPreserveAttributeBase.cs - - - Linker\Mono.Tuner\Dispatcher.cs - - - Linker\Mono.Tuner\CustomizeActions.cs - - - Linker\Mono.Tuner\Extensions.cs - - - Linker\Mono.Tuner\FixModuleFlags.cs - - - Linker\Mono.Tuner\PreserveCrypto.cs - - - Linker\Mono.Tuner\PreserveSoapHttpClients.cs - - - Linker\Mono.Tuner\Profile.cs - - - Linker\Mono.Tuner\RemoveAttributesBase.cs - - - Linker\Mono.Tuner\RemoveResources.cs - - - Linker\Mono.Tuner\RemoveSecurity.cs - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Mono.Android\IntentFilterAttribute.cs @@ -261,21 +95,6 @@ Utilities\StringRocks.cs - - Linker\Mono.Tuner\FilterAttributes.cs - - - Linker\Mono.Tuner\InjectSecurityAttributes.cs - - - Linker\Mono.Tuner\PrintStatus.cs - - - Linker\Mono.Tuner\RemoveSerialization.cs - - - Linker\Mono.Tuner\TunerAnnotations.cs - Mono.Android\UsesLibraryAttribute.cs diff --git a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.targets b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.targets index ad49a5e4116..7aa2f2c8e35 100644 --- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.targets +++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.targets @@ -181,7 +181,7 @@ + Replacements="@JAVA_INTEROP_COMMIT@=$(_BuildInfo_JavaInteropCommit);@SQLITE_COMMIT@=$(_BuildInfo_SqliteCommit);@XAMARIN_ANDROID_TOOLS_COMMIT@=$(_BuildInfo_XamarinAndroidToolsCommit);"> <_ExtraPackageSource Include="$(PkgXamarin_Build_AsyncTask)\lib\$(TargetFrameworkNETStandard)\Xamarin.Build.AsyncTask.pdb" /> <_ExtraPackageTarget Include="$(OutputPath)\Xamarin.Build.AsyncTask.pdb" /> + <_ExtraPackageSource Include="$(PkgMono_Cecil)\lib\$(TargetFrameworkNETStandard)\Mono.Cecil.pdb" /> + <_ExtraPackageTarget Include="$(OutputPath)\Mono.Cecil.pdb" /> + <_ExtraPackageSource Include="$(PkgMono_Cecil)\lib\$(TargetFrameworkNETStandard)\Mono.Cecil.Mdb.pdb" /> + <_ExtraPackageTarget Include="$(OutputPath)\Mono.Cecil.Mdb.pdb" /> <_ExtraPackageSource Include="$(PkgMono_Unix)\lib\$(TargetFrameworkNETStandard)\Mono.Unix.pdb" /> <_ExtraPackageTarget Include="$(OutputPath)\Mono.Unix.pdb" /> diff --git a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.BuildInfo.txt.in b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.BuildInfo.txt.in index 3fce495b128..7606ffaa56e 100644 --- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.BuildInfo.txt.in +++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.BuildInfo.txt.in @@ -6,7 +6,6 @@ # # Lines starting with # are comments # -Mono: @MONO_COMMIT@ Java.Interop: @JAVA_INTEROP_COMMIT@ SQLite: @SQLITE_COMMIT@ Xamarin.Android Tools: @XAMARIN_ANDROID_TOOLS_COMMIT@ diff --git a/src/Xamarin.Android.Tools.Aidl/Xamarin.Android.Tools.Aidl.csproj b/src/Xamarin.Android.Tools.Aidl/Xamarin.Android.Tools.Aidl.csproj index 72222d4f09b..44a16cd6941 100644 --- a/src/Xamarin.Android.Tools.Aidl/Xamarin.Android.Tools.Aidl.csproj +++ b/src/Xamarin.Android.Tools.Aidl/Xamarin.Android.Tools.Aidl.csproj @@ -9,9 +9,7 @@ $(NoWarn);CA1305 - - $(MicrosoftAndroidSdkOutDir)Xamarin.Android.Cecil.dll - + diff --git a/src/Xamarin.Android.Tools.JavadocImporter/Xamarin.Android.Tools.JavadocImporter.csproj b/src/Xamarin.Android.Tools.JavadocImporter/Xamarin.Android.Tools.JavadocImporter.csproj index a2a6de446e3..8529f06fb6b 100644 --- a/src/Xamarin.Android.Tools.JavadocImporter/Xamarin.Android.Tools.JavadocImporter.csproj +++ b/src/Xamarin.Android.Tools.JavadocImporter/Xamarin.Android.Tools.JavadocImporter.csproj @@ -11,9 +11,7 @@ - - $(MicrosoftAndroidSdkOutDir)Xamarin.Android.Cecil.dll - + diff --git a/tests/MSBuildDeviceIntegration/MSBuildDeviceIntegration.csproj b/tests/MSBuildDeviceIntegration/MSBuildDeviceIntegration.csproj index 12bf94a46b0..15d262d06cf 100644 --- a/tests/MSBuildDeviceIntegration/MSBuildDeviceIntegration.csproj +++ b/tests/MSBuildDeviceIntegration/MSBuildDeviceIntegration.csproj @@ -37,9 +37,7 @@ - - $(MicrosoftAndroidSdkOutDir)Xamarin.Android.Cecil.dll - + @@ -55,6 +53,4 @@ - - diff --git a/tests/MSBuildDeviceIntegration/MSBuildDeviceIntegration.targets b/tests/MSBuildDeviceIntegration/MSBuildDeviceIntegration.targets deleted file mode 100644 index a5d9d353238..00000000000 --- a/tests/MSBuildDeviceIntegration/MSBuildDeviceIntegration.targets +++ /dev/null @@ -1,22 +0,0 @@ - - - - - <_Source Include="$(OutputPath)Mono.Debugging.Soft.dll"> - Mono.Cecil - $(OutputPath)Xamarin.Android.Cecil.dll - - <_Source Include="$(OutputPath)Mono.Debugger.Soft.dll"> - Mono.Cecil - $(OutputPath)Xamarin.Android.Cecil.dll - - - - - - \ No newline at end of file diff --git a/tests/Xamarin.Android.Tools.Aidl-Tests/Xamarin.Android.Tools.Aidl-Tests.csproj b/tests/Xamarin.Android.Tools.Aidl-Tests/Xamarin.Android.Tools.Aidl-Tests.csproj index 12a729d15b4..28b64d83c19 100644 --- a/tests/Xamarin.Android.Tools.Aidl-Tests/Xamarin.Android.Tools.Aidl-Tests.csproj +++ b/tests/Xamarin.Android.Tools.Aidl-Tests/Xamarin.Android.Tools.Aidl-Tests.csproj @@ -22,8 +22,6 @@ - - ..\..\bin\$(Configuration)\lib\xamarin.android\xbuild\Xamarin\Android\Xamarin.Android.Cecil.dll - +