3 This file is part of builder
4 Copyright © 2006-2010 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
9 #include <msp/fs/utils.h>
12 #include "component.h"
14 #include "objectfile.h"
15 #include "sourcefile.h"
16 #include "sourcepackage.h"
21 ObjectFile::ObjectFile(Builder &b, const Component &c, SourceFile &s):
22 FileTarget(b, &c.get_package(), generate_target_path(c, FS::basename(s.get_path()))),
30 void ObjectFile::find_depends()
32 for(TargetList::iterator i=new_deps.begin(); i!=new_deps.end();)
35 if(tgt->get_depends_ready())
37 i = new_deps.erase(i);
44 deps_ready = new_deps.empty();
48 void ObjectFile::find_depends(Target *tgt)
50 SourceFile *src = dynamic_cast<SourceFile *>(tgt->get_real_target());
51 FileTarget *file = dynamic_cast<FileTarget *>(tgt);
55 FS::Path spath = FS::dirname(file->get_path());
56 const StringList &incpath = comp.get_build_info().incpath;
58 const list<string> &includes = src->get_includes();
59 for(list<string>::const_iterator i=includes.begin(); i!=includes.end(); ++i)
61 Target *hdr = builder.get_header(*i, spath, incpath);
62 if(hdr && find(depends.begin(), depends.end(), hdr)==depends.end())
67 void ObjectFile::add_depend(Target *tgt)
69 Target::add_depend(tgt);
70 new_deps.push_back(tgt);
73 Action *ObjectFile::create_action()
75 return new Compile(builder, *this);
78 FS::Path ObjectFile::generate_target_path(const Component &comp, const string &src)
80 const SourcePackage &pkg = comp.get_package();
81 return pkg.get_temp_dir()/comp.get_name()/(FS::basepart(src)+".o");