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