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