From: Mikko Rasa Date: Fri, 3 Oct 2014 21:10:16 +0000 (+0300) Subject: Give targets the ability to gather their own build info X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=3f0f721;p=builder.git Give targets the ability to gather their own build info --- diff --git a/source/binary.cpp b/source/binary.cpp index df0daaf..6efe77a 100644 --- a/source/binary.cpp +++ b/source/binary.cpp @@ -40,10 +40,11 @@ void Binary::find_dependencies() queue.push_back(component); while(!queue.empty()) { - const Component *c = queue.front(); queue.erase(queue.begin()); - const BuildInfo &binfo = c->get_build_info(); + BuildInfo binfo; + collect_build_info(binfo); + for(BuildInfo::WordList::const_iterator i=binfo.libs.begin(); i!=binfo.libs.end(); ++i) { if(i->size()>10 && !i->compare(i->size()-10, 10, ".framework")) diff --git a/source/datatool.cpp b/source/datatool.cpp index 5ce7c02..75ec2da 100644 --- a/source/datatool.cpp +++ b/source/datatool.cpp @@ -73,7 +73,8 @@ Task *DataTool::run(const Target &tgt) const argv.push_back("-o"); argv.push_back(FS::relative(dynamic_cast(tgt).get_path(), work_dir).str()); - const BuildInfo &binfo = comp.get_build_info(); + BuildInfo binfo; + tgt.collect_build_info(binfo); if(binfo.debug) argv.push_back("-g"); if(binfo.optimize>0) diff --git a/source/gnucompiler.cpp b/source/gnucompiler.cpp index 9fcdaf0..16e24c0 100644 --- a/source/gnucompiler.cpp +++ b/source/gnucompiler.cpp @@ -81,7 +81,9 @@ Task *GnuCompiler::run(const Target &target) const argv.push_back(executable->get_path().str()); argv.push_back("-c"); - const BuildInfo &binfo = comp.get_build_info_for_path(object.get_source().get_path()); + BuildInfo binfo; + target.collect_build_info(binfo); + if(binfo.warning_level>=1) { argv.push_back("-Wall"); diff --git a/source/gnulinker.cpp b/source/gnulinker.cpp index 93eadf6..6a2fcd5 100644 --- a/source/gnulinker.cpp +++ b/source/gnulinker.cpp @@ -199,7 +199,8 @@ Task *GnuLinker::Linker::run(const Target &target) const } } - const BuildInfo &binfo = comp.get_build_info(); + BuildInfo binfo; + target.collect_build_info(binfo); for(BuildInfo::PathList::const_iterator i=binfo.libpath.begin(); i!=binfo.libpath.end(); ++i) argv.push_back("-L"+i->str()); if(binfo.strip) diff --git a/source/objectfile.cpp b/source/objectfile.cpp index 27883bb..732fe14 100644 --- a/source/objectfile.cpp +++ b/source/objectfile.cpp @@ -37,6 +37,12 @@ FS::Path ObjectFile::generate_target_path(const Component &comp, const FS::Path return temp_dir/(FS::basepart(fn)+".o"); } +void ObjectFile::collect_build_info(BuildInfo &binfo) const +{ + Target::collect_build_info(binfo); + binfo.update_from(component->get_build_info_for_path(source.get_path())); +} + void ObjectFile::find_dependencies() { for(Dependencies::iterator i=depends.begin(); i!=depends.end(); ++i) diff --git a/source/objectfile.h b/source/objectfile.h index 990b16c..9e58373 100644 --- a/source/objectfile.h +++ b/source/objectfile.h @@ -22,6 +22,8 @@ public: virtual const char *get_type() const { return "ObjectFile"; } SourceFile &get_source() const { return source; } + virtual void collect_build_info(BuildInfo &) const; + private: virtual void find_dependencies(); diff --git a/source/target.cpp b/source/target.cpp index f9fe16b..7c5532f 100644 --- a/source/target.cpp +++ b/source/target.cpp @@ -85,6 +85,14 @@ void Target::set_tool(Tool &t) (*i)->set_tool(t); } +void Target::collect_build_info(BuildInfo &binfo) const +{ + if(component) + binfo.update_from(component->get_build_info()); + else if(package) + binfo.update_from(package->get_build_info()); +} + void Target::force_rebuild() { if(!is_buildable()) diff --git a/source/target.h b/source/target.h index 114a51e..e7150c2 100644 --- a/source/target.h +++ b/source/target.h @@ -9,6 +9,7 @@ #include class Builder; +class BuildInfo; class Component; class SourcePackage; class Task; @@ -114,6 +115,8 @@ public: the build() function. */ const Tool *get_tool() const { return tool; } + virtual void collect_build_info(BuildInfo &) const; + /** Indicates if it's possible to build this target. */ bool is_buildable() const { return tool!=0; }