]> git.tdb.fi Git - builder.git/commitdiff
Give targets the ability to gather their own build info
authorMikko Rasa <tdb@tdb.fi>
Fri, 3 Oct 2014 21:10:16 +0000 (00:10 +0300)
committerMikko Rasa <tdb@tdb.fi>
Fri, 3 Oct 2014 21:10:16 +0000 (00:10 +0300)
source/binary.cpp
source/datatool.cpp
source/gnucompiler.cpp
source/gnulinker.cpp
source/objectfile.cpp
source/objectfile.h
source/target.cpp
source/target.h

index df0daaff72c51dc46a3a1607f940482e966a871f..6efe77a6475b5ce74fc18d9c2435910b3734f5a8 100644 (file)
@@ -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"))
index 5ce7c02b7b21346df7b471bd04e2817e1f486e06..75ec2da7b750998d77395ba6ba57e8d77afd87a0 100644 (file)
@@ -73,7 +73,8 @@ Task *DataTool::run(const Target &tgt) const
        argv.push_back("-o");
        argv.push_back(FS::relative(dynamic_cast<const FileTarget &>(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)
index 9fcdaf048cd50c23e0eb85e924dfa75d013ae87a..16e24c0090c5bf43a45cd3d69a0559ddcb56acd9 100644 (file)
@@ -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");
index 93eadf6f1197fbff5992013ed4c43abbf2d9a423..6a2fcd54cdfd17d90f330f53f75b66b5bbe625e8 100644 (file)
@@ -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)
index 27883bb41245cf5ef66dac8cf2b6bcef1aa69113..732fe142400f72159f2f800407c16d6287fce10d 100644 (file)
@@ -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)
index 990b16c029c16330ee09f1145c018499f2a0d490..9e583732206a269eadf01ebcbe8dc4bc6abb272b 100644 (file)
@@ -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();
 
index f9fe16b28720c2f3a9628fd99ea27faeabd35a1d..7c5532f9f8200daca4859cedaa51682a138a9a10 100644 (file)
@@ -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())
index 114a51ec35ae934faf1ed89acdf9b99a749c9382..e7150c205deb0d1b274b63da6a0194abd3161299 100644 (file)
@@ -9,6 +9,7 @@
 #include <msp/time/timestamp.h>
 
 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; }