Exemplo n.º 1
0
		public LinkContext (Pipeline pipeline, AssemblyResolver resolver)
		{
			_pipeline = pipeline;
			_resolver = resolver;
			_actions = new Hashtable ();
			_parameters = new Hashtable ();
		}
		protected override void CustomizePipeline (Pipeline pipeline)
		{
			pipeline.ReplaceStep (typeof (MarkStep), new MoonlightA11yApiMarker ());
			pipeline.ReplaceStep (typeof (SweepStep), new MoonlightA11yDescriptorGenerator ());
			pipeline.RemoveStep (typeof (LoadI18nAssemblies));
			pipeline.RemoveStep (typeof (CleanStep));
			pipeline.RemoveStep (typeof (RegenerateGuidStep));
			pipeline.RemoveStep (typeof (OutputStep));
		}
Exemplo n.º 3
0
		protected override void CustomizePipeline (Pipeline pipeline)
		{
			pipeline.RemoveStep (typeof (LoadI18nAssemblies));
			pipeline.RemoveStep (typeof (BlacklistStep));
			pipeline.RemoveStep (typeof (MarkStep));
			pipeline.RemoveStep (typeof (SweepStep));
			pipeline.RemoveStep (typeof (CleanStep));
			pipeline.RemoveStep (typeof (RegenerateGuidStep));
			pipeline.AddStepBefore (typeof (OutputStep), new MoonlightA11yProcessor ());
		}
		protected virtual void CustomizePipeline (Pipeline pipeline)
		{
			pipeline.RemoveStep (typeof (LoadI18nAssemblies));
			pipeline.RemoveStep (typeof (BlacklistStep));
			pipeline.RemoveStep (typeof (TypeMapStep));
			pipeline.RemoveStep (typeof (MarkStep));
			pipeline.RemoveStep (typeof (SweepStep));
			pipeline.RemoveStep (typeof (CleanStep));
			pipeline.RemoveStep (typeof (RegenerateGuidStep));
			pipeline.AddStepBefore (typeof (OutputStep), new InjectSecurityAttributes ());
		}
Exemplo n.º 5
0
 static LinkContext CreateLinkContext(LinkerOptions options, Pipeline pipeline)
 {
     var context = new LinkContext (pipeline, options.Resolver);
     if (options.DumpDependencies) {
         var prepareDependenciesDump = context.Annotations.GetType ().GetMethod ("PrepareDependenciesDump", new Type[] {});
         if (prepareDependenciesDump != null)
             prepareDependenciesDump.Invoke (context.Annotations, null);
     }
     context.LogInternalExceptions = Xamarin.Android.Tasks.MonoAndroidHelper.LogInternalExceptions;
     context.CoreAction = AssemblyAction.Link;
     context.LinkSymbols = true;
     context.SymbolReaderProvider = new MdbReaderProvider ();
     context.SymbolWriterProvider = new MdbWriterProvider ();
     context.OutputDirectory = options.OutputDirectory;
     return context;
 }
Exemplo n.º 6
0
 static void Run(Pipeline pipeline, LinkContext context)
 {
     pipeline.Process (context);
 }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            var mydir = new FileInfo(Assembly.GetExecutingAssembly().Location).Directory;
            var monoroot = mydir.Parent.Parent.Parent.Parent;

            var inputdir = Path.Combine(monoroot.FullName,"builds/monodistribution/lib/mono/unity");
            var outputdir = Path.Combine(monoroot.FullName, "tmp/unity_linkered");

            if (Directory.Exists(outputdir))
                Directory.Delete(outputdir, true);
            Directory.CreateDirectory(outputdir);

            var assemblies = new List<string>();
            var nonassemblies = new List<string>();
            var files = new List<string>();
            foreach(var file in Directory.GetFiles(inputdir))
            {
                var ext = Path.GetExtension(file);
                var filename = Path.GetFileName(file);
                files.Add(filename);
                if (ext == ".dll" || ext==".exe")
                    assemblies.Add(filename);
                else
                    nonassemblies.Add(filename);
            }

            Console.WriteLine("InputDir: "+inputdir);
            Console.WriteLine("OutputDir: "+outputdir);

            Pipeline p = new Pipeline();

            foreach(var file in assemblies)
            {
                var fullfile = Path.Combine(inputdir,file);
                IStep s = null;
                var action = GetAssemblyAction(file);
                if (action==AssemblyAction.Link)
                    s = new MarkPublicApiExceptStep(fullfile);
                else if (action == AssemblyAction.Copy)
                    s = new ResolveFromAssemblyStep(fullfile);
                if (s!=null) p.AppendStep(s);
            }
            p.AppendStep(new LoadReferencesStep());
            p.AppendStep(new BlacklistStep());
            p.AppendStep(new TypeMapStep());
            p.AppendStep(new MarkAllFieldsOfSerializableTypes());
            p.AppendStep(new MarkStep());
            p.AppendStep(new SweepStep());
            p.AppendStep(new CleanStep());
            p.AppendStep(new RegenerateGuidStep());
            p.AppendStep(new OutputStep());
            p.AppendStep(new OutputMarkBacktraceReportStep());
            p.AppendStep(new FailIfWeMissTypesThatWeShippedInAPreviousVersionStep());

            LinkContext context = new LinkContext(p);
            context.CoreAction = AssemblyAction.Link;
            context.OutputDirectory = outputdir;
            context.Resolver.AddSearchDirectory(inputdir);
            p.Process(context);

            foreach(var file in files.Where(f => GetAssemblyAction(f)==AssemblyAction.Copy))
            {
                var _from = Path.Combine(inputdir,file);
                var _to = Path.Combine(outputdir,file);
                File.Copy(_from,_to,true);
            }
            WriteDiffReport(inputdir,assemblies, outputdir);
        }
Exemplo n.º 8
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 TypeMapStep ());

                pipeline.AppendStep (new SubStepDispatcher {
                    new ApplyPreserveAttribute (),
                    new CoreRemoveSecurity (),
                    new OptimizeGeneratedCodeSubStep (options.EnsureUIThread),
                    new CoreRemoveAttributes (),
                    new CoreHttpMessageHandler (options),
                    new CoreTlsProviderStep (options),
                    new MarkNSObjects (),
                });

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

                pipeline.AppendStep (new MonoMacMarkStep ());
                pipeline.AppendStep (new MacRemoveResources (options));
                pipeline.AppendStep (new MobileSweepStep ());
                pipeline.AppendStep (new CleanStep ());

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

                pipeline.AppendStep (new RegenerateGuidStep ());
            }

            pipeline.AppendStep (new ListExportedSymbols ());

            pipeline.AppendStep (new OutputStep ());

            return pipeline;
        }
Exemplo n.º 9
0
 static LinkContext CreateLinkContext(LinkerOptions options, Pipeline pipeline)
 {
     var context = new MonoMacLinkContext (pipeline, options.Resolver);
     context.CoreAction = AssemblyAction.Link;
     context.LinkSymbols = options.LinkSymbols;
     if (options.LinkSymbols) {
         context.SymbolReaderProvider = new MdbReaderProvider ();
         context.SymbolWriterProvider = new MdbWriterProvider ();
     }
     context.OutputDirectory = options.OutputDirectory;
     return context;
 }
Exemplo n.º 10
0
		static Type FindStep (Pipeline pipeline, string name)
		{
			foreach (IStep step in pipeline.GetSteps ()) {
				Type t = step.GetType ();
				if (t.Name == name)
					return t;
			}

			return null;
		}
Exemplo n.º 11
0
		public LinkContext (Pipeline pipeline)
			: this (pipeline, new AssemblyResolver ())
		{
		}
Exemplo n.º 12
0
 public LinkContext(Pipeline pipeline, AssemblyResolver resolver)
     : this(pipeline, resolver, new ReaderParameters {
     AssemblyResolver = resolver
 }, new UnintializedContextFactory())
 {
 }
Exemplo n.º 13
0
 public LinkContext(Pipeline pipeline)
     : this(pipeline, new AssemblyResolver())
 {
 }
Exemplo n.º 14
0
		static LinkContext GetDefaultContext (Pipeline pipeline)
		{
			LinkContext context = new LinkContext (pipeline);
			context.CoreAction = AssemblyAction.Skip;
			context.OutputDirectory = "output";
			return context;
		}
Exemplo n.º 15
0
        static MonoTouchLinkContext CreateLinkContext(LinkerOptions options, Pipeline pipeline)
        {
            var context = new MonoTouchLinkContext (pipeline, options.Resolver);
            context.CoreAction = options.LinkMode == LinkMode.None ? AssemblyAction.Copy : AssemblyAction.Link;
            context.LinkSymbols = options.LinkSymbols;
            context.OutputDirectory = options.OutputDirectory;
            context.SetParameter ("debug-build", options.DebugBuild.ToString ());

            options.LinkContext = context;

            return context;
        }
Exemplo n.º 16
0
        static Pipeline CreatePipeline(LinkerOptions options)
        {
            var pipeline = new Pipeline ();

            if (options.LinkNone) {
                pipeline.AppendStep (new FixAbstractMethodsStep ());
                pipeline.AppendStep (new OutputStep ());
                return pipeline;
            }

            pipeline.AppendStep (new LoadReferencesStep ());

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

            pipeline.AppendStep (new BlacklistStep ());

            foreach (var desc in options.LinkDescriptions)
                pipeline.AppendStep (new ResolveFromXmlStep (new XPathDocument (desc)));

            pipeline.AppendStep (new CustomizeActions (options.LinkSdkOnly, options.SkippedAssemblies));

            pipeline.AppendStep (new TypeMapStep ());

            // monodroid tuner steps
            pipeline.AppendStep (new SubStepDispatcher {
                new ApplyPreserveAttribute (),
                new PreserveExportedTypes (),
                new RemoveSecurity (),
                new MarkJavaObjects (),
                new PreserveJavaExceptions (),
                new PreserveJavaTypeRegistrations (),
                new PreserveApplications (),
                new RemoveAttributes (),
                new PreserveDynamicTypes (),
                new PreserveSoapHttpClients (),
                new PreserveTypeConverters (),
                new PreserveLinqExpressions (),
                new PreserveRuntimeSerialization (),
            });

            pipeline.AppendStep (new PreserveCrypto ());
            pipeline.AppendStep (new PreserveCode ());

            pipeline.AppendStep (new RemoveLibraryResourceZip ());
            pipeline.AppendStep (new RemoveResources (options.I18nAssemblies)); // remove collation tables
            // end monodroid specific

            pipeline.AppendStep (new FixAbstractMethodsStep ());
            pipeline.AppendStep (new MonoDroidMarkStep ());
            pipeline.AppendStep (new SweepStep ());
            pipeline.AppendStep (new CleanStep ());
            // monodroid tuner steps
            if (!string.IsNullOrWhiteSpace (options.ProguardConfiguration))
                pipeline.AppendStep (new GenerateProguardConfiguration (options.ProguardConfiguration));
            // end monodroid specific
            pipeline.AppendStep (new RegenerateGuidStep ());
            pipeline.AppendStep (new OutputStep ());

            return pipeline;
        }
Exemplo n.º 17
0
        static Pipeline CreatePipeline(LinkerOptions options)
        {
            var pipeline = new Pipeline ();

            pipeline.AppendStep (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 CustomizeIOSActions (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 MonoTouchTypeMapStep ());

                pipeline.AppendStep (GetSubSteps (options));

                pipeline.AppendStep (new PreserveCode (options));

                // only remove bundled resources on device builds as MonoDevelop requires the resources later
                // (to be extracted). That differs from the device builds (where another unmodified copy is used)
                if (options.Device)
                    pipeline.AppendStep (new RemoveMonoTouchResources ());

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

                pipeline.AppendStep (new MonoTouchMarkStep ());
                pipeline.AppendStep (new MonoTouchSweepStep ());
                pipeline.AppendStep (new CleanStep ());

                if (!options.DebugBuild)
                    pipeline.AppendStep (GetPostLinkOptimizations (options));

                pipeline.AppendStep (new RemoveSelectors ());
                pipeline.AppendStep (new FixModuleFlags ());
            }

            pipeline.AppendStep (new ListExportedSymbols ());

            pipeline.AppendStep (new OutputStep ());

            return pipeline;
        }
Exemplo n.º 18
0
		public LinkContext (Pipeline pipeline, AssemblyResolver resolver)
		{
			_pipeline = pipeline;
			_resolver = resolver;
			_actions = new Hashtable ();
			_parameters = new Hashtable ();
			_annotations = new AnnotationStore ();
			_readerParameters = new ReaderParameters {
				AssemblyResolver = _resolver,
			};
		}
Exemplo n.º 19
0
 public MonoMacLinkContext(Pipeline pipeline, AssemblyResolver resolver)
     : base(pipeline, resolver)
 {
 }
Exemplo n.º 20
0
 static Pipeline GetStandardPipeline()
 {
     var pipeline = new Pipeline();
     pipeline.AppendStep(new LoadReferencesStep());
     pipeline.AppendStep(new BlacklistStep());
     pipeline.AppendStep(new TypeMapStep());
     pipeline.AppendStep(new MarkStep());
     pipeline.AppendStep(new SweepStep());
     pipeline.AppendStep(new CleanStep());
     pipeline.AppendStep(new RegenerateGuidStep());
     pipeline.AppendStep(new OutputStep());
     return pipeline;
 }
Exemplo n.º 21
0
		static void AddCustomStep (Pipeline pipeline, string arg)
		{
			int pos = arg.IndexOf (":");
			if (pos == -1) {
				pipeline.AppendStep (ResolveStep (arg));
				return;
			}

			string [] parts = arg.Split (':');
			if (parts.Length != 2)
				Usage ("Step is specified as TYPE:STEP");

			if (parts [0].IndexOf (",") > -1)
				pipeline.AddStepBefore (FindStep (pipeline, parts [1]), ResolveStep (parts [0]));
			else if (parts [1].IndexOf (",") > -1)
				pipeline.AddStepAfter (FindStep (pipeline, parts [0]), ResolveStep (parts [1]));
			else
				Usage ("No comma separator in TYPE or STEP");
		}