示例#1
0
        private bool CompileFile(BuildCommand compileCommand)
        {
            if (_output == null)
            {
                return(false);
            }

            if (compileCommand == null)
            {
                _output.AddLineToOutputView(String.Format(
                                                "------ {0}: {1}",
                                                Resources.BuildErrors,
                                                Resources.ErrorBuildToolInvalid));

                _output.AdjustOutputWidth();
                _mainForm.SetStatusBarMessage(Resources.BuildErrors);
                return(false);
            }

            if (Directory.GetCurrentDirectory() !=
                compileCommand.SourceInfo.DirectoryName)
            {
                Directory.SetCurrentDirectory(
                    compileCommand.SourceInfo.DirectoryName);

                _applicationManager.NotifyFileSystemChange();
            }

            RunProcessContext context = new RunProcessContext();

            context.ExePath     = compileCommand.Path;
            context.ProcessArgs = compileCommand.Args;
            context.HeaderText  = compileCommand.StartText;
            context.FooterText  = compileCommand.FinishText;
            context.LineParser  = compileCommand.BuildTool.LineParser;
            context.ExitCode    = 0;

            Dictionary <String, List <String> > actionCommands =
                _buildToolManager.GetActionCommands(compileCommand.SourceText);

            _output.Text = String.Format("{0} {1}",
                                         Resources.OutputWindowCompile,
                                         compileCommand.BuildTool.DisplayName);

            bool res = RunShellCommands(
                String.Format("{0} ", Resources.PreCompileTask),
                actionCommands[Constants.ACTION_CMD_DO_PRE_COMPILE]);

            _applicationManager.NotifyFileSystemChange();

            if (res)
            {
                res = _output.RunProcessInternal(context);
            }

            if (context.ExitCode != compileCommand.SuccessCode)
            {
                res = false;
            }

            if (res)
            {
                res = RunShellCommands(
                    String.Format("{0} ", Resources.PostCompileTask),
                    actionCommands[Constants.ACTION_CMD_DO_POST_COMPILE]);
            }

            _applicationManager.NotifyFileSystemChange();

            if (res)
            {
                _mainForm.SetStatusBarMessage(Resources.BuildSuccess);
            }
            else
            {
                _mainForm.SetStatusBarMessage(Resources.BuildErrors);
            }

            return(res);
        }