示例#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);
            }
        }
示例#2
0
 public static void AddCommonReferences(CompilerOptions options)
 {
     options.AddRef(GetCorlibPath(true));
     foreach (var cr in CommonAssemblies)
     {
         string lib = GetLibPath(cr);
         if (File.Exists(lib))
         {
             options.AddRef(lib);
         }
     }
 }
示例#3
0
        static void RunTest(Test test)
        {
            string wd = Environment.CurrentDirectory;

            const string prefix   = "__pfx_nunit";
            const string name_cs  = prefix + ".cs";
            const string name_exe = prefix + ".exe";
            const string name_swf = prefix + ".swf";

            string mainFile = Path.Combine(wd, name_cs);

            File.WriteAllText(mainFile, test.MainCode);

            var compilerOptions = new CompilerOptions
            {
                Target   = CompilerTarget.ConsoleApp,
                Output   = name_exe,
                NoLogo   = true,
                NoConfig = true,
                NoStdlib = true
            };

            GlobalSettings.AddCommonReferences(compilerOptions);
            compilerOptions.AddRef(_asmpath);
            compilerOptions.Input.Add(name_cs);

            string cout = CompilerConsole.Run(compilerOptions);

            if (CompilerConsole.HasErrors(cout))
            {
                Console.WriteLine(cout);
                Environment.Exit(-1);
            }

            string path_exe = Path.Combine(wd, name_exe);
            string path_swf = Path.Combine(wd, name_swf);

            var asm = LoadAssembly(path_exe);

            MakeSwf(asm, path_swf);
            RunPlayer(test, path_swf);
            Report.AddTest(test);
        }
示例#4
0
 static void AddCorlibRef(CompilerOptions options)
 {
     options.AddRef(GlobalSettings.GetCorlibPath(true));
 }
示例#5
0
        private static void SetCompilerOptions(TestCase tc, CompilerLanguage lang, CompilerOptions options)
        {
            options.Language = lang;
            options.Debug    = tc.Debug;
            options.Optimize = tc.Optimize;
            options.Unsafe   = tc.Unsafe;
            options.Output   = tc.ExePath;
            options.Target   = CompilerTarget.ConsoleApp;
            options.NoLogo   = true;
            options.Checked  = false;

            options.Define("TARGET_JVM");             //to remove unsafe
            options.Define("NET_2_0");
            options.Defines.AddRange(tc.Defines);

            if (tc.VM == VM.CLR)
            {
                options.Define("MSCLR");
            }
            else if (tc.VM == VM.AVM)
            {
                options.Define("AVM");
            }

            //common refs
            if (tc.VM == VM.AVM)
            {
                GlobalSettings.AddCommonReferences(options);

                options.AddRef(Path.Combine(GlobalSettings.LibsDirectory, "flash.v10.2.dll"));

                options.NoConfig = true;
                options.NoStdlib = true;

                if (lang == CompilerLanguage.VB)
                {
                    //options.NoVBRuntime = true;
                    options.VBRuntime = GlobalSettings.Libs.VBRuntime;
                    //options.CompactFramework = true;
                    options.SDKPath = GlobalSettings.Dirs.Libs;
                    options.NoWarn  = true;
                }
            }
            else
            {
                options.AddRef("System.Core.dll");
            }

            if (tc.IsNUnit)
            {
                if (tc.VM == VM.CLR)
                {
                    string nunit = QA.GetNUnitFrameworkPath(GlobalOptions.UseCommonDirectory ? "" : tc.Root);
                    options.AddRef(nunit);
                }
                else
                {
                    options.AddRef(GlobalSettings.GetLibPath(QA.NUnitFrameworkDll));
                }
                options.AddRef(tc.GetNUnitTestsPath(tc.Root));
            }

            options.Input.AddRange(tc.SourceFiles.Names);
        }