public CompileJobStatus Update()
        {
            if (process != null && started && process.HasExited)
            {
                string output = process.StandardOutput.ReadToEnd();
                string errors = process.StandardError.ReadToEnd();

                if (!string.IsNullOrEmpty(output))
                {
                    Debug.Log(output);
                }
                if (!string.IsNullOrEmpty(errors))
                {
                    Debug.Log(errors);
                }
                if (process.ExitCode == 0)
                {
                    status = CompileJobStatus.Succeeded;
                }
                else
                {
                    status = CompileJobStatus.Failed;
                }
                process.Close();
                process.Dispose();
                process = null;
            }
            return(status);
        }
 public void CleanUp()
 {
     if (status == CompileJobStatus.Running)
     {
         process.Close();
         process.Dispose();
         process = null;
     }
     status = CompileJobStatus.Disposed;
 }
    public static bool TryGetJobResult(int jobId, out CompileJobStatus result, out string outputFilePath)
    {
        CompileJob job = compileJobs.Find((j) => {
            return(j.jobId == jobId);
        });

        if (job == null)
        {
            result         = CompileJobStatus.Invalid;
            outputFilePath = null;
            return(false);
        }
        result         = job.status;
        outputFilePath = job.path + ".dll";
        return(true);
    }
        public void Start(string code, string[] assemblies, bool sync)
        {
            if (status != CompileJobStatus.NotStarted)
            {
                Debug.LogError("Compile job already running, Start can only be called once");
                return;
            }

            status = CompileJobStatus.Running;

            try {
                File.WriteAllText(@"./" + path + ".cs", code);
                process = new Process();
#if UNITY_EDITOR_OSX
                process.StartInfo.FileName = @"/usr/local/bin/mcs";
#elif UNITY_EDITOR_WIN
                process.StartInfo.FileName = @"C:\PROGRA~2\Unity\Editor\Data\Mono\bin\gmcs.bat";
                //need to escape due to spaces in windows paths
                for (int i = 0; i < assemblies.Length; i++)
                {
                    assemblies[i] = "\"" + assemblies[i] + "\"";
                }
#endif
                process.StartInfo.Arguments = BuildArguments(assemblies);
                process.StartInfo.RedirectStandardOutput = true;
                process.StartInfo.RedirectStandardError  = true;
                process.StartInfo.UseShellExecute        = false;
                process.StartInfo.CreateNoWindow         = true;
                started = process.Start();
                if (sync)
                {
                    process.WaitForExit();
                    Update();
                }
            }
            catch (Exception e) {
                status = CompileJobStatus.Failed;
                Debug.LogError(e);
                process = null;;
            }
        }
        public CompileJobStatus Update() {
            if (process != null && started && process.HasExited) {
                string output = process.StandardOutput.ReadToEnd();
                string errors = process.StandardError.ReadToEnd();

                if (!string.IsNullOrEmpty(output)) {
                    Debug.Log(output);
                }
                if (!string.IsNullOrEmpty(errors)) {
                    Debug.Log(errors);
                }
                if (process.ExitCode == 0) {
                    status = CompileJobStatus.Succeeded;
                }
                else {
                    status = CompileJobStatus.Failed;
                }
                process.Close();
                process.Dispose();
                process = null;
            }
            return status;
        }
        public void Start(string code, string[] assemblies, bool sync) {
            if (status != CompileJobStatus.NotStarted) {
                Debug.LogError("Compile job already running, Start can only be called once");
                return;
            }

            status = CompileJobStatus.Running;

            try {
                File.WriteAllText(@"./" + path + ".cs", code);
                process = new Process();
#if UNITY_EDITOR_OSX
                process.StartInfo.FileName = @"/usr/local/bin/mcs";
#elif UNITY_EDITOR_WIN
                process.StartInfo.FileName = @"C:\PROGRA~2\Unity\Editor\Data\Mono\bin\gmcs.bat";
                //need to escape due to spaces in windows paths
                for (int i = 0; i < assemblies.Length; i++) {
                    assemblies[i] = "\"" + assemblies[i] + "\"";
                }
#endif
                process.StartInfo.Arguments = BuildArguments(assemblies);
                process.StartInfo.RedirectStandardOutput = true;
                process.StartInfo.RedirectStandardError = true;
                process.StartInfo.UseShellExecute = false;
                process.StartInfo.CreateNoWindow = true;
                started = process.Start();
                if (sync) {
                    process.WaitForExit();
                    Update();
                }
            }
            catch (Exception e) {
                status = CompileJobStatus.Failed;
                Debug.LogError(e);
                process = null; ;
            }
        }
 public void CleanUp() {
     if (status == CompileJobStatus.Running) {
         process.Close();
         process.Dispose();
         process = null;
     }
     status = CompileJobStatus.Disposed;
 }
 public CompileJob(int jobId) {
     this.jobId = jobId;
     path = @"./" + FileUtil.GetUniqueTempPathInProject();
     status = CompileJobStatus.NotStarted;
 }
 public static bool TryGetJobResult(int jobId, out CompileJobStatus result, out string outputFilePath) {
     CompileJob job = compileJobs.Find((j) => {
         return j.jobId == jobId;
     });
     if (job == null) {
         result = CompileJobStatus.Invalid;
         outputFilePath = null;
         return false;
     }
     result = job.status;
     outputFilePath = job.path + ".dll";
     return true;
 }
 public CompileJob(int jobId)
 {
     this.jobId = jobId;
     path       = @"./" + FileUtil.GetUniqueTempPathInProject();
     status     = CompileJobStatus.NotStarted;
 }