]> git.tdb.fi Git - builder.git/blob - source/pkgconfigaction.cpp
c390fbd0e0a47dd45ee1e72995513411914e4866
[builder.git] / source / pkgconfigaction.cpp
1 /* $Id$
2
3 This file is part of builder
4 Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #include <fstream>
9 #include <iostream>
10 #include <msp/path/utils.h>
11 #include "package.h"
12 #include "pkgconfig.h"
13 #include "pkgconfigaction.h"
14
15 using namespace std;
16
17 PkgConfigAction::PkgConfigAction(Builder &b, const PkgConfig &p):
18         Action(b)
19 {
20         const SourcePackage &spkg=*static_cast<const SourcePackage *>(p.get_package());
21
22         announce(spkg.get_name(), "PC", relative(p.get_name(), spkg.get_source()).str());
23
24         ofstream out(p.get_name().c_str());
25         if(out)
26         {
27                 // Prefix is already included in the various paths
28                 //out<<"prefix="<<pkg.get_prefix()<<"\n\n";
29                 out<<"source="<<spkg.get_source()<<"\n\n";
30
31                 out<<"Name: "<<spkg.get_name()<<'\n';
32                 out<<"Description: "<<spkg.get_description()<<'\n';
33                 out<<"Version: "<<spkg.get_version()<<'\n';
34
35                 out<<"Requires:";
36                 const PkgRefList &reqs=spkg.get_requires();
37                 for(PkgRefList::const_iterator i=reqs.begin(); i!=reqs.end(); ++i)
38                         if(i->get_package()->get_use_pkgconfig())
39                                 out<<' '<<i->get_name();
40                 out<<'\n';
41
42                 const BuildInfo &binfo=spkg.get_exported_binfo();
43                 out<<"Libs:";
44                 for(StringList::const_iterator i=binfo.libpath.begin(); i!=binfo.libpath.end(); ++i)
45                         out<<" -L"<<*i;
46                 for(StringList::const_iterator i=binfo.libs.begin(); i!=binfo.libs.end(); ++i)
47                         out<<" -l"<<*i;
48                 for(StringList::const_iterator i=binfo.ldflags.begin(); i!=binfo.ldflags.end(); ++i)
49                         out<<' '<<*i;
50                 out<<'\n';
51
52                 out<<"Cflags:";
53                 for(StringList::const_iterator i=binfo.incpath.begin(); i!=binfo.incpath.end(); ++i)
54                         out<<" -I"<<*i;
55                 for(StringList::const_iterator i=binfo.defines.begin(); i!=binfo.defines.end(); ++i)
56                         out<<" -D"<<*i;
57                 for(StringList::const_iterator i=binfo.cflags.begin(); i!=binfo.cflags.end(); ++i)
58                         out<<' '<<*i;
59                 out<<'\n';
60         }
61         else
62                 cerr<<"Can't open "<<p.get_name()<<" for writing\n";
63 }
64
65 int PkgConfigAction::check()
66 {
67         signal_done.emit();
68         return 0;
69 }