From 76be6f9f3d6ed0b39044938fa7e424284627eac5 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sat, 22 Sep 2007 13:43:48 +0000 Subject: [PATCH] Improve Builder::get_header Move problem reporting later so --analyze can be used even if there are problems Do not crash on missing requires in a condition Make include and library paths in components absolute by using package source path --- source/builder.cpp | 70 +++++++++++++++++++++++++++------------- source/component.cpp | 5 +++ source/sourcepackage.cpp | 3 +- 3 files changed, 55 insertions(+), 23 deletions(-) diff --git a/source/builder.cpp b/source/builder.cpp index 34c65af..d9444ce 100644 --- a/source/builder.cpp +++ b/source/builder.cpp @@ -13,6 +13,7 @@ Distributed under the LGPL #include #include #include +#include #include #include #include @@ -198,7 +199,7 @@ path. Considers known targets as well as existing files. If a matching target is not found but a file exists, a new SystemHeader target will be created and returned. */ -Target *Builder::get_header(const string &include, const string &, const string &from, const list &path) +Target *Builder::get_header(const string &include, const string &arch, const string &from, const list &path) { string hash(8, 0); update_hash(hash, from); @@ -210,21 +211,43 @@ Target *Builder::get_header(const string &include, const string &, const string if(i!=includes.end()) return i->second; - string fn=include.substr(1); - Target *tgt=0; - if(include[0]=='"' && (tgt=get_header(Path(from)/fn))) - ; - else if((tgt=get_header(Path("/usr/include")/fn))) - ; - //XXX Determine the C++ header location dynamically - else if((tgt=get_header(Path("/usr/include/c++/4.1.2")/fn))) - ; - else + static string cxx_ver; + if(cxx_ver.empty()) { - for(list::const_iterator j=path.begin(); (j!=path.end() && !tgt); ++j) - tgt=get_header(cwd/ *j/fn); + StringList argv; + argv.push_back(get_architecture(arch).get_tool("CXX")); + argv.push_back("--version"); + cxx_ver=Regex(" ([0-9.]+) ").match(run_command(argv))[1].str; + while(!cxx_ver.empty() && !exists(Path("/usr/include/c++")/cxx_ver)) + { + unsigned dot=cxx_ver.rfind('.'); + if(dot==string::npos) + break; + cxx_ver.erase(dot); + } + if(verbose>=5) + cout<<"C++ version is "<=5) + cout<<"Looking for include "<::const_iterator j=syspath.begin(); (!tgt && j!=syspath.end()); ++j) + tgt=get_header(Path(*j)/fn); + for(list::const_iterator j=path.begin(); (!tgt && j!=path.end()); ++j) + tgt=get_header(cwd/ *j/fn); + includes.insert(TargetMap::value_type(id, tgt)); return tgt; @@ -262,6 +285,9 @@ Target *Builder::get_library(const string &lib, const string &arch, const list=5) + cout<<"Looking for library "<get_name(), format("wrong architecture (%s)", spkg->get_arch())); } - if(!problems.empty()) - { - cerr<<"The following problems were detected:\n"; - for(ProblemList::iterator i=problems.begin(); i!=problems.end(); ++i) - cerr<<" "<package<<": "<descr<<'\n'; - cerr<<"Please fix them and try again.\n"; - return 1; - } - if(conf_only) return 0; @@ -385,6 +402,15 @@ int Builder::main() if(analyzer) analyzer->analyze(); + if(!problems.empty()) + { + cerr<<"The following problems were detected:\n"; + for(ProblemList::iterator i=problems.begin(); i!=problems.end(); ++i) + cerr<<" "<package<<": "<descr<<'\n'; + cerr<<"Please fix them and try again.\n"; + return 1; + } + //if(create_makefile if(clean) diff --git a/source/component.cpp b/source/component.cpp index f4e8fc2..29f58b4 100644 --- a/source/component.cpp +++ b/source/component.cpp @@ -41,6 +41,11 @@ void Component::create_build_info() for(PackageList::iterator i=requires.begin(); i!=requires.end(); ++i) build_info.add((*i)->get_exported_binfo()); + for(StringList::iterator i=build_info.incpath.begin(); i!=build_info.incpath.end(); ++i) + *i=(pkg.get_source() / *i).str(); + for(StringList::iterator i=build_info.libpath.begin(); i!=build_info.libpath.end(); ++i) + *i=(pkg.get_source() / *i).str(); + if(type==PROGRAM) { string strip=pkg.get_config().get_option("strip").value; diff --git a/source/sourcepackage.cpp b/source/sourcepackage.cpp index cfe4be3..42118a1 100644 --- a/source/sourcepackage.cpp +++ b/source/sourcepackage.cpp @@ -106,7 +106,8 @@ void SourcePackage::do_configure(const StringMap &opts, unsigned flag) { const StringList &reqs=i->get_requires(); for(StringList::const_iterator j=reqs.begin(); j!=reqs.end(); ++j) - requires.push_back(builder.get_package(*j)); + if(Package *pkg=builder.get_package(*j)) + requires.push_back(pkg); } base_reqs=requires; -- 2.45.2