X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbuilder.cpp;h=8bef2c6e5d7a67d5126d86fbfa53b1295f5eb482;hb=54aab19ee471810a956e1fee4d3b962aaf9ae9b3;hp=2ef5a709e1913d33cae79f1677ce1b21290d1cee;hpb=0ac8d6708b8c758fb89d97a0049d4a329990b83b;p=builder.git diff --git a/source/builder.cpp b/source/builder.cpp index 2ef5a70..8bef2c6 100644 --- a/source/builder.cpp +++ b/source/builder.cpp @@ -5,14 +5,17 @@ Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions Distributed under the LGPL */ -#include #include #include -#include +#include #include #include +#include +#include +#include #include #include +#include #include #include #include @@ -113,7 +116,7 @@ Builder::Builder(int argc, char **argv): if(!work_dir.empty()) chdir(work_dir.c_str()); - cwd=Path::getcwd(); + cwd=getcwd(); Architecture &native_arch=archs.insert(ArchMap::value_type("native", Architecture(*this, "native"))).first->second; native_arch.set_tool("CC", "gcc"); @@ -124,7 +127,7 @@ Builder::Builder(int argc, char **argv): const char *home=getenv("HOME"); if(home) - load_build_file((Path::Path(home)/".builderrc").str()); + load_build_file((Path(home)/".builderrc").str()); } /** @@ -145,6 +148,8 @@ Package *Builder::get_package(const string &n) argv.push_back("pkg-config"); argv.push_back("--variable=source"); argv.push_back(n); + if(verbose>=4) + cout<<"Running "< &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); @@ -208,21 +213,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::Path(from)/fn))) - ; - else if((tgt=get_header(Path::Path("/usr/include")/fn))) - ; - //XXX Determine the C++ header location dynamically - else if((tgt=get_header(Path::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]\\.[0-9.]+").match(run_command(argv))[0].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=path.begin(); (!tgt && j!=path.end()); ++j) + tgt=get_header(cwd/ *j/fn); + for(list::const_iterator j=syspath.begin(); (!tgt && j!=syspath.end()); ++j) + tgt=get_header(Path(*j)/fn); + includes.insert(TargetMap::value_type(id, tgt)); return tgt; @@ -260,11 +287,14 @@ 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; @@ -383,6 +404,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) @@ -442,18 +472,24 @@ Loads the given build file. @return 0 on success, -1 if the file could not be opened */ -int Builder::load_build_file(const Path::Path &fn) +int Builder::load_build_file(const Path &fn) { - ifstream in(fn.str().c_str()); - if(!in) - return -1; + try + { + IO::File inf(fn.str()); + IO::Buffered in(inf); - if(verbose>=3) - cout<<"Reading "<=3) + cout<<"Reading "< Builder::reg; -Builder::Loader::Loader(Builder &b, const Path::Path &s): +Builder::Loader::Loader(Builder &b, const Path &s): bld(b), src(s) {