]> git.tdb.fi Git - builder.git/commitdiff
Get rid of the global TargetList typedef
authorMikko Rasa <tdb@tdb.fi>
Wed, 11 Apr 2012 18:39:21 +0000 (21:39 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sun, 8 Jul 2012 21:08:49 +0000 (00:08 +0300)
12 files changed:
source/analyzer.cpp
source/builder.cpp
source/builder.h
source/filetarget.cpp
source/gnuarchiver.cpp
source/gnulinker.cpp
source/objectfile.cpp
source/objectfile.h
source/tar.cpp
source/target.cpp
source/target.h
source/virtualtarget.cpp

index dd8894c61b4d61a122c236c8c9116091658a0f2f..b0646463669fd07c8c87f9e86a1f3e124bddf5e0 100644 (file)
@@ -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<max_depth-1)
        {
-               TargetList depends;
+               Target::Dependencies depends;
                if(mode==RDEPS)
                {
                        const set<Target *> &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);
        }
 }
index bd1ee1aa82b523c450faeb6c72357e9d6651fc8d..b6f29f845108b300c30218c80d7a66dde8af5f14 100644 (file)
@@ -640,7 +640,7 @@ int Builder::do_clean()
        // Cleaning doesn't care about ordering, so a simpler method can be used
 
        set<Target *> clean_tgts;
-       TargetList queue;
+       list<Target *> 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<Target *>::const_iterator i=deps.begin(); i!=deps.end(); ++i)
                        if(!clean_tgts.count(*i))
                                queue.push_back(*i);
        }
index fc160d3220a971a903a5495b3bb76ac43a4e81dc..7a33ab8f86d6022a142e99eaad17d9f3da8e59ff 100644 (file)
@@ -56,6 +56,7 @@ private:
 
 public:
        typedef std::map<std::string, Target *> TargetMap;
+       typedef std::list<Target *> TargetList;
 
 private:
        typedef std::list<Package *> PackageList;
index bc4e110d8700002f822bca478d0e6aa6fde6a8be..ad3786c76611d3012adcd154ef6bcfbac3210485 100644 (file)
@@ -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<FileTarget *>(*i);
                        if(ft && ft->get_mtime()>mtime)
index 8eab751e7ad405faf49951bff4f763fd003303d6..3f56a2ea4e246e701bd4b18ade03104c4d797f3b 100644 (file)
@@ -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<ObjectFile *>(*i))
                        argv.push_back(relative(obj->get_path(), work_dir).str());
 
index 45cfd7fff4fc2b98c134c57fffdda78d9d3e8b42..c59251efabe9dc8a1baa4caba18d36a08938c971 100644 (file)
@@ -53,8 +53,8 @@ Task *GnuLinker::run(const Target &target) const
 
        string command = "gcc";
 
-       const list<Target *> &depends = target.get_depends();
-       for(list<Target *>::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<ObjectFile *>(*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();
 
index e13b0820dc633739fb966573249de4e816828e18..52c8a81e8de302efe936802fc87d084e8eba4260 100644 (file)
@@ -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())
index 21483147cfa20cb7dd22b115450baec00e8ed89e..10659814cd66d59f5abfa0902deaf2b35c5e85dc 100644 (file)
@@ -14,7 +14,7 @@ class ObjectFile: public FileTarget
 private:
        const Component &comp;
        SourceFile &source;
-       TargetList new_deps;
+       Dependencies new_deps;
        
 public:
        ObjectFile(Builder &, const Component &, SourceFile &);
index 82330caa9762f34531be65b56fcffcdd2b2eb3f6..b49e6fe08a7279b3bdddcde002955b4516cf50df 100644 (file)
@@ -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<FileTarget *>(*i);
                if(!ft)
index 6ba64717e4272405fb79b8a008df471dd9f57b4c..6653c11fb0b90e0e3e916a63b7a74548c259daab 100644 (file)
@@ -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();
index 48bd7e4438502e466d2c34770b408e7bb55765ea..a47eb756f868cc0663939f7d255c6b31f3f15d8d 100644 (file)
@@ -13,7 +13,6 @@ class Task;
 class Tool;
 
 class Target;
-typedef std::list<Target *> 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<Target *> 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; }
 
        /**
index e22d8fc438e709f6f03d450628861d199ecc732e..e3974d57c426a311879964850994a506e4d8236b 100644 (file)
@@ -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");
 }