From: Mikko Rasa Date: Fri, 28 Sep 2012 12:20:02 +0000 (+0300) Subject: Prevent crashes if a tool's executable cannot be found X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=486adc75285b8b5d62a990dd9f9cd4737c8ab7f6;p=builder.git Prevent crashes if a tool's executable cannot be found --- diff --git a/source/filetarget.cpp b/source/filetarget.cpp index af63c23..b42580a 100644 --- a/source/filetarget.cpp +++ b/source/filetarget.cpp @@ -102,11 +102,14 @@ void FileTarget::check_rebuild() if(package->get_config().get_mtime()>mtime) mark_rebuild("Package options changed"); - string build_sig = create_build_signature(); - if(package->get_cache().has_key(this, "build_sig")) + if(tool->get_executable()) { - if(package->get_cache().get_value(this, "build_sig")!=build_sig) - mark_rebuild("Build signature changed"); + string build_sig = create_build_signature(); + if(package->get_cache().has_key(this, "build_sig")) + { + if(package->get_cache().get_value(this, "build_sig")!=build_sig) + mark_rebuild("Build signature changed"); + } } } } diff --git a/source/gnucompiler.cpp b/source/gnucompiler.cpp index 43e8e30..a3052df 100644 --- a/source/gnucompiler.cpp +++ b/source/gnucompiler.cpp @@ -20,6 +20,8 @@ GnuCompiler::GnuCompiler(Builder &b, const Architecture &a, const string &t, con if(architecture->is_cross()) command = format("%s-%s", architecture->get_cross_prefix(), command); executable = builder.get_vfs().find_binary(command); + if(!executable) + builder.problem(string(), format("Can't find executable %s for tool %s", command, tag)); if(architecture->is_native()) system_path.push_back("/usr/include"); diff --git a/source/gnucxxcompiler.cpp b/source/gnucxxcompiler.cpp index 05782e4..9e206cc 100644 --- a/source/gnucxxcompiler.cpp +++ b/source/gnucxxcompiler.cpp @@ -17,6 +17,12 @@ GnuCxxCompiler::GnuCxxCompiler(Builder &b, const Architecture &a): input_suffixes.push_back(".cc"); aux_suffixes.push_back(".hpp"); + if(executable) + query_version(); +} + +void GnuCxxCompiler::query_version() +{ ExternalTask::Arguments argv; argv.push_back(executable->get_path().str()); argv.push_back("-dumpversion"); diff --git a/source/gnucxxcompiler.h b/source/gnucxxcompiler.h index a764e89..314bb51 100644 --- a/source/gnucxxcompiler.h +++ b/source/gnucxxcompiler.h @@ -10,7 +10,10 @@ class GnuCxxCompiler: public GnuCompiler { public: GnuCxxCompiler(Builder &, const Architecture &); +private: + void query_version(); +public: virtual Target *create_source(const Component &, const Msp::FS::Path &) const; virtual Target *create_source(const Msp::FS::Path &) const; };