Beispiel #1
0
        private CompilerResults FromFileWorker(CompilerParameters options, params string[] files)
        {
            CompilerResults res = new CompilerResults(options.TempFiles);

            PEFileKinds targetKind;

            if (options.OutputAssembly != null)
            {
                if (options.OutputAssembly.ToLower().EndsWith(".exe"))
                {
                    targetKind = PEFileKinds.WindowApplication;
                }
                else
                {
                    targetKind = options.GenerateExecutable ? PEFileKinds.WindowApplication : PEFileKinds.Dll;
                }
            }
            else
            {
                targetKind = PEFileKinds.WindowApplication;
            }

            AppDomain compileDomain = null;

            try {
                compileDomain = AppDomain.CreateDomain("compilation domain");
                RemoteCompiler rc = (RemoteCompiler)compileDomain.CreateInstanceAndUnwrap(
                    Assembly.GetExecutingAssembly().FullName,
                    "IronPython.CodeDom.RemoteCompiler");

                rc.Initialize(files, options.OutputAssembly, options.IncludeDebugInformation, options.ReferencedAssemblies, targetKind);

                rc.DoCompile();
                res.NativeCompilerReturnValue = rc.ErrorCount;
                for (int i = 0; i < rc.Errors.Count; i++)
                {
                    res.Errors.Add(rc.Errors[i]);
                }
                try {
                    if (options.GenerateInMemory)
                    {
                        res.CompiledAssembly = rc.CompiledAssembly;
                    }
                } catch {
                }
            } finally {
                AppDomain.Unload(compileDomain);
            }

            return(res);
        }
Beispiel #2
0
 public RemoteCompiler()
 {
     instance = this;
     assmRefs = new List <Assembly>();
 }
Beispiel #3
0
 public CodeDomCompilerSink(RemoteCompiler results)
 {
     compResults = results;
 }