]> git.tdb.fi Git - builder.git/blobdiff - source/builder.cpp
Allow doing clean and build in the same run
[builder.git] / source / builder.cpp
index e45e696a0e4f6e62a67496147b4295502e15473a..665983100894acad49db12d8eb478055713c9ad8 100644 (file)
@@ -68,7 +68,7 @@ Builder::Builder(int argc, char **argv):
 
        GetOpt getopt;
        getopt.add_option('a', "analyze",    analyze_mode,  GetOpt::REQUIRED_ARG).set_help("Perform dependency analysis.", "MODE");
-       getopt.add_option('b', "build",      build,         GetOpt::NO_ARG).set_help("Perform build even if doing analysis.");
+       getopt.add_option('b', "build",      build,         GetOpt::NO_ARG).set_help("Perform build even if also doing something else.");
        getopt.add_option('c', "clean",      clean,         GetOpt::NO_ARG).set_help("Clean buildable targets.");
        getopt.add_option('f', "file",       build_file,    GetOpt::REQUIRED_ARG).set_help("Read build instructions from FILE.", "FILE");
        getopt.add_option('h', "help",       help,          GetOpt::NO_ARG).set_help("Print this message.");
@@ -108,20 +108,10 @@ Builder::Builder(int argc, char **argv):
                logger.enable_channel("commands");
        }
        if(verbose>=3)
-       {
-               logger.enable_channel("packagemgr");
-               logger.enable_channel("configure");
-       }
-       if(verbose>=4)
        {
                logger.enable_channel("files");
                logger.enable_channel("auxcommands");
        }
-       if(verbose>=5)
-       {
-               logger.enable_channel("tools");
-               logger.enable_channel("vfs");
-       }
        for(list<string>::const_iterator i=log_channels.begin(); i!=log_channels.end(); ++i)
        {
                vector<string> parts = split(*i, ',');
@@ -307,7 +297,7 @@ int Builder::main()
 
        if(clean)
                exit_code = do_clean();
-       else if(build)
+       if(build)
                exit_code = do_build();
 
        return exit_code;
@@ -560,9 +550,11 @@ int Builder::do_clean()
        }
 
        for(set<Target *>::iterator i=clean_tgts.begin(); i!=clean_tgts.end(); ++i)
-               if(FileTarget *ft = dynamic_cast<FileTarget *>(*i))
-                       if(ft->get_mtime())
-                               FS::unlink(ft->get_path());
+       {
+               logger.log("tasks", format("RM    %s", (*i)->get_name()));
+               if(!dry_run)
+                       (*i)->clean();
+       }
 
        return 0;
 }