1 #include <msp/fs/dir.h>
2 #include <msp/fs/stat.h>
3 #include <msp/fs/utils.h>
7 #include "objectfile.h"
8 #include "sourcepackage.h"
9 #include "staticlibrary.h"
14 Archive::Archive(Builder &b, const StaticLibrary &lib):
17 const Component &comp = lib.get_component();
19 work_dir = comp.get_package().get_source();
21 std::string tool = "AR";
22 argv.push_back(builder.get_current_arch().get_tool(tool));
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());
31 FS::Path lpath = lib.get_path();
32 if(!builder.get_dry_run())
34 FS::mkpath(FS::dirname(lpath), 0755);
35 if(FS::exists(lib.get_path()))
36 FS::unlink(lib.get_path());
39 announce(comp.get_package().get_name(), tool, relative(lpath, work_dir).str().substr(2));