Esempio n. 1
0
        protected override void Process()
        {
            string tfmPaths;

            if (Context.TryGetCustomData("XATargetFrameworkDirectories", out tfmPaths))
            {
                Xamarin.Android.Tasks.MonoAndroidHelper.TargetFrameworkDirectories = tfmPaths.Split(new char [] { ';' });
            }

            var subSteps = new SubStepDispatcher();

            subSteps.Add(new PreserveExportedTypes());
            subSteps.Add(new MarkJavaObjects());
            subSteps.Add(new PreserveJavaExceptions());
            subSteps.Add(new PreserveJavaTypeRegistrations());
            subSteps.Add(new PreserveApplications());

            var cache = new TypeDefinitionCache();

            InsertAfter(new FixAbstractMethodsStep(cache), "RemoveUnreachableBlocksStep");
            InsertAfter(subSteps, "RemoveUnreachableBlocksStep");

            string proguardPath;

            if (Context.TryGetCustomData("ProguardConfiguration", out proguardPath))
            {
                InsertAfter(new GenerateProguardConfiguration(proguardPath), "CleanStep");
            }
        }
Esempio n. 2
0
        static SubStepDispatcher GetSubSteps(LinkerOptions options)
        {
            SubStepDispatcher sub = new SubStepDispatcher();

            sub.Add(new ApplyPreserveAttribute());
            sub.Add(new CoreRemoveSecurity());
            sub.Add(new OptimizeGeneratedCodeSubStep(options));
            // OptimizeGeneratedCodeSubStep needs [GeneratedCode] so it must occurs before RemoveAttributes
            sub.Add(new RemoveAttributes());
            // http://bugzilla.xamarin.com/show_bug.cgi?id=1408
            if (options.LinkAway)
            {
                sub.Add(new RemoveCode(options));
            }
            sub.Add(new MarkNSObjects());
            sub.Add(new PreserveSoapHttpClients());
            // there's only one registrar for unified, i.e. DynamicRegistrar
            if (!options.Unified)
            {
                sub.Add(new RemoveExtraRegistrar(options.OldRegistrar));
            }
            sub.Add(new CoreHttpMessageHandler(options));
            sub.Add(new CoreTlsProviderStep(options));
            return(sub);
        }
Esempio n. 3
0
        static SubStepDispatcher GetPostLinkOptimizations(LinkerOptions options)
        {
            SubStepDispatcher sub = new SubStepDispatcher();

            sub.Add(new MetadataReducerSubStep());
            sub.Add(new SealerSubStep());
            return(sub);
        }
Esempio n. 4
0
        static SubStepDispatcher GetPostLinkOptimizations(LinkerOptions options)
        {
            SubStepDispatcher sub = new SubStepDispatcher();

            sub.Add(new MetadataReducerSubStep());
            if (options.Application.Optimizations.SealAndDevirtualize == true)
            {
                sub.Add(new SealerSubStep());
            }
            return(sub);
        }
Esempio n. 5
0
        static SubStepDispatcher GetSubSteps(LinkerOptions options)
        {
            SubStepDispatcher sub = new SubStepDispatcher();

            sub.Add(new ApplyPreserveAttribute());
            sub.Add(new OptimizeGeneratedCodeSubStep(options));
            sub.Add(new RemoveUserResourcesSubStep());
            // OptimizeGeneratedCodeSubStep and RemoveUserResourcesSubStep needs [GeneratedCode] so it must occurs before RemoveAttributes
            if (options.Application.Optimizations.CustomAttributesRemoval == true)
            {
                sub.Add(new CoreRemoveAttributes());
            }

            sub.Add(new CoreHttpMessageHandler(options));
            sub.Add(new MarkNSObjects());

            // CoreRemoveSecurity can modify non-linked assemblies
            // but the conditions for this cannot happen if only the platform assembly is linked
            if (options.LinkMode != LinkMode.Platform)
            {
                sub.Add(new CoreRemoveSecurity());
            }

            return(sub);
        }
        static SubStepDispatcher GetPostLinkOptimizations(LinkerOptions options)
        {
            SubStepDispatcher sub = new SubStepDispatcher();

            if (options.Application.Optimizations.ForceRejectedTypesRemoval == true)
            {
                sub.Add(new RemoveRejectedTypesStep());
            }
            if (!options.DebugBuild)
            {
                sub.Add(new MetadataReducerSubStep());
                if (options.Application.Optimizations.SealAndDevirtualize == true)
                {
                    sub.Add(new SealerSubStep());
                }
            }
            return(sub);
        }
Esempio n. 7
0
        static SubStepDispatcher GetSubSteps(LinkerOptions options)
        {
            SubStepDispatcher sub = new SubStepDispatcher();

            sub.Add(new ApplyPreserveAttribute());
            sub.Add(new CoreRemoveSecurity());
            sub.Add(new OptimizeGeneratedCodeSubStep(options));
            sub.Add(new RemoveUserResourcesSubStep(options));
            // OptimizeGeneratedCodeSubStep and RemoveUserResourcesSubStep needs [GeneratedCode] so it must occurs before RemoveAttributes
            sub.Add(new RemoveAttributes());
            // http://bugzilla.xamarin.com/show_bug.cgi?id=1408
            if (options.LinkAway)
            {
                sub.Add(new RemoveCode(options));
            }
            sub.Add(new MarkNSObjects());
            sub.Add(new PreserveSoapHttpClients());
            sub.Add(new CoreHttpMessageHandler(options));
            sub.Add(new InlinerSubStep());
            return(sub);
        }
Esempio n. 8
0
        static SubStepDispatcher GetSubSteps(LinkerOptions options)
        {
            SubStepDispatcher sub = new SubStepDispatcher();

            sub.Add(new ApplyPreserveAttribute());
            sub.Add(new CoreRemoveSecurity());
            sub.Add(new OptimizeGeneratedCodeSubStep(options));
            // OptimizeGeneratedCodeSubStep needs [GeneratedCode] so it must occurs before RemoveAttributes
            sub.Add(new RemoveAttributes());
            // http://bugzilla.xamarin.com/show_bug.cgi?id=1408
            if (options.LinkAway)
            {
                sub.Add(new RemoveCode(options));
            }
            sub.Add(new MarkNSObjects());
            sub.Add(new PreserveSoapHttpClients());
            sub.Add(new CoreHttpMessageHandler(options));
            if (Driver.App.Platform != Xamarin.Utils.ApplePlatform.WatchOS)
            {
                sub.Add(new CoreTlsProviderStep(options));
            }
            return(sub);
        }
Esempio n. 9
0
        protected override void Process()
        {
            string tfmPaths;

            if (Context.TryGetCustomData("XATargetFrameworkDirectories", out tfmPaths))
            {
                Xamarin.Android.Tasks.MonoAndroidHelper.TargetFrameworkDirectories = tfmPaths.Split(new char [] { ';' });
            }

            var subSteps1 = new SubStepDispatcher();

            subSteps1.Add(new ApplyPreserveAttribute());

            var cache     = new TypeDefinitionCache();
            var subSteps2 = new SubStepDispatcher();

            subSteps2.Add(new PreserveExportedTypes());
            subSteps2.Add(new MarkJavaObjects());
            subSteps2.Add(new PreserveJavaExceptions());
            subSteps2.Add(new PreserveJavaTypeRegistrations());
            subSteps2.Add(new PreserveApplications());
            subSteps2.Add(new PreserveRegistrations(cache));
            subSteps2.Add(new PreserveJavaInterfaces());

            InsertAfter(new FixAbstractMethodsStep(cache), "RemoveUnreachableBlocksStep");
            InsertAfter(subSteps2, "RemoveUnreachableBlocksStep");
            InsertAfter(subSteps1, "RemoveUnreachableBlocksStep");

            string proguardPath;

            if (Context.TryGetCustomData("ProguardConfiguration", out proguardPath))
            {
                InsertAfter(new GenerateProguardConfiguration(proguardPath), "CleanStep");
            }

            string addKeepAlivesStep;

            if (Context.TryGetCustomData("AddKeepAlivesStep", out addKeepAlivesStep) && bool.TryParse(addKeepAlivesStep, out var bv) && bv)
            {
                InsertAfter(new AddKeepAlivesStep(cache), "CleanStep");
            }

            InsertAfter(new StripEmbeddedLibraries(), "CleanStep");
        }
Esempio n. 10
0
        static SubStepDispatcher GetSubSteps()
        {
            SubStepDispatcher sub = new SubStepDispatcher();

            sub.Add(new MobileApplyPreserveAttribute());
            sub.Add(new OptimizeGeneratedCodeSubStep());
            sub.Add(new RemoveUserResourcesSubStep());
            // OptimizeGeneratedCodeSubStep and RemoveUserResourcesSubStep needs [GeneratedCode] so it must occurs before RemoveAttributes
            sub.Add(new CoreRemoveAttributes());

            sub.Add(new CoreHttpMessageHandler());
            sub.Add(new MarkNSObjects());

            sub.Add(new CoreRemoveSecurity());

            return(sub);
        }
        static Pipeline CreatePipeline(LinkerOptions options)
        {
            var pipeline = new Pipeline();

            pipeline.Append(new LoadReferencesStep());

            if (options.I18nAssemblies != I18nAssemblies.None)
            {
                pipeline.Append(new LoadI18nAssemblies(options.I18nAssemblies));
            }

            // that must be done early since the XML files can "add" new assemblies [#15878]
            // and some of the assemblies might be (directly or referenced) SDK assemblies
            foreach (string definition in options.ExtraDefinitions)
            {
                pipeline.Append(GetResolveStep(definition));
            }

            if (options.LinkMode != LinkMode.None)
            {
                pipeline.Append(new BlacklistStep());
            }

            if (options.WarnOnTypeRef.Count > 0)
            {
                pipeline.Append(new PreLinkScanTypeReferenceStep(options.WarnOnTypeRef));
            }

            pipeline.Append(new CustomizeIOSActions(options.LinkMode, options.SkippedAssemblies));

            // We need to store the Field attribute in annotations, since it may end up removed.
            pipeline.Append(new ProcessExportedFields());

            // We remove incompatible bitcode from all assemblies, not only the linked assemblies.
            RemoveBitcodeIncompatibleCodeStep remove_incompatible_bitcode = null;

            if (options.Application.Optimizations.RemoveUnsupportedILForBitcode == true)
            {
                remove_incompatible_bitcode = new RemoveBitcodeIncompatibleCodeStep(options);
            }

            if (options.LinkMode != LinkMode.None)
            {
                pipeline.Append(new CoreTypeMapStep());

                pipeline.Append(GetSubSteps());

                pipeline.Append(new PreserveCode(options));

                pipeline.Append(new RemoveResources(options.I18nAssemblies));                   // remove collation tables

                pipeline.Append(new MonoTouchMarkStep());

                // We only want to remove from methods that aren't already linked away, so we need to do this
                // after the mark step. If we remove any incompatible code, we'll mark
                // the NotSupportedException constructor we need, so we need to do this before the sweep step.
                if (remove_incompatible_bitcode != null)
                {
                    pipeline.Append(new SubStepDispatcher {
                        remove_incompatible_bitcode
                    });
                }

                pipeline.Append(new MonoTouchSweepStep(options));
                pipeline.Append(new CleanStep());

                pipeline.AppendStep(GetPostLinkOptimizations(options));

                pipeline.Append(new FixModuleFlags());
            }
            else
            {
                SubStepDispatcher sub = new SubStepDispatcher()
                {
                    new RemoveUserResourcesSubStep(),
                };
                if (options.Application.Optimizations.ForceRejectedTypesRemoval == true)
                {
                    sub.Add(new RemoveRejectedTypesStep());
                }
                if (remove_incompatible_bitcode != null)
                {
                    sub.Add(remove_incompatible_bitcode);
                }
                pipeline.Append(sub);
            }

            pipeline.Append(new ListExportedSymbols(options.MarshalNativeExceptionsState));

            pipeline.Append(new OutputStep());

            // expect that changes can occur until it's all saved back to disk
            if (options.WarnOnTypeRef.Count > 0)
            {
                pipeline.Append(new PostLinkScanTypeReferenceStep(options.WarnOnTypeRef));
            }

            return(pipeline);
        }
Esempio n. 12
0
        static Pipeline CreatePipeline(LinkerOptions options)
        {
            var pipeline = new Pipeline();

            pipeline.AppendStep(options.LinkMode == LinkMode.None ? new LoadOptionalReferencesStep() : new LoadReferencesStep());

            if (options.I18nAssemblies != I18nAssemblies.None)
            {
                pipeline.AppendStep(new LoadI18nAssemblies(options.I18nAssemblies));
            }

            // that must be done early since the XML files can "add" new assemblies [#15878]
            // and some of the assemblies might be (directly or referenced) SDK assemblies
            foreach (string definition in options.ExtraDefinitions)
            {
                pipeline.AppendStep(GetResolveStep(definition));
            }

            if (options.LinkMode != LinkMode.None)
            {
                pipeline.AppendStep(new BlacklistStep());
            }

            pipeline.AppendStep(new CustomizeMacActions(options.LinkMode, options.SkippedAssemblies));

            // We need to store the Field attribute in annotations, since it may end up removed.
            pipeline.AppendStep(new ProcessExportedFields());

            if (options.LinkMode != LinkMode.None)
            {
                pipeline.AppendStep(new CoreTypeMapStep());

                var subdispatcher = new SubStepDispatcher {
                    new ApplyPreserveAttribute(),
                    new OptimizeGeneratedCodeSubStep(options),
                    new RemoveUserResourcesSubStep(),
                    new CoreRemoveAttributes(),
                    new CoreHttpMessageHandler(options),
                    new MarkNSObjects(),
                };
                // CoreRemoveSecurity can modify non-linked assemblies
                // but the conditions for this cannot happen if only the platform assembly is linked
                if (options.LinkMode != LinkMode.Platform)
                {
                    subdispatcher.Add(new CoreRemoveSecurity());
                }
                pipeline.AppendStep(subdispatcher);

                pipeline.AppendStep(new MonoMacPreserveCode(options));
                pipeline.AppendStep(new PreserveCrypto());

                pipeline.AppendStep(new MonoMacMarkStep());
                pipeline.AppendStep(new MacRemoveResources(options));
                pipeline.AppendStep(new CoreSweepStep(options.LinkSymbols));
                pipeline.AppendStep(new CleanStep());

                pipeline.AppendStep(new MonoMacNamespaces());
                pipeline.AppendStep(new RemoveSelectors());

                pipeline.AppendStep(new RegenerateGuidStep());
            }
            else
            {
                SubStepDispatcher sub = new SubStepDispatcher()
                {
                    new RemoveUserResourcesSubStep()
                };
                pipeline.AppendStep(sub);
            }

            pipeline.AppendStep(new ListExportedSymbols(options.MarshalNativeExceptionsState, options.SkipExportedSymbolsInSdkAssemblies));

            pipeline.AppendStep(new OutputStep());

            return(pipeline);
        }
Esempio n. 13
0
        protected override void Process()
        {
            string tfmPaths;

            if (Context.TryGetCustomData("XATargetFrameworkDirectories", out tfmPaths))
            {
                Xamarin.Android.Tasks.MonoAndroidHelper.TargetFrameworkDirectories = tfmPaths.Split(new char [] { ';' });
            }

            var subSteps1 = new SubStepDispatcher();

            subSteps1.Add(new ApplyPreserveAttribute());

            var cache     = new TypeDefinitionCache();
            var subSteps2 = new SubStepDispatcher();

            subSteps2.Add(new PreserveExportedTypes());
            subSteps2.Add(new MarkJavaObjects());
            subSteps2.Add(new PreserveJavaExceptions());
            subSteps2.Add(new PreserveApplications());
            subSteps2.Add(new PreserveRegistrations(cache));
            subSteps2.Add(new PreserveJavaInterfaces());

            InsertAfter(new FixAbstractMethodsStep(cache), "SetupStep");
            InsertAfter(subSteps2, "SetupStep");
            InsertAfter(subSteps1, "SetupStep");

            // temporary workaround: this call forces illink to process all the assemblies
            if (getReferencedAssembliesMethod == null)
            {
                throw new InvalidOperationException($"Temporary linker workaround failed, {nameof (getReferencedAssembliesMethod)} is null.");
            }

            foreach (var assembly in (IEnumerable <AssemblyDefinition>)getReferencedAssembliesMethod.Invoke(Context, null))
            {
                Context.LogMessage($"Reference assembly to process: {assembly}");
            }

            string proguardPath;

            if (Context.TryGetCustomData("ProguardConfiguration", out proguardPath))
            {
                InsertAfter(new GenerateProguardConfiguration(proguardPath), "CleanStep");
            }

            string addKeepAlivesStep;

            if (Context.TryGetCustomData("AddKeepAlivesStep", out addKeepAlivesStep) && bool.TryParse(addKeepAlivesStep, out var bv) && bv)
            {
                InsertAfter(new AddKeepAlivesStep(cache), "CleanStep");
            }

            string androidLinkResources;

            if (Context.TryGetCustomData("AndroidLinkResources", out androidLinkResources) && bool.TryParse(androidLinkResources, out var linkResources) && linkResources)
            {
                InsertAfter(new RemoveResourceDesignerStep(), "CleanStep");
                InsertAfter(new GetAssembliesStep(), "CleanStep");
            }
            InsertAfter(new StripEmbeddedLibraries(), "CleanStep");
        }
        static SubStepDispatcher GetSubSteps()
        {
            SubStepDispatcher sub = new SubStepDispatcher();

            sub.Add(new ApplyPreserveAttribute());
            sub.Add(new CoreRemoveSecurity());
            sub.Add(new OptimizeGeneratedCodeSubStep());
            sub.Add(new RemoveUserResourcesSubStep());
            sub.Add(new RemoveAttributes());
            // http://bugzilla.xamarin.com/show_bug.cgi?id=1408
            sub.Add(new RemoveCode());
            sub.Add(new MarkNSObjects());
            sub.Add(new PreserveSoapHttpClients());
            sub.Add(new CoreHttpMessageHandler());
            sub.Add(new InlinerSubStep());
            sub.Add(new PreserveSmartEnumConversionsSubStep());
            return(sub);
        }
Esempio n. 15
0
 static SubStepDispatcher GetPostLinkOptimizations(LinkerOptions options)
 {
     SubStepDispatcher sub = new SubStepDispatcher ();
     sub.Add (new MetadataReducerSubStep ());
     sub.Add (new SealerSubStep ());
     return sub;
 }
Esempio n. 16
0
        static SubStepDispatcher GetSubSteps(LinkerOptions options)
        {
            SubStepDispatcher sub = new SubStepDispatcher();

            sub.Add(new ApplyPreserveAttribute());
            sub.Add(new CoreRemoveSecurity());
            sub.Add(new OptimizeGeneratedCodeSubStep(options));
            sub.Add(new RemoveUserResourcesSubStep(options));
            if (options.Application.Optimizations.CustomAttributesRemoval == true)
            {
                sub.Add(new RemoveAttributes());
            }
            // http://bugzilla.xamarin.com/show_bug.cgi?id=1408
            if (options.LinkAway)
            {
                sub.Add(new RemoveCode(options));
            }
            sub.Add(new MarkNSObjects());
            sub.Add(new PreserveSoapHttpClients());
            sub.Add(new CoreHttpMessageHandler(options));
            sub.Add(new InlinerSubStep());
            sub.Add(new PreserveSmartEnumConversionsSubStep());
            return(sub);
        }
Esempio n. 17
0
 static SubStepDispatcher GetSubSteps(LinkerOptions options)
 {
     SubStepDispatcher sub = new SubStepDispatcher ();
     sub.Add (new ApplyPreserveAttribute ());
     sub.Add (new CoreRemoveSecurity ());
     sub.Add (new OptimizeGeneratedCodeSubStep (options));
     // OptimizeGeneratedCodeSubStep needs [GeneratedCode] so it must occurs before RemoveAttributes
     sub.Add (new RemoveAttributes ());
     // http://bugzilla.xamarin.com/show_bug.cgi?id=1408
     if (options.LinkAway)
         sub.Add (new RemoveCode (options));
     sub.Add (new MarkNSObjects ());
     sub.Add (new PreserveSoapHttpClients ());
     // there's only one registrar for unified, i.e. DynamicRegistrar
     if (!options.Unified)
         sub.Add (new RemoveExtraRegistrar (options.OldRegistrar));
     sub.Add (new CoreHttpMessageHandler (options));
     sub.Add (new CoreTlsProviderStep (options));
     return sub;
 }