]> git.tdb.fi Git - builder.git/commitdiff
Fix path prefixification in .pc files
authorMikko Rasa <tdb@tdb.fi>
Mon, 23 Jul 2012 18:31:35 +0000 (21:31 +0300)
committerMikko Rasa <tdb@tdb.fi>
Mon, 23 Jul 2012 18:31:35 +0000 (21:31 +0300)
source/pkgconfiggenerator.cpp
source/pkgconfiggenerator.h

index 811fa5d2ef68e9e6bfdb9ef3d04a6c88ac2f4950..bd807d4581ba3e173367f8b040c63d30b4cc608b 100644 (file)
@@ -53,7 +53,7 @@ void PkgConfigGenerator::Worker::main()
        const BuildInfo &binfo = spkg.get_exported_build_info();
        IO::print(out, "Libs:");
        for(BuildInfo::PathList::const_iterator i=binfo.libpath.begin(); i!=binfo.libpath.end(); ++i)
-               IO::print(out, " -L%s", FS::relative(*i, builder.get_prefix()).str());
+               IO::print(out, " -L%s", prefixify(*i, builder.get_prefix()));
        for(BuildInfo::WordList::const_iterator i=binfo.libs.begin(); i!=binfo.libs.end(); ++i)
                IO::print(out, " -l%s", *i);
        if(binfo.threads)
@@ -62,7 +62,7 @@ void PkgConfigGenerator::Worker::main()
 
        IO::print(out, "Cflags:");
        for(BuildInfo::PathList::const_iterator i=binfo.incpath.begin(); i!=binfo.incpath.end(); ++i)
-               IO::print(out, " -I%s", FS::relative(*i, builder.get_prefix()).str());
+               IO::print(out, " -I%s", prefixify(*i, builder.get_prefix()));
        for(BuildInfo::DefineMap::const_iterator i=binfo.defines.begin(); i!=binfo.defines.end(); ++i)
                if(i->second.empty())
                        IO::print(out, " -D%s", i->first);
@@ -72,3 +72,14 @@ void PkgConfigGenerator::Worker::main()
 
        status = Task::SUCCESS;
 }
+
+string PkgConfigGenerator::Worker::prefixify(const FS::Path &path, const FS::Path &prefix)
+{
+       if(FS::descendant_depth(path, prefix)>=0)
+       {
+               FS::Path rel_path = FS::relative(path, prefix);
+               return "${prefix}"+rel_path.str().substr(1);
+       }
+       else
+               return path.str();
+}
index 602a2aac0f3b11fd6eec1ffde7a43683ae79252d..14ba317df9c6a31e12f120c911c81ed53c3b9c36 100644 (file)
@@ -19,6 +19,8 @@ private:
 
        private:
                virtual void main();
+
+               std::string prefixify(const Msp::FS::Path &, const Msp::FS::Path &);
        };
 
 public: