diff options
author | Lluis Sanchez <lluis@novell.com> | 2007-09-27 15:40:43 +0400 |
---|---|---|
committer | Lluis Sanchez <lluis@novell.com> | 2007-09-27 15:40:43 +0400 |
commit | 9978afc92ed530ab5d53e55ad74b895dd858d43a (patch) | |
tree | 6eea560e721024bcd907837783d2680ecf0db3d4 | |
parent | 762b248a2c91e806dac2ec34fa6922d6cbeb0860 (diff) |
2007-09-26 Lluis Sanchez Gual <lluis@novell.com>
* Parser/TagDatabaseManager.cs: Don't crash if the compiler can't be found.
* Compiler/GNUCompiler.cs: Check for the compiler before trying to compile.
svn path=/branches/monodevelop/0.16/; revision=86484
-rw-r--r-- | Extras/CBinding/ChangeLog | 5 | ||||
-rw-r--r-- | Extras/CBinding/Compiler/GNUCompiler.cs | 33 | ||||
-rw-r--r-- | Extras/CBinding/Parser/TagDatabaseManager.cs | 10 |
3 files changed, 46 insertions, 2 deletions
diff --git a/Extras/CBinding/ChangeLog b/Extras/CBinding/ChangeLog index 5c49908ba6..3f0f1a8ca4 100644 --- a/Extras/CBinding/ChangeLog +++ b/Extras/CBinding/ChangeLog @@ -1,3 +1,8 @@ +2007-09-26 Lluis Sanchez Gual <lluis@novell.com> + + * Parser/TagDatabaseManager.cs: Don't crash if the compiler can't be found. + * Compiler/GNUCompiler.cs: Check for the compiler before trying to compile. + 2007-09-21 Lluis Sanchez Gual <lluis@novell.com> * CBinding.addin.xml: Bump MD version. diff --git a/Extras/CBinding/Compiler/GNUCompiler.cs b/Extras/CBinding/Compiler/GNUCompiler.cs index 58a748b999..31681a8c07 100644 --- a/Extras/CBinding/Compiler/GNUCompiler.cs +++ b/Extras/CBinding/Compiler/GNUCompiler.cs @@ -50,12 +50,34 @@ namespace CBinding { public abstract class GNUCompiler : CCompiler { + bool appsChecked; + bool compilerFound; + bool linkerFound; + public override ICompilerResult Compile ( ProjectFileCollection projectFiles, ProjectPackageCollection packages, CProjectConfiguration configuration, IProgressMonitor monitor) { + if (!appsChecked) { + appsChecked = true; + compilerFound = CheckApp (compilerCommand); + linkerFound = CheckApp (linkerCommand); + } + + if (!compilerFound) { + DefaultCompilerResult cres = new DefaultCompilerResult (); + cres.AddError ("Compiler not found: " + compilerCommand); + return cres; + } + + if (!linkerFound) { + DefaultCompilerResult cres = new DefaultCompilerResult (); + cres.AddError ("Linker not found: " + linkerCommand); + return cres; + } + CompilerResults cr = new CompilerResults (new TempFileCollection ()); bool res = true; string args = GetCompilerFlags (configuration); @@ -588,5 +610,16 @@ namespace CBinding return p.StandardOutput.ReadToEnd(); } + + bool CheckApp (string app) + { + try { + ProcessWrapper p = Runtime.ProcessService.StartProcess (linkerCommand, "--version", null, null); + p.WaitForOutput (); + return true; + } catch { + return false; + } + } } } diff --git a/Extras/CBinding/Parser/TagDatabaseManager.cs b/Extras/CBinding/Parser/TagDatabaseManager.cs index 5c6742f5d2..bd3e93d7f5 100644 --- a/Extras/CBinding/Parser/TagDatabaseManager.cs +++ b/Extras/CBinding/Parser/TagDatabaseManager.cs @@ -90,8 +90,14 @@ namespace CBinding.Parser internal string[] Headers (string filename, bool with_system) { string option = (with_system ? "-M" : "-MM"); - ProcessWrapper p = Runtime.ProcessService.StartProcess ("gcc", option + " -MG " + filename, null, null); - p.WaitForExit (); + ProcessWrapper p; + try { + p = Runtime.ProcessService.StartProcess ("gcc", option + " -MG " + filename, null, null); + p.WaitForExit (); + } catch (Exception ex) { + Runtime.LoggingService.Error (ex); + return new string [0]; + } StringBuilder output = new StringBuilder (); string line; |