]> git.tdb.fi Git - builder.git/blob - source/archive.cpp
Better encapsulation of config inside Package
[builder.git] / source / archive.cpp
1 #include <msp/path/utils.h>
2 #include "archive.h"
3 #include "builder.h"
4 #include "component.h"
5 #include "objectfile.h"
6 #include "package.h"
7 #include "staticlibrary.h"
8
9 using namespace std;
10 using namespace Msp;
11
12 Archive::Archive(Builder &b, const StaticLibrary &lib):
13         ExternalAction(b)
14 {
15         const Component &comp=lib.get_component();
16
17         const string &prefix=b.get_arch_prefix(lib.get_package()->get_arch());
18
19         argv.push_back(prefix+"ar");
20         argv.push_back("rc");
21
22         argv.push_back(lib.get_name());
23         const TargetList &deps=lib.get_depends();
24         for(TargetList::const_iterator i=deps.begin(); i!=deps.end(); ++i)
25                 if(dynamic_cast<ObjectFile *>(*i))
26                         argv.push_back((*i)->get_name());
27
28         Path::Path lpath=lib.get_name();
29         if(!builder.get_dry_run())
30                 Path::mkpath(lpath.subpath(0, lpath.size()-1), 0755);
31
32         announce(comp.get_package().get_name(), "AR  ", relative(lpath, comp.get_package().get_source()).str());
33
34         launch();
35 }