Ejemplo n.º 1
0
        protected override void TryProcess()
        {
            // Don't use --custom-step to load each step, because this assembly
            // is loaded into the current process once per --custom-step,
            // which makes it very difficult to share state between steps.

            // Load the list of assemblies loaded by the linker.
            // This would not be needed of LinkContext.GetAssemblies () was exposed to us.
            InsertAfter(new CollectAssembliesStep(), "LoadReferencesStep");

            var pre_dynamic_dependency_lookup_substeps = new DotNetSubStepDispatcher();

            InsertBefore(pre_dynamic_dependency_lookup_substeps, "DynamicDependencyLookupStep");

            var prelink_substeps = new DotNetSubStepDispatcher();

            InsertAfter(prelink_substeps, "RemoveSecurityStep");

            var post_sweep_substeps = new DotNetSubStepDispatcher();

            InsertAfter(post_sweep_substeps, "SweepStep");

            if (Configuration.LinkMode != LinkMode.None)
            {
                pre_dynamic_dependency_lookup_substeps.Add(new PreserveBlockCodeSubStep());

                // We need to run the ApplyPreserveAttribute step even we're only linking sdk assemblies, because even
                // though we know that sdk assemblies will never have Preserve attributes, user assemblies may have
                // [assembly: LinkSafe] attributes, which means we treat them as sdk assemblies and those may have
                // Preserve attributes.
                prelink_substeps.Add(new ApplyPreserveAttribute());
                prelink_substeps.Add(new OptimizeGeneratedCodeSubStep());
                prelink_substeps.Add(new MarkNSObjects());
                prelink_substeps.Add(new PreserveSmartEnumConversionsSubStep());
                prelink_substeps.Add(new CollectUnmarkedMembersSubStep());

                post_sweep_substeps.Add(new RemoveAttributesStep());
            }

            Steps.Add(new LoadNonSkippedAssembliesStep());
            Steps.Add(new ExtractBindingLibrariesStep());
            Steps.Add(new RegistrarStep());
            Steps.Add(new GenerateMainStep());
            Steps.Add(new GatherFrameworksStep());

            Configuration.Write();

            if (Configuration.Verbosity > 0)
            {
                Console.WriteLine();
                Console.WriteLine("Pipeline Steps:");
                foreach (var step in Steps)
                {
                    Console.WriteLine($"    {step}");
                    if (step is SubStepsDispatcher)
                    {
                        var substeps = typeof(SubStepsDispatcher).GetField("substeps", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(step) as IEnumerable <ISubStep>;
                        if (substeps != null)
                        {
                            foreach (var substep in substeps)
                            {
                                Console.WriteLine($"        {substep}");
                            }
                        }
                    }
                }
            }

            ErrorHelper.Platform = Configuration.Platform;
            Directory.CreateDirectory(Configuration.ItemsDirectory);
            Directory.CreateDirectory(Configuration.CacheDirectory);
        }
Ejemplo n.º 2
0
        protected override void TryProcess()
        {
            // Don't use --custom-step to load each step, because this assembly
            // is loaded into the current process once per --custom-step,
            // which makes it very difficult to share state between steps.

            // Load the list of assemblies loaded by the linker.
            // This would not be needed of LinkContext.GetAssemblies () was exposed to us.
            InsertBefore(new CollectAssembliesStep(), "MarkStep");

            var pre_dynamic_dependency_lookup_substeps = new DotNetSubStepDispatcher();

            InsertBefore(pre_dynamic_dependency_lookup_substeps, "MarkStep");

            var prelink_substeps = new DotNetSubStepDispatcher();

            InsertBefore(prelink_substeps, "MarkStep");

            var post_sweep_substeps = new DotNetSubStepDispatcher();

            InsertAfter(post_sweep_substeps, "SweepStep");

            if (Configuration.LinkMode != LinkMode.None)
            {
                pre_dynamic_dependency_lookup_substeps.Add(new PreserveBlockCodeSubStep());

                // We need to run the ApplyPreserveAttribute step even we're only linking sdk assemblies, because even
                // though we know that sdk assemblies will never have Preserve attributes, user assemblies may have
                // [assembly: LinkSafe] attributes, which means we treat them as sdk assemblies and those may have
                // Preserve attributes.
                prelink_substeps.Add(new ApplyPreserveAttribute());
                prelink_substeps.Add(new OptimizeGeneratedCodeSubStep());
                prelink_substeps.Add(new MarkNSObjects());
                prelink_substeps.Add(new PreserveSmartEnumConversionsSubStep());
                prelink_substeps.Add(new CollectUnmarkedMembersSubStep());
                prelink_substeps.Add(new StoreAttributesStep());

                post_sweep_substeps.Add(new RemoveAttributesStep());
            }

            InsertBefore(new ListExportedSymbols(null), "OutputStep");
            InsertBefore(new LoadNonSkippedAssembliesStep(), "OutputStep");
            InsertBefore(new ExtractBindingLibrariesStep(), "OutputStep");
            InsertBefore(new DotNetSubStepDispatcher(new RemoveUserResourcesSubStep()), "OutputStep");
            Steps.Add(new RegistrarStep());
            Steps.Add(new GenerateMainStep());
            Steps.Add(new GenerateReferencesStep());
            Steps.Add(new GatherFrameworksStep());
            Steps.Add(new ComputeNativeBuildFlagsStep());
            Steps.Add(new ComputeAOTArguments());
            Steps.Add(new DoneStep());               // Must be the last step.

            Configuration.Write();

            if (Configuration.Verbosity > 0)
            {
                DumpSteps();
            }

            ErrorHelper.Platform = Configuration.Platform;
            Directory.CreateDirectory(Configuration.ItemsDirectory);
            Directory.CreateDirectory(Configuration.CacheDirectory);
        }