]> git.tdb.fi Git - builder.git/commitdiff
Code reorganizing and cleanup
authorMikko Rasa <tdb@tdb.fi>
Tue, 14 Nov 2006 00:05:34 +0000 (00:05 +0000)
committerMikko Rasa <tdb@tdb.fi>
Tue, 14 Nov 2006 00:05:34 +0000 (00:05 +0000)
29 files changed:
source/analyzer.cpp
source/archive.cpp
source/builder.cpp
source/builder.h
source/buildinfo.cpp
source/buildinfo.h
source/compile.cpp
source/compile.h
source/component.cpp
source/component.h
source/copy.h
source/executable.h
source/externalaction.cpp
source/externalaction.h
source/header.h
source/install.h
source/link.cpp
source/misc.h
source/objectfile.cpp
source/objectfile.h
source/package.cpp
source/package.h
source/packageref.h
source/sourcefile.h
source/staticlibrary.h
source/target.cpp
source/target.h
source/virtualtarget.cpp
source/virtualtarget.h

index 7dceac720eb7e4f5d969b3d3c381776adfd0bdca..21ed52cec64b2cf463a62a1d9823870ea5917283 100644 (file)
@@ -73,9 +73,9 @@ void Analyzer::build_depend_table(Target &tgt, unsigned depth)
 
        if(!max_depth || depth<max_depth-1)
        {
-               const list<Target *> &depends=tgt.get_depends();
+               const TargetList &depends=tgt.get_depends();
                //depends.sort(target_order);
-               for(list<Target *>::const_iterator i=depends.begin(); i!=depends.end(); ++i)
+               for(TargetList::const_iterator i=depends.begin(); i!=depends.end(); ++i)
                        build_depend_table(**i, depth+1);
        }
 }
index daff2339d56a1ac0d3798c5b10fdfa604e654283..11c633c39da54539d2fdd827cb831a8556aea2b3 100644 (file)
@@ -18,8 +18,8 @@ Archive::Archive(Builder &b, const StaticLibrary &lib):
        argv.push_back("rc");
 
        argv.push_back(lib.get_name());
-       const list<Target *> &deps=lib.get_depends();
-       for(list<Target *>::const_iterator i=deps.begin(); i!=deps.end(); ++i)
+       const TargetList &deps=lib.get_depends();
+       for(TargetList::const_iterator i=deps.begin(); i!=deps.end(); ++i)
                if(dynamic_cast<ObjectFile *>(*i))
                        argv.push_back((*i)->get_name());
 
index 28d57d44012ce1465720185b1ea5d04c7558b910..5a1d624390fa45250bab4451b3196693d5d46dc9 100644 (file)
@@ -27,12 +27,12 @@ using namespace std;
 using namespace Msp;
 
 Builder::Builder(int argc, char **argv):
+       analyzer(0),
+       do_build(true),
        verbose(1),
+       chrome(false),
        build_file("Build"),
-       do_build(true),
-       analyzer(0),
-       jobs(1),
-       chrome(false)
+       jobs(1)
 {
        GetOpt getopt;
        getopt.add_option(GetOpt::Option('a', "analyze", GetOpt::REQUIRED));
@@ -256,7 +256,7 @@ int Builder::main()
                return 0;
        }
 
-       std::list<std::string> missing;
+       StringList missing;
        for(PackageMap::iterator i=packages.begin(); i!=packages.end(); ++i)
                if(!i->second)
                        missing.push_back(i->first);
@@ -639,8 +639,8 @@ void Builder::package_help()
        const Config::OptionMap &options=config.get_options();
 
        cout<<"Required packages:\n  ";
-       const list<PackageRef> &requires=default_pkg->get_requires();
-       for(list<PackageRef>::const_iterator i=requires.begin(); i!=requires.end(); ++i)
+       const PkgRefList &requires=default_pkg->get_requires();
+       for(PkgRefList::const_iterator i=requires.begin(); i!=requires.end(); ++i)
        {
                if(i!=requires.begin())
                        cout<<", ";
index 3dba62920a48d1821f242c3d915e550e041aa843..786b48c37f8f1752a8fbe17630d80aeacf5196e1 100644 (file)
@@ -8,10 +8,11 @@
 #include <msp/parser/loader.h>
 #include <msp/path/path.h>
 #include "config.h"
+#include "misc.h"
+#include "target.h"
 
 class Analyzer;
 class Package;
-class Target;
 
 class Builder: public Msp::Application
 {
@@ -22,8 +23,8 @@ public:
        bool     get_build_all() const { return build_all; }
        Package  *get_package(const std::string &);
        Target   *get_target(const std::string &);
-       Target   *get_header(const std::string &, const std::string &, const std::list<std::string> &);
-       Target   *get_library(const std::string &, const std::list<std::string> &);
+       Target   *get_header(const std::string &, const std::string &, const StringList &);
+       Target   *get_library(const std::string &, const StringList &);
        const Msp::Path::Path &get_cwd() const { return cwd; }
        int      main();
        ~Builder();
@@ -35,49 +36,51 @@ private:
        public:
                Loader(Builder &, const Msp::Path::Path &);
        private:
-               Builder &bld;
+               Builder         &bld;
                Msp::Path::Path src;
                
                void package(const std::string &);
        };
 
+       typedef std::list<Package *>               PackageList;
        typedef std::map<std::string, Package *>   PackageMap;
        typedef std::map<std::string, Target *>    TargetMap;
        typedef std::map<std::string, std::string> ToolMap;
        
-       std::list<std::string> cmdline_targets;
+       StringList   cmdline_targets;
        RawOptionMap cmdline_options;
+       Msp::Path::Path cwd;
        
-       PackageMap  packages;
-       std::list<Package *> new_pkgs;
-       Package     *default_pkg;
+       PackageMap   packages;
+       PackageList  new_pkgs;
+       Package      *default_pkg;
 
-       TargetMap   targets;
-       std::list<Target *> new_tgts;
-       TargetMap   includes;
-       TargetMap   libraries;
+       TargetMap    targets;
+       TargetList   new_tgts;
+       TargetMap    includes;
+       TargetMap    libraries;
 
-       ToolMap     tools;
-       unsigned    verbose;
-       Msp::Path::Path cwd;
+       ToolMap      tools;    /// Not used yet
+       
+       Analyzer        *analyzer;
+       bool            do_build;
+       bool            dry_run;
+       bool            help;
+       unsigned        verbose;
+       bool            chrome;
        Msp::Path::Path build_file;
-       bool        do_build;
-       bool        dry_run;
-       Analyzer    *analyzer;
-       unsigned    jobs;
-       std::list<std::string> what_if;
-       bool        chrome;
-       bool        conf_all;
-       bool        build_all;
-       bool        help;
+       unsigned        jobs;
+       StringList      what_if;
+       bool            conf_all;
+       bool            build_all;
 
-       int load_build_file(const Msp::Path::Path &);
-       int create_targets();
+       int    load_build_file(const Msp::Path::Path &);
+       int    create_targets();
        Target *check_header(const Msp::Path::Path &);
-       void add_target(Target *);
-       void update_hash(std::string &, const std::string &);
-       int build();
-       void package_help();
+       void   add_target(Target *);
+       void   update_hash(std::string &, const std::string &);
+       int    build();
+       void   package_help();
        
        static Msp::Application::RegApp<Builder> reg;
 };
index 340fd9660bbdfd6333d9eb219df6389ff545108f..f96820baee83f3886e33189d5900a1a17d346daa 100644 (file)
@@ -23,10 +23,10 @@ void BuildInfo::unique()
        unique(libs);
 }
 
-void BuildInfo::unique(InfoList &l)
+void BuildInfo::unique(StringList &l)
 {
-       InfoList l2;
-       for(InfoList::iterator i=l.begin(); i!=l.end(); ++i)
+       StringList l2;
+       for(StringList::iterator i=l.begin(); i!=l.end(); ++i)
                if(!contains(l2, *i))
                        l2.push_back(*i);
        swap(l, l2);
index 2e98906b36c3ef86debaac053ab37c4ae962c489..ccd4b86798db7cc4a8c96eafffaef56c0ea82f82 100644 (file)
@@ -4,6 +4,7 @@
 #include <list>
 #include <string>
 #include <msp/parser/loader.h>
+#include "misc.h"
 
 class BuildInfo
 {
@@ -23,19 +24,17 @@ public:
                void library(const std::string &s) { binfo.libs.push_back(s); }
        };
        
-       typedef std::list<std::string> InfoList;
-       
-       InfoList cflags;
-       InfoList defines;
-       InfoList incpath;
-       InfoList ldflags;
-       InfoList libpath;
-       InfoList libs;
+       StringList cflags;
+       StringList defines;
+       StringList incpath;
+       StringList ldflags;
+       StringList libpath;
+       StringList libs;
 
        void add(const BuildInfo &);
        void unique();
 private:
-       void unique(InfoList &);
+       void unique(StringList &);
 };
 
 #endif
index d823c30a5ace4d90aab67ec050e9fa8cc1e2379f..fd802bbb54e76d2a960ae140e40003a174aa03a4 100644 (file)
@@ -3,18 +3,21 @@
 #include "buildinfo.h"
 #include "compile.h"
 #include "component.h"
+#include "objectfile.h"
 #include "package.h"
 
 using namespace std;
 using namespace Msp;
 
-Compile::Compile(Builder &b, const Path::Path &s, const Path::Path &o, const Component &c):
-       ExternalAction(b),
-       source(s),
-       object(o),
-       comp(c)
+Compile::Compile(Builder &b, const ObjectFile &obj):
+       ExternalAction(b)
 {
-       string ext=Path::splitext(source.str()).ext;
+       const Component &comp=obj.get_component();
+
+       const TargetList &deps=obj.get_depends();
+       Path::Path spath=deps.front()->get_name();
+
+       string ext=Path::splitext(spath.str()).ext;
        const char *tool=0;
        if(ext==".cpp" || ext==".cc")
        {
@@ -36,14 +39,15 @@ Compile::Compile(Builder &b, const Path::Path &s, const Path::Path &o, const Com
        for(list<string>::const_iterator i=binfo.defines.begin(); i!=binfo.defines.end(); ++i)
                argv.push_back("-D"+*i);
        
+       Path::Path opath=obj.get_name();
        argv.push_back("-o");
-       argv.push_back(object.str());
-       argv.push_back(source.str());
+       argv.push_back(opath.str());
+       argv.push_back(spath.str());
 
        if(!builder.get_dry_run())
-               Path::mkpath(object.subpath(0, object.size()-1), 0755);
+               Path::mkpath(opath.subpath(0, opath.size()-1), 0755);
 
-       announce(comp.get_package().get_name(), tool, relative(object.str(), comp.get_package().get_source()).str());
+       announce(comp.get_package().get_name(), tool, relative(opath, comp.get_package().get_source()).str());
 
        launch();
 }
index 42ae95c1f45c125ade30dc9bc92e730ab968efd7..5e0d47f3104ca148ee47e99620f2e7e2b97b51b7 100644 (file)
@@ -5,15 +5,12 @@
 #include "externalaction.h"
 
 class Component;
+class ObjectFile;
 
 class Compile: public ExternalAction
 {
 public:
-       Compile(Builder &, const Msp::Path::Path &, const Msp::Path::Path &, const Component &);
-private:
-       Msp::Path::Path source;
-       Msp::Path::Path object;
-       const Component &comp;
+       Compile(Builder &, const ObjectFile &);
 };
 
 #endif
index 6d80f3b0efc249511eae49e0d41cd0ec1d317172..6d02ad319e690a33be59823edbf4ddc35d85fcb3 100644 (file)
@@ -12,7 +12,7 @@ Component::Component(Package &p, Type t, const string &n):
 
 void Component::resolve_refs()
 {
-       for(list<PackageRef>::iterator i=requires.begin(); i!=requires.end(); ++i)
+       for(PkgRefList::iterator i=requires.begin(); i!=requires.end(); ++i)
                i->resolve();
 }
 
@@ -20,7 +20,7 @@ void Component::create_build_info()
 {
        build_info.add(pkg.get_build_info());
 
-       for(list<PackageRef>::iterator i=requires.begin(); i!=requires.end(); ++i)
+       for(PkgRefList::iterator i=requires.begin(); i!=requires.end(); ++i)
        {
                if(!i->get_package())
                        continue;
index 04a0a41103b858a2a483c7b97e8ff75c2b3fcb68..ab3906854f79e38ca192fead4ca744f79ff4291f 100644 (file)
@@ -52,7 +52,7 @@ protected:
        bool        install;
        std::string install_headers;
        BuildInfo   build_info;
-       std::list<PackageRef> requires;
+       PkgRefList  requires;
 };
 typedef std::list<Component> ComponentList;
 
index 018b3de8e6cac0b0df823403353a13568a40284b..3f92b155f4960038ccc7a5341586d27bb870d7b0 100644 (file)
@@ -18,7 +18,7 @@ private:
        {
        public:
                Worker(Copy &i): copy(i), done(false), error(false) { launch(); }
-               bool get_done() const { return done; }
+               bool get_done() const  { return done; }
                bool get_error() const { return error; }
        private:
                Copy &copy;
index 81637a7ae461f334a5866e02e0517eee6a37c5d5..7fefef7a469326246b706b0f5f72d4a7282f3add 100644 (file)
@@ -10,10 +10,10 @@ class Executable: public Target
 {
 public:
        Executable(Builder &, const Component &, const std::list<ObjectFile *> &);
-       const char *get_type() const { return "Executable"; }
+       const char      *get_type() const      { return "Executable"; }
        const Component &get_component() const { return comp; }
-       void find_depends();
-       Action *build();
+       void            find_depends();
+       Action          *build();
 private:
        const Component &comp;
 
index bae244ce7cf471633106154e99de956c245b2eab..b86d8028da25636e5677f00e5eb1763df6a17a94 100644 (file)
@@ -36,7 +36,7 @@ void ExternalAction::launch()
 {
        if(builder.get_verbose()>=2)
        {
-               for(list<string>::const_iterator i=argv.begin(); i!=argv.end(); ++i)
+               for(StringList::const_iterator i=argv.begin(); i!=argv.end(); ++i)
                {
                        if(i!=argv.begin())
                                cout<<' ';
@@ -53,7 +53,7 @@ void ExternalAction::launch()
                if(pid==0)
                {
                        char *argv_[argv.size()+1];
-                       for(CountingIterator<string, list<string>::iterator> i=argv.begin(); i!=argv.end(); ++i)
+                       for(CountingIterator<string, StringList::iterator> i=argv.begin(); i!=argv.end(); ++i)
                                argv_[i.count()]=strdup(i->c_str());
                        argv_[argv.size()]=0;
                        execvp(argv_[0], argv_);
index 0d0924a966e049777f0afe02bd700d80e9d6e025..86f32753e61f3b323f7a2012a3bd85a3438f8e4a 100644 (file)
@@ -4,15 +4,16 @@
 #include <list>
 #include <string>
 #include "action.h"
+#include "misc.h"
 
 class ExternalAction: public Action
 {
 public:
        int check();
 protected:
-       std::list<std::string> argv;
-       int pid;
-       int exit_code;
+       StringList argv;
+       int        pid;
+       int        exit_code;
        
        ExternalAction(Builder &b): Action(b), pid(0), exit_code(0) { }
        void launch();
index 56e563408ca622030f10cb842a795aac772b939a..c398468a882dc2cb0ded93a493052c4b9e70774b 100644 (file)
@@ -15,7 +15,7 @@ class SystemHeader: public Header
 public:
        SystemHeader(Builder &b, const std::string &f): Header(b,0,f) { }
        const char *get_type() const { return "SystemHeader"; }
-       void find_depends() { deps_ready=true; }
+       void       find_depends()    { deps_ready=true; }
 };
 
 #endif
index 2aa3280a75778494e664c0a8562c43e17dd12098..503205a021f0a4223e9bb537078193d130d05444 100644 (file)
@@ -8,8 +8,8 @@ class Install: public Target
 public:
        Install(Builder &, const Package &, Target &, const std::string &);
        const char *get_type() const { return "Install"; }
-       void check_rebuild();
-       Action *build();
+       void       check_rebuild();
+       Action     *build();
 private:
 };
 
index 8b4c56421089e34d8bee43ffbd378c28cfb1566d..7cbdc03c84db1b0b7dbaaa4f96d54fcfc6935d74 100644 (file)
@@ -14,6 +14,7 @@ Link::Link(Builder &b, const Executable &exe):
 {
        const Component &comp=exe.get_component();
 
+       //XXX Determine whether to use g++ or gcc
        argv.push_back("g++");
        
        if(comp.get_type()==Component::LIBRARY)
@@ -29,8 +30,8 @@ Link::Link(Builder &b, const Executable &exe):
        
        argv.push_back("-o");
        argv.push_back(exe.get_name());
-       const list<Target *> &deps=exe.get_depends();
-       for(list<Target *>::const_iterator i=deps.begin(); i!=deps.end(); ++i)
+       const TargetList &deps=exe.get_depends();
+       for(TargetList::const_iterator i=deps.begin(); i!=deps.end(); ++i)
                if(dynamic_cast<ObjectFile *>(*i))
                        argv.push_back((*i)->get_name());
 
index a35c0ed3093cf371baf8e6f43b18630c7a16b697..1e1b16cdf9149cccb4279e1f1e048c9b4835c9d1 100644 (file)
@@ -5,8 +5,9 @@
 #include <string>
 #include <msp/path/path.h>
 
+typedef std::list<std::string>     StringList;
 typedef std::list<Msp::Path::Path> PathList;
 
-std::string run_command(const std::list<std::string> &);
+std::string run_command(const StringList &);
 
 #endif
index 8fbbed1913539bbee8718fef4549a028c8483ae6..874f06925e56343c4e9e7ce5afe0911cd3a025e2 100644 (file)
@@ -21,7 +21,7 @@ ObjectFile::ObjectFile(Builder &b, const Component &c, SourceFile &src):
 
 void ObjectFile::find_depends()
 {
-       for(list<Target *>::iterator i=new_deps.begin(); i!=new_deps.end();)
+       for(TargetList::iterator i=new_deps.begin(); i!=new_deps.end();)
        {
                Target *tgt=*i;
                if(tgt->get_depends_ready())
@@ -38,7 +38,7 @@ void ObjectFile::find_depends()
 
 Action *ObjectFile::build()
 {
-       return Target::build(new Compile(builder, depends.front()->get_name(), name, comp));
+       return Target::build(new Compile(builder, *this));
 }
 
 void ObjectFile::find_depends(Target *tgt)
index d3315f7f10f1bea8f4111d78ee62cc92311f8b3f..8306aea46284ac63d668dc73ebc4dfd62274f0d3 100644 (file)
@@ -10,12 +10,13 @@ class ObjectFile: public Target
 {
 public:
        ObjectFile(Builder &, const Component &, SourceFile &);
-       const char *get_type() const { return "ObjectFile"; }
-       void find_depends();
-       Action *build();
+       const char      *get_type() const { return "ObjectFile"; }
+       const Component &get_component() const { return comp; }
+       void            find_depends();
+       Action          *build();
 private:
        const Component &comp;
-       std::list<Target *> new_deps;
+       TargetList      new_deps;
        
        void find_depends(Target *);
        void add_depend(Target *);
index d4022f5f3fae7b0f045ddea2087828d5eb987ad9..14d2321e26964229a04d68cc72716b791bc15978 100644 (file)
@@ -12,30 +12,11 @@ using namespace Msp;
 Package::Package(Builder &b, const string &n, const Path::Path &s):
        builder(b),
        name(n),
-       source(s),
        buildable(true),
+       source(s),
        build_info_ready(false)
 { }
 
-Package::Package(Builder &b, const string &n, const vector<string> &info):
-       builder(b),
-       name(n),
-       buildable(false),
-       build_info_ready(false)
-{
-       for(vector<string>::const_iterator i=info.begin(); i!=info.end(); ++i)
-       {
-               if(!i->compare(0, 2, "-I"))
-                       export_binfo.incpath.push_back(i->substr(2));
-               else if(!i->compare(0, 2, "-D"))
-                       export_binfo.defines.push_back(i->substr(2));
-               else if(!i->compare(0, 2, "-L"))
-                       export_binfo.libpath.push_back(i->substr(2));
-               else if(!i->compare(0, 2, "-l"))
-                       export_binfo.libs.push_back(i->substr(2));
-       }
-}
-
 void Package::set_path(const Msp::Path::Path &p)
 {
        path=builder.get_cwd()/p;
@@ -43,7 +24,7 @@ void Package::set_path(const Msp::Path::Path &p)
 
 void Package::resolve_refs()
 {
-       for(list<PackageRef>::iterator i=requires.begin(); i!=requires.end(); ++i)
+       for(PkgRefList::iterator i=requires.begin(); i!=requires.end(); ++i)
                i->resolve();
        for(ComponentList::iterator i=components.begin(); i!=components.end(); ++i)
                i->resolve_refs();
@@ -56,7 +37,7 @@ void Package::create_build_info()
        
        if(buildable)
        {
-               for(list<PackageRef>::iterator i=requires.begin(); i!=requires.end(); ++i)
+               for(PkgRefList::iterator i=requires.begin(); i!=requires.end(); ++i)
                {
                        Package *pkg=i->get_package();
                        if(!pkg)
@@ -156,6 +137,27 @@ Package *Package::create(Builder &b, const string &name)
        return pkg;
 }
 
+/*** private ***/
+
+Package::Package(Builder &b, const string &n, const vector<string> &info):
+       builder(b),
+       name(n),
+       buildable(false),
+       build_info_ready(false)
+{
+       for(vector<string>::const_iterator i=info.begin(); i!=info.end(); ++i)
+       {
+               if(!i->compare(0, 2, "-I"))
+                       export_binfo.incpath.push_back(i->substr(2));
+               else if(!i->compare(0, 2, "-D"))
+                       export_binfo.defines.push_back(i->substr(2));
+               else if(!i->compare(0, 2, "-L"))
+                       export_binfo.libpath.push_back(i->substr(2));
+               else if(!i->compare(0, 2, "-l"))
+                       export_binfo.libs.push_back(i->substr(2));
+       }
+}
+
 void Package::init_buildable()
 {
        buildable=true;
@@ -179,7 +181,7 @@ void Package::init_buildable()
        if(flags&DATA)
                config.add_option("includedir", "$prefix/share",   "Data installation directory");*/
 
-       for(list<PackageRef>::iterator i=requires.begin(); i!=requires.end(); ++i)
+       for(PkgRefList::iterator i=requires.begin(); i!=requires.end(); ++i)
                config.add_option(i->get_name()+"_path", "", "Path for "+i->get_name());
 
        config.load(source/".options.cache");
index a1a9859136f7f262543f232391e480e6de2e915e..743a962f52e2750c429c6bd93299208729dde8e0 100644 (file)
@@ -31,18 +31,17 @@ public:
        };
 
        Package(Builder &, const std::string &, const Msp::Path::Path &);
-       Package(Builder &, const std::string &, const std::vector<std::string> &);
        void                set_path(const Msp::Path::Path &);
-       const std::string   &get_name() const       { return name; }
-       const Msp::Path::Path &get_source() const   { return source; }
-       const ComponentList &get_components() const { return components; }
-       bool                get_buildable() const   { return buildable; }
-       const Config        &get_config() const     { return config; }
-       const std::list<PackageRef> &get_requires() const { return requires; }
-       const BuildInfo     &get_build_info() const { return build_info; }
+       const std::string   &get_name() const           { return name; }
+       const Msp::Path::Path &get_source() const       { return source; }
+       const ComponentList &get_components() const     { return components; }
+       bool                get_buildable() const       { return buildable; }
+       const Config        &get_config() const         { return config; }
+       const PkgRefList    &get_requires() const       { return requires; }
+       const BuildInfo     &get_build_info() const     { return build_info; }
        const BuildInfo     &get_exported_binfo() const { return export_binfo; }
-       Builder             &get_builder() const    { return builder; }
-       bool                get_need_path() const   { return need_path; }
+       Builder             &get_builder() const        { return builder; }
+       bool                get_need_path() const       { return need_path; }
        void                resolve_refs();
        void                create_build_info();
        void                process_options(const RawOptionMap &);
@@ -58,21 +57,25 @@ private:
        };
        
        Builder       &builder;
+       
        std::string   name;
        std::string   version;
        std::string   description;
-       std::list<PackageRef> requires;
+       
+       bool          buildable;
+       Msp::Path::Path source;
+       PkgRefList    requires;
        BuildInfo     build_info;
        BuildInfo     export_binfo;
-       Msp::Path::Path source;
-       bool          buildable;
        ComponentList components;
        Config        config;
        bool          build_info_ready;
+
        bool          need_path;
        Msp::Path::Path path;
 
-       void init_buildable();
+       Package(Builder &, const std::string &, const std::vector<std::string> &);
+       void    init_buildable();
        unsigned get_install_flags();
 };
 
index bc44da3000f121d539bb3f2731031b06ef0c042d..9698b1e14e0ee4f222c0f7dc79f81b80dd5f1de9 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef PACKAGEREF_H_
 #define PACKAGEREF_H_
 
+#include <list>
 #include <string>
 
 class Builder;
@@ -18,5 +19,6 @@ private:
        std::string name;
        Package     *package;
 };
+typedef std::list<PackageRef> PkgRefList;
 
 #endif
index b1ec8294f578d796ab85f61cb83ea804ebe50b55..0bca39055fede799a16eca2c970b1963991fc9df 100644 (file)
@@ -9,13 +9,13 @@ class SourceFile: public Target
 {
 public:
        SourceFile(Builder &, const Component *, const std::string &);
-       const std::list<std::string> &get_includes() const { return includes; }
-       const char *get_type() const { return "SourceFile"; }
-       void find_depends();
-       Action *build() { rebuild=false; return 0; }
+       const StringList &get_includes() const { return includes; }
+       const char       *get_type() const { return "SourceFile"; }
+       void             find_depends();
+       Action           *build() { return 0; }
 private:
        const Component *comp;
-       std::list<std::string> includes;
+       StringList      includes;
 };
 
 #endif
index f7f178a7306c5649f049be7c5d6002092d07d9a4..0d1242f31d96825dd198b4ed23027202d92c1b35 100644 (file)
@@ -10,9 +10,9 @@ class StaticLibrary: public Target
 {
 public:
        StaticLibrary(Builder &, const Component &, const std::list<ObjectFile *> &);
-       const char *get_type() const { return "StaticLibrary"; }
+       const char      *get_type() const      { return "StaticLibrary"; }
        const Component &get_component() const { return comp; }
-       Action *build();
+       Action          *build();
 private:
        const Component &comp;
 
index d55202289dfd026fb1893a3c83abd8f1cd34f670..e03428837838afdbd78447862075f4db66d082b6 100644 (file)
@@ -11,7 +11,7 @@ using namespace Msp;
 Target *Target::get_buildable_target()
 {
        bool self_ok=true;
-       for(list<Target *>::iterator i=depends.begin(); i!=depends.end(); ++i)
+       for(TargetList::iterator i=depends.begin(); i!=depends.end(); ++i)
        {
                Target *tgt=(*i)->get_buildable_target();
                if(tgt)
@@ -37,7 +37,7 @@ void Target::prepare()
        if(prepared)
                return;
 
-       for(list<Target *>::iterator i=depends.begin(); i!=depends.end(); ++i)
+       for(TargetList::iterator i=depends.begin(); i!=depends.end(); ++i)
                (*i)->prepare();
 
        check_rebuild();
@@ -50,7 +50,7 @@ unsigned Target::count_rebuild()
 
        counted=true;
        unsigned count=rebuild;
-       for(list<Target *>::iterator i=depends.begin(); i!=depends.end(); ++i)
+       for(TargetList::iterator i=depends.begin(); i!=depends.end(); ++i)
                count+=(*i)->count_rebuild();
        return count;
 }
@@ -64,11 +64,11 @@ Target::Target(Builder &b, const Package *p, const string &n):
        builder(b),
        package(p),
        name(n),
+       buildable(false),
        building(false),
        rebuild(false),
        deps_ready(false),
        prepared(false),
-       buildable(false),
        counted(false)
 {
        struct stat st;
@@ -93,7 +93,7 @@ void Target::check_rebuild()
                mark_rebuild("Does not exist");
        else
        {
-               for(list<Target *>::iterator i=depends.begin(); (i!=depends.end() && !rebuild); ++i)
+               for(TargetList::iterator i=depends.begin(); (i!=depends.end() && !rebuild); ++i)
                {
                        if((*i)->get_mtime()>mtime)
                                mark_rebuild(Path::basename((*i)->get_name())+" has changed");
index 890f123e2095855036e11655df664fec767ef293..eb46d9fe7116125798f4e7920baf71f5c87c8260 100644 (file)
@@ -9,45 +9,51 @@ class Action;
 class Builder;
 class Package;
 
+class Target;
+typedef std::list<Target *> TargetList;
+
 class Target
 {
 public:
-       const std::string &get_name() const            { return name; }
-       Target            *get_buildable_target();
-       bool              get_rebuild() const          { return rebuild; }
-       const std::string &get_rebuild_reason() const  { return rebuild_reason; }
+       const std::string  &get_name() const           { return name; }
+       Target             *get_buildable_target();
+       bool               get_rebuild() const         { return rebuild; }
+       const std::string  &get_rebuild_reason() const { return rebuild_reason; }
        const Msp::Time::TimeStamp &get_mtime() const  { return mtime; }
        virtual const char *get_type() const=0;
-       const std::list<Target *> &get_depends() const { return depends; }
-       const Package     *get_package() const         { return package; }
-       bool              get_depends_ready() const       { return deps_ready; }
-       void              add_depend(Target *);
-       virtual void      find_depends()               { deps_ready=true; }
-       virtual void      prepare();
-       virtual Action    *build()=0;
-       void              reset_count()                { counted=false; }
-       virtual unsigned  count_rebuild();
-       void              touch();
+       const TargetList   &get_depends() const        { return depends; }
+       const Package      *get_package() const        { return package; }
+       bool               get_depends_ready() const   { return deps_ready; }
+       void               add_depend(Target *);
+       virtual void       find_depends()              { deps_ready=true; }
+       virtual void       prepare();
+       virtual Action     *build()=0;
+       void               reset_count()               { counted=false; }
+       virtual unsigned   count_rebuild();
+       void               touch();
        virtual ~Target() { }
 protected:
-       Builder     &builder;
+       Builder       &builder;
        const Package *package;
-       std::string name;
-       bool        building;
-       bool        rebuild;
-       std::string rebuild_reason;
+       std::string   name;
        Msp::Time::TimeStamp mtime;
-       std::list<Target *> depends;
-       std::list<Target *> rdepends;
-       bool        deps_ready;
-       bool        prepared;
-       bool        buildable;
-       bool        counted;
+
+       bool          buildable;
+       bool          building;
+       bool          rebuild;
+       std::string   rebuild_reason;
+
+       TargetList    depends;
+       TargetList    rdepends;
+       bool          deps_ready;
+
+       bool          prepared;
+       bool          counted;
 
        Target(Builder &, const Package *, const std::string &);
-       void mark_rebuild(const std::string &);
+       void         mark_rebuild(const std::string &);
        virtual void check_rebuild();
-       Action *build(Action *);
+       Action       *build(Action *);
        virtual void build_done();
 };
 
index e44eecc5828b99b4e230d4c3c29692fdafedc112..074647abfe75a1e4aa3b339bd8b57388487f798b 100644 (file)
@@ -5,7 +5,7 @@ using namespace std;
 
 void VirtualTarget::check_rebuild()
 {
-       for(list<Target *>::iterator i=depends.begin(); (i!=depends.end() && !rebuild); ++i)
+       for(TargetList::iterator i=depends.begin(); (i!=depends.end() && !rebuild); ++i)
                if((*i)->get_rebuild())
                        mark_rebuild(Msp::Path::basename((*i)->get_name())+" needs rebuilding");
 }
index 4f064ba819a3c2127005af29f91219878fade55c..baccfa63ca536c93005a0ceb91da373f7bb4b44d 100644 (file)
@@ -8,8 +8,8 @@ class VirtualTarget: public Target
 public:
        VirtualTarget(Builder &b, const std::string &n): Target(b,0,n) { }
        const char *get_type() const { return "VirtualTarget"; }
-       Action *build() { rebuild=false; return 0; }
-       unsigned count_rebuild();
+       Action     *build()          { rebuild=false; return 0; }
+       unsigned   count_rebuild();
 private:
        void check_rebuild();
 };