From 0b16c3de0f9dc01bd8a9708008f9435fe0252df1 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Wed, 11 Apr 2012 21:39:21 +0300 Subject: [PATCH] Get rid of the global TargetList typedef --- source/analyzer.cpp | 12 ++++++------ source/builder.cpp | 6 +++--- source/builder.h | 1 + source/filetarget.cpp | 2 +- source/gnuarchiver.cpp | 4 ++-- source/gnulinker.cpp | 6 +++--- source/objectfile.cpp | 2 +- source/objectfile.h | 2 +- source/tar.cpp | 4 ++-- source/target.cpp | 4 ++-- source/target.h | 8 +++++--- source/virtualtarget.cpp | 2 +- 12 files changed, 28 insertions(+), 25 deletions(-) diff --git a/source/analyzer.cpp b/source/analyzer.cpp index dd8894c..b064646 100644 --- a/source/analyzer.cpp +++ b/source/analyzer.cpp @@ -27,8 +27,8 @@ void Analyzer::analyze() const Builder::TargetMap &targets = builder.get_targets(); for(Builder::TargetMap::const_iterator i=targets.begin(); i!=targets.end(); ++i) { - const TargetList &depends = i->second->get_depends(); - for(TargetList::const_iterator j=depends.begin(); j!=depends.end(); ++j) + const Target::Dependencies &depends = i->second->get_depends(); + for(Target::Dependencies::const_iterator j=depends.begin(); j!=depends.end(); ++j) rdepends[*j].insert(i->second); } } @@ -46,8 +46,8 @@ void Analyzer::analyze() Target &cmdline = *builder.get_target("cmdline"); if(mode==RDEPS) { - const TargetList &deps = cmdline.get_depends(); - for(TargetList::const_iterator i=deps.begin(); i!=deps.end(); ++i) + const Target::Dependencies &deps = cmdline.get_depends(); + for(Target::Dependencies::const_iterator i=deps.begin(); i!=deps.end(); ++i) build_depend_table(**i, 0); } else @@ -107,7 +107,7 @@ void Analyzer::build_depend_table(Target &tgt, unsigned depth) if(!max_depth || depth &rdeps = rdepends[&tgt]; @@ -118,7 +118,7 @@ void Analyzer::build_depend_table(Target &tgt, unsigned depth) depends.sort(full_paths ? target_order_full : target_order); - for(TargetList::const_iterator i=depends.begin(); i!=depends.end(); ++i) + for(Target::Dependencies::const_iterator i=depends.begin(); i!=depends.end(); ++i) build_depend_table(**i, depth+1); } } diff --git a/source/builder.cpp b/source/builder.cpp index bd1ee1a..b6f29f8 100644 --- a/source/builder.cpp +++ b/source/builder.cpp @@ -640,7 +640,7 @@ int Builder::do_clean() // Cleaning doesn't care about ordering, so a simpler method can be used set clean_tgts; - TargetList queue; + list queue; queue.push_back(get_target("cmdline")); while(!queue.empty()) @@ -651,8 +651,8 @@ int Builder::do_clean() if(tgt->is_buildable() && (tgt->get_package()==main_pkg || clean>=2)) clean_tgts.insert(tgt); - const TargetList &deps = tgt->get_depends(); - for(TargetList::const_iterator i=deps.begin(); i!=deps.end(); ++i) + const Target::Dependencies &deps = tgt->get_depends(); + for(list::const_iterator i=deps.begin(); i!=deps.end(); ++i) if(!clean_tgts.count(*i)) queue.push_back(*i); } diff --git a/source/builder.h b/source/builder.h index fc160d3..7a33ab8 100644 --- a/source/builder.h +++ b/source/builder.h @@ -56,6 +56,7 @@ private: public: typedef std::map TargetMap; + typedef std::list TargetList; private: typedef std::list PackageList; diff --git a/source/filetarget.cpp b/source/filetarget.cpp index bc4e110..ad3786c 100644 --- a/source/filetarget.cpp +++ b/source/filetarget.cpp @@ -39,7 +39,7 @@ void FileTarget::check_rebuild() mark_rebuild("Does not exist"); else { - for(TargetList::iterator i=depends.begin(); (i!=depends.end() && !rebuild); ++i) + for(Dependencies::iterator i=depends.begin(); (i!=depends.end() && !rebuild); ++i) { FileTarget *ft = dynamic_cast(*i); if(ft && ft->get_mtime()>mtime) diff --git a/source/gnuarchiver.cpp b/source/gnuarchiver.cpp index 8eab751..3f56a2e 100644 --- a/source/gnuarchiver.cpp +++ b/source/gnuarchiver.cpp @@ -52,8 +52,8 @@ Task *GnuArchiver::run(const Target &target) const argv.push_back(relative(lib.get_path(), work_dir).str()); - const TargetList &deps = lib.get_depends(); - for(TargetList::const_iterator i=deps.begin(); i!=deps.end(); ++i) + const Target::Dependencies &deps = lib.get_depends(); + for(Target::Dependencies::const_iterator i=deps.begin(); i!=deps.end(); ++i) if(ObjectFile *obj = dynamic_cast(*i)) argv.push_back(relative(obj->get_path(), work_dir).str()); diff --git a/source/gnulinker.cpp b/source/gnulinker.cpp index 45cfd7f..c59251e 100644 --- a/source/gnulinker.cpp +++ b/source/gnulinker.cpp @@ -53,8 +53,8 @@ Task *GnuLinker::run(const Target &target) const string command = "gcc"; - const list &depends = target.get_depends(); - for(list::const_iterator i=depends.begin(); i!=depends.end(); ++i) + const Target::Dependencies &depends = target.get_depends(); + for(Target::Dependencies::const_iterator i=depends.begin(); i!=depends.end(); ++i) if(ObjectFile *obj = dynamic_cast(*i)) { const Tool *tool = obj->get_tool(); @@ -86,7 +86,7 @@ Task *GnuLinker::run(const Target &target) const argv.push_back("-o"); argv.push_back(relative(bin.get_path(), work_dir).str()); - for(TargetList::const_iterator i=depends.begin(); i!=depends.end(); ++i) + for(Target::Dependencies::const_iterator i=depends.begin(); i!=depends.end(); ++i) { Target *tgt = (*i)->get_real_target(); diff --git a/source/objectfile.cpp b/source/objectfile.cpp index e13b082..52c8a81 100644 --- a/source/objectfile.cpp +++ b/source/objectfile.cpp @@ -21,7 +21,7 @@ ObjectFile::ObjectFile(Builder &b, const Component &c, SourceFile &s): void ObjectFile::find_depends() { - for(TargetList::iterator i=new_deps.begin(); i!=new_deps.end();) + for(Dependencies::iterator i=new_deps.begin(); i!=new_deps.end();) { Target *tgt = *i; if(tgt->get_depends_ready()) diff --git a/source/objectfile.h b/source/objectfile.h index 2148314..1065981 100644 --- a/source/objectfile.h +++ b/source/objectfile.h @@ -14,7 +14,7 @@ class ObjectFile: public FileTarget private: const Component ∁ SourceFile &source; - TargetList new_deps; + Dependencies new_deps; public: ObjectFile(Builder &, const Component &, SourceFile &); diff --git a/source/tar.cpp b/source/tar.cpp index 82330ca..b49e6fe 100644 --- a/source/tar.cpp +++ b/source/tar.cpp @@ -48,8 +48,8 @@ void Tar::Worker::main() FS::Path basedir = FS::basepart(FS::basename(tarball.get_path())); IO::File out(tarball.get_path().str(), IO::M_WRITE); - const TargetList &deps = tarball.get_depends(); - for(TargetList::const_iterator i=deps.begin(); i!=deps.end(); ++i) + const Target::Dependencies &deps = tarball.get_depends(); + for(Target::Dependencies::const_iterator i=deps.begin(); i!=deps.end(); ++i) { FileTarget *ft = dynamic_cast(*i); if(!ft) diff --git a/source/target.cpp b/source/target.cpp index 6ba6471..6653c11 100644 --- a/source/target.cpp +++ b/source/target.cpp @@ -31,7 +31,7 @@ Target *Target::get_buildable_target() return 0; bool self_ok = !building; - for(TargetList::iterator i=depends.begin(); i!=depends.end(); ++i) + for(Dependencies::iterator i=depends.begin(); i!=depends.end(); ++i) { Target *tgt = (*i)->get_buildable_target(); if(tgt) @@ -69,7 +69,7 @@ void Target::prepare() } preparing = true; - for(TargetList::iterator i=depends.begin(); i!=depends.end(); ++i) + for(Dependencies::iterator i=depends.begin(); i!=depends.end(); ++i) (*i)->prepare(); check_rebuild(); diff --git a/source/target.h b/source/target.h index 48bd7e4..a47eb75 100644 --- a/source/target.h +++ b/source/target.h @@ -13,7 +13,6 @@ class Task; class Tool; class Target; -typedef std::list TargetList; /** Targets make up the build graph. This class is a base for all target types and @@ -21,6 +20,9 @@ handles many common tasks. See also FileTarget and VirtualTarget. */ class Target { +public: + typedef std::list Dependencies; + protected: Builder &builder; const Package *package; @@ -32,7 +34,7 @@ protected: bool rebuild; std::string rebuild_reason; - TargetList depends; + Dependencies depends; bool deps_ready; bool preparing; @@ -68,7 +70,7 @@ public: bool get_rebuild() const { return rebuild; } const std::string &get_rebuild_reason() const { return rebuild_reason; } void add_depend(Target *); - const TargetList &get_depends() const { return depends; } + const Dependencies &get_depends() const { return depends; } bool get_depends_ready() const { return deps_ready; } /** diff --git a/source/virtualtarget.cpp b/source/virtualtarget.cpp index e22d8fc..e3974d5 100644 --- a/source/virtualtarget.cpp +++ b/source/virtualtarget.cpp @@ -13,7 +13,7 @@ VirtualTarget::VirtualTarget(Builder &b, const string &n): void VirtualTarget::check_rebuild() { // Virtual targets are only rebuilt if their dependencies need rebuilding. - for(TargetList::iterator i=depends.begin(); (i!=depends.end() && !rebuild); ++i) + for(Dependencies::iterator i=depends.begin(); (i!=depends.end() && !rebuild); ++i) if((*i)->get_rebuild()) mark_rebuild((*i)->get_name()+" needs rebuilding"); } -- 2.43.0