]> git.tdb.fi Git - builder.git/blobdiff - source/pkgconfiggenerator.cpp
Refactor transitive dependencies to work on all targets
[builder.git] / source / pkgconfiggenerator.cpp
diff --git a/source/pkgconfiggenerator.cpp b/source/pkgconfiggenerator.cpp
deleted file mode 100644 (file)
index 677ef9b..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-#include <msp/fs/utils.h>
-#include <msp/io/file.h>
-#include <msp/io/print.h>
-#include "builder.h"
-#include "pkgconfigfile.h"
-#include "pkgconfiggenerator.h"
-
-using namespace std;
-using namespace Msp;
-
-PkgConfigGenerator::PkgConfigGenerator(Builder &b):
-       Tool(b, "PCG")
-{
-}
-
-Target *PkgConfigGenerator::create_target(const list<Target *> &, const string &)
-{
-       throw logic_error("Not implemented");
-}
-
-Task *PkgConfigGenerator::run(const Target &target) const
-{
-       const PkgConfigFile &pkgc = dynamic_cast<const PkgConfigFile &>(target);
-       Worker *worker = new Worker(pkgc);
-       return new InternalTask(worker);
-}
-
-
-PkgConfigGenerator::Worker::Worker(const PkgConfigFile &t):
-       target(t)
-{ }
-
-void PkgConfigGenerator::Worker::main()
-{
-       Builder &builder = target.get_package()->get_builder();
-       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_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 Package::Requirements &reqs = spkg.get_required_packages();
-       for(Package::Requirements::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_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", 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)
-               out.write("-pthread");
-       out.put('\n');
-
-       IO::print(out, "Cflags:");
-       for(BuildInfo::PathList::const_iterator i=binfo.incpath.begin(); i!=binfo.incpath.end(); ++i)
-               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);
-               else
-                       IO::print(out, " -D%s=%s", i->first, i->second);
-       out.put('\n');
-
-       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();
-}