From 64d69068586a764b8a8ee35b0efd98cd5a5bbf32 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 23 Jul 2012 21:31:35 +0300 Subject: [PATCH] Fix path prefixification in .pc files --- source/pkgconfiggenerator.cpp | 15 +++++++++++++-- source/pkgconfiggenerator.h | 2 ++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/source/pkgconfiggenerator.cpp b/source/pkgconfiggenerator.cpp index 811fa5d..bd807d4 100644 --- a/source/pkgconfiggenerator.cpp +++ b/source/pkgconfiggenerator.cpp @@ -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(); +} diff --git a/source/pkgconfiggenerator.h b/source/pkgconfiggenerator.h index 602a2aa..14ba317 100644 --- a/source/pkgconfiggenerator.h +++ b/source/pkgconfiggenerator.h @@ -19,6 +19,8 @@ private: private: virtual void main(); + + std::string prefixify(const Msp::FS::Path &, const Msp::FS::Path &); }; public: -- 2.45.2