Esempio n. 1
0
        static void CompileAssembly()
        {
            var options = new CompilerOptions();

            //redirect cl options to compiler
            if (!RedirectOptions(options))
            {
                LogError(Errors.InvalidCommandLine);
                Environment.Exit(-1);
            }

            //remove system references
            options.References.RemoveAll(IsSysRef);

            //add reference to pagefx corlib
            AddCorlibRef(options);
            AddCommonoRefs(options);

            if (cl.HasOption(PFCOptions.MX))
            {
                string mx = GlobalSettings.GetMxLibraryPath();
                if (!File.Exists(mx))
                {
                    //TODO: raise error
                }
                options.AddRef(mx);
            }

            var rsls = RslList.Parse(cl);

            foreach (var rsl in rsls)
            {
                options.AddRef(rsl.Library);
            }

            options.NoLogo   = true;
            options.NoStdlib = true;
            options.NoConfig = true;
            options.Output   = asmpath;

            string cout = CompilerConsole.Run(options, true);

            var errors = CompilerConsole.ParseOutput(cout);

            if (NoMain(errors))
            {
                asmpath        = Path.ChangeExtension(asmpath, ".dll");
                options.Output = asmpath;
                options.Target = CompilerTarget.Library;

                cout   = CompilerConsole.Run(options, true);
                errors = CompilerConsole.ParseOutput(cout);
            }

            if (errors.HasErrors)
            {
                Console.WriteLine(cout);
                Environment.Exit(-1);
            }
        }
Esempio n. 2
0
        private static void Compile(CompilerOptions copts, string path)
        {
            string olddir = Environment.CurrentDirectory;

            try
            {
                Environment.CurrentDirectory = Path.GetDirectoryName(path);
                string cout   = CompilerConsole.Run(copts, true);
                var    errors = CompilerConsole.ParseOutput(cout);
                if (errors.HasErrors)
                {
                    throw new InvalidOperationException(string.Format("Unable to generate wrapper.\n{0}", cout));
                }
                if (errors.HasWarnings)
                {
                    Console.WriteLine(cout);
                }
            }
            finally
            {
                Environment.CurrentDirectory = olddir;
            }
        }