Ejemplo n.º 1
0
        /// <summary>
        /// Compile an assembly into a dex file.
        /// </summary>
        private static void CompileAssembly(CommandLineOptions options, NameConverter nsConverter)
        {
            // Load resource type usage info file
            var usedTypeNames = LoadResourceTypeUsageInformation(options);

            // Load assemblies
            var assemblies       = new List <AssemblyDefinition>();
            var module           = new XModule();
            var classLoader      = new AssemblyClassLoader(module.OnClassLoaded);
            var resolver         = new AssemblyResolver(options.ReferenceFolders, classLoader, module.OnAssemblyLoaded);
            var readerParameters = new ReaderParameters(ReadingMode.Immediate)
            {
                AssemblyResolver     = resolver,
                SymbolReaderProvider = new SafeSymbolReaderProvider(),
                ReadSymbols          = true
            };

            foreach (var asmPath in options.Assemblies)
            {
                var asm = resolver.Load(asmPath, readerParameters);
                module.OnAssemblyLoaded(asm);
                classLoader.LoadAssembly(asm);
                assemblies.Add(asm);
            }
            // Load references
            var references = new List <AssemblyDefinition>();

            foreach (var refPath in options.References)
            {
                var asm = resolver.Load(refPath, readerParameters);
                module.OnAssemblyLoaded(asm);
                classLoader.LoadAssembly(asm);
                references.Add(asm);
            }

            // Load resources
            Table table;

            using (var stream = new FileStream(options.InputResources, FileMode.Open, FileAccess.Read))
            {
                table = new Table(stream);
            }

            // Create compiler
            var compiler = new AssemblyCompiler(options.CompilationMode, assemblies, references, table, nsConverter, options.DebugInfo, classLoader, usedTypeNames, module);

            compiler.Compile();
            compiler.Save(options.OutputFolder, options.FreeAppsKeyPath);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Default ctor
        /// </summary>
        private ManifestBuilder(string assemblyFile, IEnumerable<string> referenceFolders, string packageName, NameConverter nsConverter, bool debuggable, List<string> appWidgetProviderCodeFiles, string targetSdkVersion)
        {
#if DEBUG
            //Debugger.Launch();
#endif

            module = new XModule();
            this.packageName = packageName;
            this.nsConverter = nsConverter;
            this.debuggable = debuggable;
            this.appWidgetProviderCodeFiles = appWidgetProviderCodeFiles;
            this.targetSdkVersion = targetSdkVersion;

            // Load assembly file
            if (!File.Exists(assemblyFile))
                throw new ArgumentException(string.Format("Assembly {0} not found", assemblyFile));
            var parameters = new ReaderParameters { AssemblyResolver = new AssemblyResolver(referenceFolders, null, module.OnAssemblyLoaded) };
            assembly = AssemblyDefinition.ReadAssembly(assemblyFile, parameters);
            module.OnAssemblyLoaded(assembly);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Default ctor
        /// </summary>
        private ManifestBuilder(string assemblyFile, IEnumerable <string> referenceFolders, string packageName, NameConverter nsConverter, bool debuggable, List <string> appWidgetProviderCodeFiles, string targetSdkVersion)
        {
#if DEBUG
            //Debugger.Launch();
#endif

            module           = new XModule();
            this.packageName = packageName;
            this.nsConverter = nsConverter;
            this.debuggable  = debuggable;
            this.appWidgetProviderCodeFiles = appWidgetProviderCodeFiles;
            this.targetSdkVersion           = targetSdkVersion;

            // Load assembly file
            if (!File.Exists(assemblyFile))
            {
                throw new ArgumentException(string.Format("Assembly {0} not found", assemblyFile));
            }
            var parameters = new ReaderParameters {
                AssemblyResolver = new AssemblyResolver(referenceFolders, null, module.OnAssemblyLoaded)
            };
            assembly = AssemblyDefinition.ReadAssembly(assemblyFile, parameters);
            module.OnAssemblyLoaded(assembly);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Compile an assembly into a dex file.
        /// </summary>
        private static void CompileAssembly(CommandLineOptions options, NameConverter nsConverter)
        {
            // Load resource type usage info file
            var usedTypeNames = LoadResourceTypeUsageInformation(options);

            // Load assemblies
            var assemblies = new List<AssemblyDefinition>();
            var module = new XModule();
            var classLoader = new AssemblyClassLoader(module.OnClassLoaded);
            var resolver = new AssemblyResolver(options.ReferenceFolders, classLoader, module.OnAssemblyLoaded);
            var readerParameters = new ReaderParameters(ReadingMode.Immediate)
            {
                AssemblyResolver = resolver,
                SymbolReaderProvider = new SafeSymbolReaderProvider(),
                ReadSymbols = true
            };
            foreach (var asmPath in options.Assemblies)
            {
                var asm = resolver.Load(asmPath, readerParameters);
                module.OnAssemblyLoaded(asm);
                classLoader.LoadAssembly(asm);
                assemblies.Add(asm);
            }
            // Load references
            var references = new List<AssemblyDefinition>();
            foreach (var refPath in options.References)
            {
                var asm = resolver.Load(refPath, readerParameters);
                module.OnAssemblyLoaded(asm);
                classLoader.LoadAssembly(asm);
                references.Add(asm);
            }

            // Load resources
            Table table;
            using (var stream = new FileStream(options.InputResources, FileMode.Open, FileAccess.Read))
            {
                table = new Table(stream);
            }

            // Create compiler
            var compiler = new AssemblyCompiler(options.CompilationMode, assemblies, references, table, nsConverter, options.DebugInfo, classLoader, usedTypeNames, module);
            compiler.Compile();
            compiler.Save(options.OutputFolder, options.FreeAppsKeyPath);
        }