2 #include <msp/path/utils.h>
7 #include "objectfile.h"
9 #include "sourcefile.h"
14 ObjectFile::ObjectFile(Builder &b, const Component &c, SourceFile &src):
15 Target(b, &c.get_package(), generate_target_name(c, src.get_name())),
22 void ObjectFile::find_depends()
24 for(list<Target *>::iterator i=new_deps.begin(); i!=new_deps.end();)
27 if(tgt->get_depends_ready())
36 deps_ready=new_deps.empty();
39 Action *ObjectFile::build()
41 return Target::build(new Compile(builder, depends.front()->get_name(), name, comp));
44 void ObjectFile::find_depends(Target *tgt)
46 const string &tname=tgt->get_name();
47 string path=tname.substr(0, tname.rfind('/'));
49 SourceFile *src=dynamic_cast<SourceFile *>(tgt);
52 Install *inst=dynamic_cast<Install *>(tgt);
54 src=dynamic_cast<SourceFile *>(inst->get_depends().front());
59 const list<string> &includes=src->get_includes();
60 for(list<string>::const_iterator i=includes.begin(); i!=includes.end(); ++i)
62 Target *hdr2=builder.get_header(*i, path, comp.get_build_info().incpath);
63 if(hdr2 && !contains(depends, hdr2))
68 void ObjectFile::add_depend(Target *tgt)
70 Target::add_depend(tgt);
71 new_deps.push_back(tgt);
74 string ObjectFile::generate_target_name(const Component &comp, const string &src)
76 return (comp.get_package().get_source()/"temp"/comp.get_name()/(Path::splitext(src.substr(src.rfind('/')+1)).base+".o")).str();