/// <summary> /// Run a file. Source files and their dependencies /// will be recompiled conditionally if out of date or unconditionally. /// </summary> /// <param name="srcInfo">The source file info.</param> /// <param name="srcText">The source file text.</param> /// <param name="compileAll">Compile dependencies unconditionally if true.</param> /// <returns>True if the action completed successfully.</returns> public bool Run(FileInfo srcInfo, string srcText, bool compileAll) { if (_output == null) { return(false); } _output.ClearOutputViews(); _mainForm.SetStatusBarMessage(Resources.BuildStarted); _mainForm.StatusBar.Refresh(); if (srcInfo == null || String.IsNullOrEmpty(srcText)) { _output.AddLineToOutputView(String.Format( "------ {0}: {1}", Resources.BuildErrors, Resources.ErrorSourceInvalid)); _output.AdjustOutputWidth(); _mainForm.SetStatusBarMessage(Resources.BuildErrors); return(false); } if (!CompileDependencies(srcText, compileAll)) { return(false); } BuildCommand runCommand = GetBuildCommand(srcInfo, Constants.ACTION_RUN); if (runCommand.TargetBuildRequired()) { BuildCommand compileCommand = GetBuildCommand(srcInfo, Constants.ACTION_COMPILE); if (!CompileFile(compileCommand)) { return(false); } } return(RunFile(runCommand)); }
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); }