X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fpkgconfiggenerator.cpp;h=bd807d4581ba3e173367f8b040c63d30b4cc608b;hb=a0868300fc26496b5a7551d1b732925c11350fdd;hp=f29ae4a73b9c6373a70741a7180fcb47f15b7b39;hpb=ca18323d45d67243773b03668e79c715aa976441;p=builder.git diff --git a/source/pkgconfiggenerator.cpp b/source/pkgconfiggenerator.cpp index f29ae4a..bd807d4 100644 --- a/source/pkgconfiggenerator.cpp +++ b/source/pkgconfiggenerator.cpp @@ -33,27 +33,27 @@ PkgConfigGenerator::Worker::Worker(const PkgConfigFile &t): void PkgConfigGenerator::Worker::main() { Builder &builder = target.get_package()->get_builder(); - const SourcePackage &spkg = dynamic_cast(*target.get_package()); + const SourcePackage &spkg = *target.get_package(); IO::BufferedFile out(target.get_path().str(), IO::M_WRITE); IO::print(out, "prefix=%s\n", builder.get_prefix().str()); - IO::print(out, "source=%s\n\n", spkg.get_source()); + IO::print(out, "source=%s\n\n", spkg.get_source_directory()); IO::print(out, "Name: %s\n", spkg.get_name()); IO::print(out, "Description: %s\n", spkg.get_description()); IO::print(out, "Version: %s\n", spkg.get_version()); IO::print(out, "Requires:"); - const PackageList &reqs = spkg.get_requires(); + const PackageList &reqs = spkg.get_required_packages(); for(PackageList::const_iterator i=reqs.begin(); i!=reqs.end(); ++i) if((*i)->get_use_pkgconfig()) IO::print(out, " %s", (*i)->get_name()); out.put('\n'); - const BuildInfo &binfo = spkg.get_exported_binfo(); + 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(); +}