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())),
23 Processes as many new dependences as possible. Some may be left unprocessed
24 if their own dependencies are not ready, requiring another call to this
25 function. Use the get_deps_ready() function to determine whether this is the
28 void ObjectFile::find_depends()
30 for(TargetList::iterator i=new_deps.begin(); i!=new_deps.end();)
33 if(tgt->get_depends_ready())
42 deps_ready=new_deps.empty();
45 Action *ObjectFile::build()
47 return Target::build(new Compile(builder, *this));
51 Recursively looks for header targets and adds them as dependencies.
53 void ObjectFile::find_depends(Target *tgt)
55 const string &tname=tgt->get_name();
56 string path=tname.substr(0, tname.rfind('/'));
58 SourceFile *src=dynamic_cast<SourceFile *>(tgt);
61 Install *inst=dynamic_cast<Install *>(tgt);
63 src=dynamic_cast<SourceFile *>(inst->get_depends().front());
68 const list<string> &includes=src->get_includes();
69 for(list<string>::const_iterator i=includes.begin(); i!=includes.end(); ++i)
71 Target *hdr2=builder.get_header(*i, path, comp.get_build_info().incpath);
72 if(hdr2 && !contains(depends, hdr2))
78 Adds a target to the dependency list as well as the new dependencies list.
80 void ObjectFile::add_depend(Target *tgt)
82 Target::add_depend(tgt);
83 new_deps.push_back(tgt);
86 string ObjectFile::generate_target_name(const Component &comp, const string &src)
88 return (comp.get_package().get_source()/"temp"/comp.get_name()/(Path::splitext(src.substr(src.rfind('/')+1)).base+".o")).str();