From: Mikko Rasa Date: Mon, 23 Jul 2012 18:43:13 +0000 (+0300) Subject: Locate and check the existence of the libraries of binary packages X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=b8407de928d2c5421c35474df1c3185fd494ef68;p=builder.git Locate and check the existence of the libraries of binary packages --- diff --git a/source/binarypackage.cpp b/source/binarypackage.cpp index a167269..7e2435a 100644 --- a/source/binarypackage.cpp +++ b/source/binarypackage.cpp @@ -14,13 +14,68 @@ BinaryPackage::BinaryPackage(Builder &b, const string &n): void BinaryPackage::do_prepare() { - for(BuildInfo::PathList::iterator i=export_binfo.incpath.begin(); i!=export_binfo.incpath.end(); ++i) - if((*i)[0]=="@") - *i = builder.get_prefix()/i->subpath(1); + bool has_relative_paths = false; + for(BuildInfo::PathList::const_iterator i=export_binfo.libpath.begin(); (!has_relative_paths && i!=export_binfo.libpath.end()); ++i) + has_relative_paths = !i->is_absolute(); + + list bases; + + /* If we have any relative paths that need resolving, or we have no paths at + all and are not using pkg-config, look for files in prefix */ + if(has_relative_paths || (!use_pkgconfig && export_binfo.libpath.empty())) + bases.push_back(builder.get_prefix()); + + // Always look in system locations + bases.push_back(FS::Path()); + + bool system = false; + for(list::const_iterator i=bases.begin(); i!=bases.end(); ++i) + { + FS::Path prefix = *i; + system = prefix.empty(); + if(system) + { + prefix = "/usr"; + const Architecture &arch = builder.get_current_arch(); + if(arch.is_cross()) + prefix /= arch.get_cross_prefix(); + } + + BuildInfo::PathList libpath = export_binfo.libpath; + if(!system && libpath.empty()) + libpath.push_back("lib"); + for(BuildInfo::PathList::iterator j=libpath.begin(); j!=libpath.end(); ++j) + *j = prefix/ *j; + + bool all_found = true; + for(BuildInfo::WordList::const_iterator j=export_binfo.libs.begin(); j!=export_binfo.libs.end(); ++j) + all_found &= (builder.get_vfs().find_library(*j, libpath, export_binfo.libmode, system)!=0); + if(all_found) + { + base_path = prefix; + builder.get_logger().log("configure", format("%s found in %s", name, ((system && use_pkgconfig) ? "system" : base_path.str()))); + break; + } + } + + if(base_path.empty()) + { + builder.problem(name, "Cannot locate files"); + return; + } + + /* Add default entries to paths if they're empty and the package was found + in a non-system location */ + if(!system && export_binfo.incpath.empty()) + export_binfo.incpath.push_back(base_path/"include"); + if(!system && export_binfo.libpath.empty()) + export_binfo.libpath.push_back(base_path/"lib"); + + for(BuildInfo::PathList::iterator i=export_binfo.incpath.begin(); i!=export_binfo.incpath.end(); ++i) + *i = base_path/ *i; for(BuildInfo::PathList::iterator i=export_binfo.libpath.begin(); i!=export_binfo.libpath.end(); ++i) - if((*i)[0]=="@") - *i = builder.get_prefix()/i->subpath(1); + *i = base_path/ *i; } BinaryPackage *BinaryPackage::from_flags(Builder &builder, const string &name, const vector &flags) diff --git a/source/binarypackage.h b/source/binarypackage.h index 088c3e1..5b47d64 100644 --- a/source/binarypackage.h +++ b/source/binarypackage.h @@ -18,6 +18,10 @@ public: void build_info(); }; +private: + Msp::FS::Path base_path; + +public: BinaryPackage(Builder &, const std::string &); static BinaryPackage *from_flags(Builder &, const std::string &, const std::vector &);