]> git.tdb.fi Git - builder.git/commitdiff
Check headers as well
authorMikko Rasa <tdb@tdb.fi>
Mon, 23 Jul 2012 19:01:17 +0000 (22:01 +0300)
committerMikko Rasa <tdb@tdb.fi>
Mon, 23 Jul 2012 19:01:17 +0000 (22:01 +0300)
source/binarypackage.cpp
source/binarypackage.h

index 7e2435a4a6fce6b138d3f319f40069ecf4bafb40..f00f0faf10519e7211dfd7df4a38af5bcf76eb29 100644 (file)
@@ -17,12 +17,14 @@ void BinaryPackage::do_prepare()
        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();
+       for(BuildInfo::PathList::const_iterator i=export_binfo.incpath.begin(); (!has_relative_paths && i!=export_binfo.incpath.end()); ++i)
+               has_relative_paths = !i->is_absolute();
 
        list<FS::Path> 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()))
+       if(has_relative_paths || (!use_pkgconfig && export_binfo.libpath.empty() && export_binfo.incpath.empty()))
                bases.push_back(builder.get_prefix());
 
        // Always look in system locations
@@ -51,6 +53,15 @@ void BinaryPackage::do_prepare()
                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);
 
+               BuildInfo::PathList incpath = export_binfo.incpath;
+               if(!system && incpath.empty())
+                       incpath.push_back("include");
+               for(BuildInfo::PathList::iterator j=incpath.begin(); j!=incpath.end(); ++j)
+                       *j = prefix/ *j;
+
+               for(HeaderList::const_iterator j=headers.begin(); j!=headers.end(); ++j)
+                       all_found &= (builder.get_vfs().find_header(*j, incpath, system)!=0);
+
                if(all_found)
                {
                        base_path = prefix;
@@ -72,10 +83,13 @@ void BinaryPackage::do_prepare()
        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)
-               *i = base_path/ *i;
+       if(has_relative_paths)
+       {
+               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)
+                       *i = base_path/ *i;
+       }
 }
 
 BinaryPackage *BinaryPackage::from_flags(Builder &builder, const string &name, const vector<string> &flags)
@@ -112,9 +126,15 @@ BinaryPackage::Loader::Loader(BinaryPackage &p):
        DataFile::DerivedObjectLoader<BinaryPackage, Package>(p)
 {
        add("build_info", &Loader::build_info);
+       add("header",     &Loader::header);
 }
 
 void BinaryPackage::Loader::build_info()
 {
        load_sub(obj.export_binfo);
 }
+
+void BinaryPackage::Loader::header(const string &h)
+{
+       obj.headers.push_back(h);
+}
index 5b47d645c149710b71eaed051a577c4fa5fc4b03..892718484856cfc98a3bf5102a050fd835ab7b74 100644 (file)
@@ -16,10 +16,14 @@ public:
                Loader(BinaryPackage &);
        private:
                void build_info();
+               void header(const std::string &);
        };
 
 private:
+       typedef std::list<std::string> HeaderList;
+
        Msp::FS::Path base_path;
+       HeaderList headers;
 
 public:
        BinaryPackage(Builder &, const std::string &);