From: Mikko Rasa Date: Wed, 25 Sep 2013 17:19:57 +0000 (+0300) Subject: Move nested build signature creation to FileTarget X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=8575b50479945c3ad6ab0e4ea7eb116da5b5f04d;p=builder.git Move nested build signature creation to FileTarget 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. --- diff --git a/source/binary.cpp b/source/binary.cpp index b3b882d..df0daaf 100644 --- a/source/binary.cpp +++ b/source/binary.cpp @@ -24,6 +24,9 @@ Binary::Binary(Builder &b, const Component &c, const string &p, const list::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 object_tools; - for(list::const_iterator i=objects.begin(); i!=objects.end(); ++i) - object_tools.insert((*i)->get_tool()); - - list sigs; - for(set::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(), ";"); -} diff --git a/source/binary.h b/source/binary.h index b689a1d..b435758 100644 --- a/source/binary.h +++ b/source/binary.h @@ -19,8 +19,6 @@ protected: Binary(Builder &, const Component &, const std::string &, const std::list &); virtual void find_dependencies(); - - virtual std::string create_build_signature() const; }; #endif diff --git a/source/filetarget.cpp b/source/filetarget.cpp index 862ddbe..51a92d1 100644 --- a/source/filetarget.cpp +++ b/source/filetarget.cpp @@ -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 sigs; + if(nested_build_sig && component) + { + set 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_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) diff --git a/source/filetarget.h b/source/filetarget.h index 64567fd..976590f 100644 --- a/source/filetarget.h +++ b/source/filetarget.h @@ -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 &); diff --git a/source/staticlibrary.cpp b/source/staticlibrary.cpp index 29abc0d..9ee4a9a 100644 --- a/source/staticlibrary.cpp +++ b/source/staticlibrary.cpp @@ -19,6 +19,8 @@ StaticLibrary::StaticLibrary(Builder &b, const Component &c, const list