Example #1
0
        static List<string> ListAssemblies(MonoTouchLinkContext context)
        {
            var list = new List<string> ();
            foreach (var assembly in context.GetAssemblies ()) {
                if (context.Annotations.GetAction (assembly) == AssemblyAction.Delete)
                    continue;

                list.Add (GetFullyQualifiedName (assembly));
            }

            return list;
        }
Example #2
0
        public static void Process(LinkerOptions options, out MonoTouchLinkContext context, out List<string> assemblies)
        {
            var pipeline = CreatePipeline (options);

            pipeline.PrependStep (new MobileResolveMainAssemblyStep (options.MainAssembly));

            context = CreateLinkContext (options, pipeline);
            context.Resolver.AddSearchDirectory (options.OutputDirectory);

            if (options.DumpDependencies) {
                var prepareDependenciesDump = context.Annotations.GetType ().GetMethod ("PrepareDependenciesDump", new Type[1] { typeof (string) });
                if (prepareDependenciesDump != null)
                    prepareDependenciesDump.Invoke (context.Annotations, new object[1] { string.Format ("{0}{1}linker-dependencies.xml.gz", options.OutputDirectory, Path.DirectorySeparatorChar) });
            }

            try {
                pipeline.Process (context);
            } catch (FileNotFoundException fnfe) {
                // Cecil throw this if the assembly is not found
                throw new MonoTouchException (2002, true, fnfe, fnfe.Message);
            } catch (AggregateException) {
                throw;
            } catch (MonoTouchException) {
                throw;
            } catch (ResolutionException re) {
                TypeReference tr = (re.Member as TypeReference);
                IMetadataScope scope = tr == null ? re.Member.DeclaringType.Scope : tr.Scope;
                throw new MonoTouchException (2002, true, re, "Failed to resolve \"{0}\" reference from \"{1}\"", re.Member, scope);
            } catch (Exception e) {
                throw new MonoTouchException (2001, true, e, "Could not link assemblies. Reason: {0}", e.Message);
            }

            assemblies = ListAssemblies (context);
        }
Example #3
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;
        }
Example #4
0
        public void LinkAssemblies(string main, ref List<string> assemblies, string output_dir, out MonoTouchLinkContext link_context)
        {
            if (Driver.Verbosity > 0)
                Console.WriteLine ("Linking {0} into {1} using mode '{2}'", main, output_dir, App.LinkMode);

            var cache = Resolver.ToResolverCache ();
            var resolver = cache != null
                ? new AssemblyResolver (cache)
                : new AssemblyResolver ();

            resolver.AddSearchDirectory (Resolver.RootDirectory);
            resolver.AddSearchDirectory (Resolver.FrameworkDirectory);

            var options = new LinkerOptions {
                MainAssembly = Resolver.Load (main),
                OutputDirectory = output_dir,
                LinkMode = App.LinkMode,
                Resolver = resolver,
                SkippedAssemblies = App.LinkSkipped,
                I18nAssemblies = App.I18n,
                LinkSymbols = true,
                LinkAway = App.LinkAway,
                ExtraDefinitions = App.Definitions,
                Device = App.IsDeviceBuild,
                // by default we keep the code to ensure we're executing on the UI thread (for UI code) for debug builds
                // but this can be overridden to either (a) remove it from debug builds or (b) keep it in release builds
                EnsureUIThread = App.ThreadCheck.HasValue ? App.ThreadCheck.Value : App.EnableDebug,
                OldRegistrar = (App.Registrar == RegistrarMode.LegacyDynamic || App.Registrar == RegistrarMode.LegacyStatic),
                DebugBuild = App.EnableDebug,
                Arch = Is64Build ? 8 : 4,
                IsDualBuild = App.IsDualBuild,
                Unified = App.IsUnified,
                DumpDependencies = App.LinkerDumpDependencies,
                RuntimeOptions = App.RuntimeOptions
            };

            MonoTouch.Tuner.Linker.Process (options, out link_context, out assemblies);

            // reset resolver
            foreach (var file in assemblies) {
                /*				var assembly = */Resolver.Load (file);
                // FIXME assembly.MainModule.AssemblyResolver = Resolver;
            }
            Driver.Watch ("Link Assemblies", 1);
        }