3 This file is part of builder
4 Copyright © 2006-2009 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
8 #include <msp/fs/dir.h>
9 #include <msp/fs/stat.h>
10 #include <msp/fs/utils.h>
13 #include "component.h"
14 #include "objectfile.h"
15 #include "sourcepackage.h"
16 #include "staticlibrary.h"
21 Archive::Archive(Builder &b, const StaticLibrary &lib):
24 const Component &comp = lib.get_component();
26 work_dir = comp.get_package().get_source();
28 std::string tool = "AR";
29 argv.push_back(builder.get_current_arch().get_tool(tool));
32 argv.push_back(relative(lib.get_path(), work_dir).str());
33 const TargetList &deps = lib.get_depends();
34 for(TargetList::const_iterator i=deps.begin(); i!=deps.end(); ++i)
35 if(ObjectFile *obj = dynamic_cast<ObjectFile *>(*i))
36 argv.push_back(relative(obj->get_path(), work_dir).str());
38 FS::Path lpath = lib.get_path();
39 if(!builder.get_dry_run())
41 FS::mkpath(FS::dirname(lpath), 0755);
42 if(FS::exists(lib.get_path()))
43 FS::unlink(lib.get_path());
46 announce(comp.get_package().get_name(), tool, relative(lpath, work_dir).str().substr(2));