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