private bool CompileDependencies(string srcText, bool compileAll) { List <String> deps = _buildToolManager.GetDependencies(srcText); foreach (string dep in deps) { /* * Check the filename is valid and actually exists. */ FileInfo depInfo = null; try { depInfo = new FileInfo(dep); } catch { _output.AddLineToOutputView(String.Format( "------ {0}: {1}: {2}", Resources.BuildErrors, Resources.ErrorFilenameInvalid, dep)); _output.AdjustOutputWidth(); _mainForm.SetStatusBarMessage(Resources.BuildErrors); return(false); } if (!File.Exists(depInfo.FullName)) { _output.AddLineToOutputView(String.Format( "------ {0}: {1}: {2}", Resources.BuildErrors, Resources.ErrorFileNotFound, depInfo.FullName)); _output.AdjustOutputWidth(); _mainForm.SetStatusBarMessage(Resources.BuildErrors); return(false); } /* * Compile the file. */ BuildCommand compileCommand = GetBuildCommand(depInfo, Constants.ACTION_COMPILE); if (compileCommand == null) { _output.AddLineToOutputView(String.Format( "------ {0}: {1} {2}", Resources.BuildErrors, Resources.ErrorBuildToolNotFound, depInfo.Name)); _output.AdjustOutputWidth(); _mainForm.SetStatusBarMessage(Resources.BuildErrors); return(false); } if (compileCommand.TargetBuildRequired() || compileAll) { if (!CompileFile(compileCommand)) { return(false); } } } return(true); }
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); }
private bool RunFile(BuildCommand runCommand) { if (_output == null) { return(false); } if (runCommand == null) { _output.AddLineToOutputView(String.Format( "------ {0}: {1}", Resources.BuildErrors, Resources.ErrorBuildToolInvalid)); _output.AdjustOutputWidth(); _mainForm.SetStatusBarMessage(Resources.BuildErrors); return(false); } if (Directory.GetCurrentDirectory() != runCommand.SourceInfo.DirectoryName) { Directory.SetCurrentDirectory( runCommand.SourceInfo.DirectoryName); _applicationManager.NotifyFileSystemChange(); } if (runCommand.Cancel) { _output.AddLineToOutputView( String.Format( Resources.ProgramTarget, runCommand.TargetInfo.FullName)); _output.AddLineToOutputView( String.Format( Resources.ProgramNotExecutable, runCommand.TargetInfo.Extension)); _output.AdjustOutputWidth(); _mainForm.SetStatusBarMessage(Resources.BuildHalted); return(runCommand.CancelResult); } RunProcessContext context = new RunProcessContext(); context.ExePath = runCommand.Path; context.ProcessArgs = runCommand.Args; context.HeaderText = runCommand.StartText; context.FooterText = runCommand.FinishText; context.LineParser = runCommand.BuildTool.LineParser; context.ExitCode = 0; Dictionary <String, List <String> > actionCommands = _buildToolManager.GetActionCommands(runCommand.SourceText); _output.Text = String.Format("{0} {1}", Resources.OutputWindowRun, runCommand.BuildTool.DisplayName); bool useWindow = (actionCommands[Constants.ACTION_CMD_RUN_IN_OWN_WINDOW].Count > 0); bool res = RunShellCommands( String.Format("{0} ", Resources.PreRunTask), actionCommands[Constants.ACTION_CMD_DO_PRE_RUN]); _applicationManager.NotifyFileSystemChange(); if (res) { if (useWindow) { res = _output.RunProcessExternal(context); } else { res = _output.RunProcessInternal(context); } } if (res) { res = RunShellCommands( String.Format("{0} ", Resources.PostRunTask), actionCommands[Constants.ACTION_CMD_DO_POST_RUN]); } _applicationManager.NotifyFileSystemChange(); _mainForm.SetStatusBarMessage( String.Format(Resources.ProgramReturn, context.ExitCode)); return(res); }