]> git.tdb.fi Git - builder.git/commitdiff
Move nested build signature creation to FileTarget
authorMikko Rasa <tdb@tdb.fi>
Wed, 25 Sep 2013 17:19:57 +0000 (20:19 +0300)
committerMikko Rasa <tdb@tdb.fi>
Wed, 25 Sep 2013 19:31:35 +0000 (22:31 +0300)
This way the same code can be used by different target classes that need
it.  In particular, both Binary and StaticLibrary need nested signatures,
and FileTerget is their closest common base.

source/binary.cpp
source/binary.h
source/filetarget.cpp
source/filetarget.h
source/staticlibrary.cpp

index b3b882d314427f6bf8efdd73b50210edd50d1112..df0daaff72c51dc46a3a1607f940482e966a871f 100644 (file)
@@ -24,6 +24,9 @@ Binary::Binary(Builder &b, const Component &c, const string &p, const list<Objec
        component = &c;
        for(list<ObjectFile *>::const_iterator i=objects.begin(); i!=objects.end(); ++i)
                add_dependency(**i);
+
+       nested_build_sig = true;
+       arch_in_build_sig = true;
 }
 
 void Binary::find_dependencies()
@@ -76,20 +79,3 @@ void Binary::find_dependencies()
                        add_dependency(**i);
        }
 }
-
-string Binary::create_build_signature() const
-{
-       set<const Tool *> object_tools;
-       for(list<ObjectFile *>::const_iterator i=objects.begin(); i!=objects.end(); ++i)
-               object_tools.insert((*i)->get_tool());
-
-       list<string> sigs;
-       for(set<const Tool *>::const_iterator i=object_tools.begin(); i!=object_tools.end(); ++i)
-               sigs.push_back((*i)->create_build_signature(component->get_build_info()));
-       sigs.sort();
-       sigs.push_front(tool->create_build_signature(component->get_build_info()));
-       if(const Architecture *arch = tool->get_architecture())
-               sigs.push_front(arch->get_name());
-
-       return join(sigs.begin(), sigs.end(), ";");
-}
index b689a1d4fab8368f2ccd45a23dd7e57129a1a889..b4357581fc905fde0b5110cac788f4149306196e 100644 (file)
@@ -19,8 +19,6 @@ protected:
        Binary(Builder &, const Component &, const std::string &, const std::list<ObjectFile *> &);
 
        virtual void find_dependencies();
-
-       virtual std::string create_build_signature() const;
 };
 
 #endif
index 862ddbe5836197c500ae99cf05f324c419bacbe5..51a92d13b1a11f61c34671a1d8c39adfa710bdcc 100644 (file)
@@ -30,6 +30,8 @@ void FileTarget::init(const SourcePackage *p)
 {
        size = 0;
        package = p;
+       nested_build_sig = false;
+       arch_in_build_sig = false;
 
        builder.get_vfs().register_path(path, this);
 
@@ -118,7 +120,27 @@ string FileTarget::create_build_signature() const
                return string();
 
        const BuildInfo &binfo = (component ? component->get_build_info() : package->get_build_info());
-       return tool->create_build_signature(binfo);
+       list<string> sigs;
+       if(nested_build_sig && component)
+       {
+               set<const Tool *> depend_tools;
+               for(Dependencies::const_iterator i=depends.begin(); i!=depends.end(); ++i)
+                       if((*i)->get_component()==component && (*i)->get_tool())
+                               depend_tools.insert((*i)->get_tool());
+
+               for(set<const Tool *>::const_iterator i=depend_tools.begin(); i!=depend_tools.end(); ++i)
+                       sigs.push_back((*i)->create_build_signature(binfo));
+               sigs.sort();
+               sigs.push_front(tool->create_build_signature(binfo));
+       }
+       else
+               sigs.push_back(tool->create_build_signature(binfo));
+
+       if(arch_in_build_sig)
+               if(const Architecture *arch = tool->get_architecture())
+                       sigs.push_front(arch->get_name());
+
+       return join(sigs.begin(), sigs.end(), ";");
 }
 
 void FileTarget::build(Task &task)
index 64567fd255755a6f87fde6d3915ecf4318b695d3..976590f4b67d15a96da867e046d4e9ac62fa3354 100644 (file)
@@ -16,6 +16,8 @@ protected:
        unsigned size;
        Msp::FS::Path install_location;
        std::string install_filename;
+       bool nested_build_sig;
+       bool arch_in_build_sig;
 
        FileTarget(Builder &, const Msp::FS::Path &);
        FileTarget(Builder &, const SourcePackage &, const Msp::FS::Path &);
index 29abc0d36efda33358038d8db90f703e2458f5e4..9ee4a9a79771326c019206bc402645e32aa0b2b8 100644 (file)
@@ -19,6 +19,8 @@ StaticLibrary::StaticLibrary(Builder &b, const Component &c, const list<ObjectFi
                add_dependency(**i);
 
        install_location = "lib";
+       nested_build_sig = true;
+       arch_in_build_sig = true;
 }
 
 string StaticLibrary::generate_filename(const Component &comp)