X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fpkgconfiggenerator.cpp;h=949a4df589747e7da8b64ec0cc39f53544ba8db0;hb=HEAD;hp=46387d35fda45e4ca4f4817edb2e4c3c6c9eacb7;hpb=1ed833343bc83b83c5f61cbfd74423bbba677a04;p=builder.git diff --git a/source/pkgconfiggenerator.cpp b/source/pkgconfiggenerator.cpp deleted file mode 100644 index 46387d3..0000000 --- a/source/pkgconfiggenerator.cpp +++ /dev/null @@ -1,74 +0,0 @@ -#include -#include -#include -#include "builder.h" -#include "internaltask.h" -#include "pkgconfigfile.h" -#include "pkgconfiggenerator.h" - -using namespace std; -using namespace Msp; - -PkgConfigGenerator::PkgConfigGenerator(Builder &b): - Tool(b, "PCG") -{ - set_run_internal(_run); -} - -Target *PkgConfigGenerator::create_target(const vector &, const string &) -{ - throw logic_error("Not implemented"); -} - -bool PkgConfigGenerator::_run(const PkgConfigFile &pkgc) -{ - Builder &builder = pkgc.get_package()->get_builder(); - const SourcePackage &spkg = *pkgc.get_package(); - - IO::BufferedFile out(pkgc.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_directory()); - - IO::print(out, "Name: %s\n", spkg.get_label()); - IO::print(out, "Description: %s\n", spkg.get_description()); - IO::print(out, "Version: %s\n", spkg.get_version()); - - IO::print(out, "Requires:"); - for(const Package *r: spkg.get_required_packages()) - if(r->uses_pkgconfig()) - IO::print(out, " %s", r->get_name()); - out.put('\n'); - - const BuildInfo &binfo = spkg.get_exported_build_info(); - IO::print(out, "Libs:"); - for(const FS::Path &p: binfo.libpath) - IO::print(out, " -L%s", prefixify(p, builder.get_prefix())); - for(const string &l: binfo.libs) - IO::print(out, " -l%s", l); - if(binfo.threads) - out.write("-pthread"); - out.put('\n'); - - IO::print(out, "Cflags:"); - for(const FS::Path &p: binfo.incpath) - IO::print(out, " -I%s", prefixify(p, builder.get_prefix())); - for(const auto &kvp: binfo.defines) - if(kvp.second.empty()) - IO::print(out, " -D%s", kvp.first); - else - IO::print(out, " -D%s=%s", kvp.first, kvp.second); - out.put('\n'); - - return true; -} - -string PkgConfigGenerator::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(); -}