X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbuilder.cpp;h=58288ffbfa096a71e4dfbe82fe360c207824f7b7;hb=refs%2Ftags%2F0.9;hp=257c931732b556cde8e5b17078dcb91d57f13cd7;hpb=8d636197d4adf5e882e51ffd2ff86d959dd82d6b;p=builder.git diff --git a/source/builder.cpp b/source/builder.cpp index 257c931..58288ff 100644 --- a/source/builder.cpp +++ b/source/builder.cpp @@ -143,7 +143,7 @@ Builder::Builder(int argc, char **argv): prefix=(FS::get_home_dir()/"local"/current_arch).str(); } else - prefix=prfx; + prefix=FS::getcwd()/prfx; warnings.push_back("all"); warnings.push_back("extra"); @@ -155,6 +155,9 @@ Builder::Builder(int argc, char **argv): vector warns=split(*i, ','); warnings.insert(warnings.end(), warns.begin(), warns.end()); } + + pkg_path.push_back(cwd/"."); + pkg_path.push_back(cwd/".."); } /** @@ -172,38 +175,14 @@ Package *Builder::get_package(const string &name) if(i!=packages.end()) return i->second; - // Try to get source directory with pkgconfig - list argv; - argv.push_back("pkg-config"); - argv.push_back("--variable=source"); - argv.push_back(name); - if(verbose>=4) - cout<<"Running "<second; } - // Go through the candidate directories and look for a Build file - for(PathList::iterator j=dirs.begin(); j!=dirs.end(); ++j) - if(!load_build_file(*j/"Build")) - { - i=packages.find(name); - if(i!=packages.end()) - return i->second; - break; - } - // Package source not found - create a binary package Package *pkg=BinaryPackage::from_pkgconfig(*this, name); @@ -400,7 +379,8 @@ int Builder::main() if(conf_only) return 0; - cout<=1) + cout<=2) { for(PackageList::const_iterator i=all_reqs.begin(); i!=all_reqs.end(); ++i) @@ -495,6 +475,52 @@ void Builder::usage(const char *reason, const char *argv0, bool brief) } } +/** +Determines the source directory of a package. pkg-config is consulted first, +and if it fails, the package path is searched for matches. +*/ +FS::Path Builder::get_package_location(const string &name) +{ + // Try to get source directory with pkgconfig + list argv; + argv.push_back("pkg-config"); + argv.push_back("--variable=source"); + argv.push_back(name); + if(verbose>=4) + cout<<"Running "<::const_iterator i=pkg_path.begin(); i!=pkg_path.end(); ++i) + { + list files=list_files(*i); + for(list::const_iterator j=files.begin(); j!=files.end(); ++j) + { + FS::Path full=*i / *j; + if(FS::exists(full/"Build")) + pkg_dirs.push_back(full); + } + } + } + + bool msp=!name.compare(0, 3, "msp"); + for(list::const_iterator i=pkg_dirs.begin(); i!=pkg_dirs.end(); ++i) + { + string base=basename(*i); + unsigned dash=base.rfind('-'); + + if(!base.compare(0, dash, name)) + return *i; + else if(msp && !base.compare(0, dash-3, name, 3, string::npos)) + return *i; + } + + return FS::Path(); +} + /** Loads the given build file. @@ -711,7 +737,8 @@ int Builder::do_build() cout<<"Already up to date\n"; return 0; } - cout<<"Will build "<=1) + cout<<"Will build "< actions;