]> git.tdb.fi Git - builder.git/commitdiff
Implement --build-all
authorMikko Rasa <tdb@tdb.fi>
Wed, 18 Oct 2006 10:24:25 +0000 (10:24 +0000)
committerMikko Rasa <tdb@tdb.fi>
Wed, 18 Oct 2006 10:24:25 +0000 (10:24 +0000)
Don't count virtual targets when reporting the number of targets to be built
Make the Copy action behave correctly in a dry run
Report the number of out-of-date targets per package with --verbose

source/action.cpp
source/builder.cpp
source/builder.h
source/copy.cpp
source/target.cpp
source/target.h
source/virtualtarget.cpp
source/virtualtarget.h

index 7ed0da1efc0b9c0c12d0d199835adbb83fac9228..9ec8087d4b2ffd6200008413d260f998831a5036 100644 (file)
@@ -9,7 +9,7 @@ void Action::announce(const string &pkg, const string &tool, const string &tgt)
 {
        ostringstream line;
        line<<left;
-       line<<'['<<setw(10)<<pkg<<"] ";
+       line<<'['<<setw(10)<<pkg.substr(0, 10)<<"] ";
        line<<'['<<setw(4)<<tool<<"] ";
        line<<tgt;
        cout<<line.str()<<'\n';
index 11f2b1a0e32a307ab899cd10352e8607a920e7b3..e9491eb8a9bc417c350b6b2f55a378b69bffa7b0 100644 (file)
@@ -78,18 +78,15 @@ Builder::Builder(int argc, char **argv):
        }
 
        dry_run=getopt['n'];
-
        jobs=max(strtol(getopt['j'].arg()), 1L);
-
        chrome=getopt["chrome"];
-
        conf_all=getopt['A'];
+       build_file=getopt['f'].arg();
+       build_all=getopt['B'];
 
        if(getopt['C'])
                chdir(getopt['C'].arg().c_str());
 
-       build_file=getopt['f'].arg();
-
        for(int i=index; i<argc; ++i)
        {
                string v(argv[i]);
@@ -276,10 +273,21 @@ int Builder::main()
                        if(i->second->get_buildable())
                                cout<<'*';
                        unsigned count=0;
+                       unsigned ood_count=0;
                        for(TargetMap::iterator j=targets.begin(); j!=targets.end(); ++j)
                                if(j->second->get_package()==i->second)
+                               {
                                        ++count;
-                       cout<<" ("<<count<<" targets)\n";
+                                       if(j->second->get_rebuild())
+                                               ++ood_count;
+                               }
+                       if(count)
+                       {
+                               cout<<" ("<<count<<" targets";
+                               if(ood_count)
+                                       cout<<", "<<ood_count<<" out-of-date";
+                               cout<<")\n";
+                       }
                }
        }
 
index 400be8a5de392fb0d37ad54db5e55b7db9650001..077d7e3cf7de6e8b914081fd8dad9cf484199098 100644 (file)
@@ -19,6 +19,7 @@ public:
        Builder(int, char **);
        unsigned get_verbose() const { return verbose; }
        bool     get_dry_run() const { return dry_run; }
+       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> &);
@@ -64,6 +65,7 @@ private:
        std::list<std::string> what_if;
        bool        chrome;
        bool        conf_all;
+       bool        build_all;
 
        int load_build_file(const Msp::Path::Path &);
        int create_targets();
index 8d18ec8001279403bc827926da8203e507671f28..0607b5de5b0d59c0bb3c285f9e0e48fee48eb80c 100644 (file)
@@ -26,7 +26,10 @@ Copy::Copy(Builder &b, const Package &pkg, const Path::Path &s, const Path::Path
 int Copy::check()
 {
        if(!worker)
+       {
+               signal_done.emit();
                return 0;
+       }
        
        if(worker->get_done())
        {
index 04d9260514a8de701e2dd1380313c3215a6b7151..d55202289dfd026fb1893a3c83abd8f1cd34f670 100644 (file)
@@ -87,7 +87,9 @@ void Target::check_rebuild()
        if(!buildable)
                return;
 
-       if(!mtime)
+       if(builder.get_build_all())
+               mark_rebuild("Rebuilding everything");
+       else if(!mtime)
                mark_rebuild("Does not exist");
        else
        {
index ab9134aff85c2b4e34ab4c9eacd719c4e8ccc06d..890f123e2095855036e11655df664fec767ef293 100644 (file)
@@ -26,7 +26,7 @@ public:
        virtual void      prepare();
        virtual Action    *build()=0;
        void              reset_count()                { counted=false; }
-       unsigned          count_rebuild();
+       virtual unsigned  count_rebuild();
        void              touch();
        virtual ~Target() { }
 protected:
index d3f80df2c762812a5bbfe06245a6215c32c51504..e44eecc5828b99b4e230d4c3c29692fdafedc112 100644 (file)
@@ -9,3 +9,8 @@ void VirtualTarget::check_rebuild()
                if((*i)->get_rebuild())
                        mark_rebuild(Msp::Path::basename((*i)->get_name())+" needs rebuilding");
 }
+
+unsigned VirtualTarget::count_rebuild()
+{
+       return Target::count_rebuild()-rebuild;
+}
index 5cd62f2266f11a082b739334d19df72068dec8e6..4f064ba819a3c2127005af29f91219878fade55c 100644 (file)
@@ -9,6 +9,7 @@ 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();
 private:
        void check_rebuild();
 };