1 #include <msp/path/utils.h>
6 #include "objectfile.h"
8 #include "sourcefile.h"
13 ObjectFile::ObjectFile(Builder &b, const Component &c, SourceFile &src):
14 Target(b, &c.get_package(), generate_target_name(c, src.get_name())),
22 Processes as many new dependences as possible. Some may be left unprocessed
23 if their own dependencies are not ready, requiring another call to this
24 function. Use the get_deps_ready() function to determine whether this is the
27 void ObjectFile::find_depends()
29 for(TargetList::iterator i=new_deps.begin(); i!=new_deps.end();)
32 if(tgt->get_depends_ready())
41 deps_ready=new_deps.empty();
44 Action *ObjectFile::build()
46 return Target::build(new Compile(builder, *this));
50 Recursively looks for header targets and adds them as dependencies.
52 void ObjectFile::find_depends(Target *tgt)
54 const string &tname=tgt->get_name();
55 string path=tname.substr(0, tname.rfind('/'));
57 SourceFile *src=dynamic_cast<SourceFile *>(tgt);
60 Install *inst=dynamic_cast<Install *>(tgt);
62 src=dynamic_cast<SourceFile *>(inst->get_depends().front());
67 const string &arch=comp.get_package().get_arch();
68 const StringList &incpath=comp.get_build_info().incpath;
70 const list<string> &includes=src->get_includes();
71 for(list<string>::const_iterator i=includes.begin(); i!=includes.end(); ++i)
73 Target *hdr2=builder.get_header(*i, arch, path, incpath);
74 if(hdr2 && find(depends.begin(), depends.end(), hdr2)==depends.end())
80 Adds a target to the dependency list as well as the new dependencies list.
82 void ObjectFile::add_depend(Target *tgt)
84 Target::add_depend(tgt);
85 new_deps.push_back(tgt);
88 string ObjectFile::generate_target_name(const Component &comp, const string &src)
90 return (comp.get_package().get_temp_dir()/comp.get_name()/(Path::splitext(src.substr(src.rfind('/')+1)).base+".o")).str();