]> git.tdb.fi Git - builder.git/blob - source/archive.cpp
Use package directory as work dir for ExternalActions and make filename arguments...
[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         work_dir=comp.get_package().get_source();
25
26         std::string tool="AR";
27         argv.push_back(builder.get_current_arch().get_tool(tool));
28         argv.push_back("rc");
29
30         argv.push_back(relative(lib.get_name(), work_dir).str());
31         const TargetList &deps=lib.get_depends();
32         for(TargetList::const_iterator i=deps.begin(); i!=deps.end(); ++i)
33                 if(dynamic_cast<ObjectFile *>(*i))
34                         argv.push_back(relative((*i)->get_name(), work_dir).str());
35
36         Path lpath=lib.get_name();
37         if(!builder.get_dry_run())
38                 mkpath(lpath.subpath(0, lpath.size()-1), 0755);
39
40         announce(comp.get_package().get_name(), tool, relative(lpath, work_dir).str());
41
42         launch();
43 }