]> git.tdb.fi Git - builder.git/blob - source/archive.cpp
Move architecture information from Builder to class Architecture
[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         std::string tool="AR";
25         argv.push_back(builder.get_architecture(comp.get_package().get_arch()).get_tool(tool));
26         argv.push_back("rc");
27
28         argv.push_back(lib.get_name());
29         const TargetList &deps=lib.get_depends();
30         for(TargetList::const_iterator i=deps.begin(); i!=deps.end(); ++i)
31                 if(dynamic_cast<ObjectFile *>(*i))
32                         argv.push_back((*i)->get_name());
33
34         Path::Path lpath=lib.get_name();
35         if(!builder.get_dry_run())
36                 Path::mkpath(lpath.subpath(0, lpath.size()-1), 0755);
37
38         announce(comp.get_package().get_name(), tool, relative(lpath, comp.get_package().get_source()).str());
39
40         launch();
41 }