]> git.tdb.fi Git - builder.git/commitdiff
Use mspio for all I/O operations
authorMikko Rasa <tdb@tdb.fi>
Thu, 7 May 2009 06:08:09 +0000 (06:08 +0000)
committerMikko Rasa <tdb@tdb.fi>
Thu, 7 May 2009 06:08:09 +0000 (06:08 +0000)
Use GetOpt to generate help messages for options
Make --help work even if there's no package in cwd

14 files changed:
source/action.cpp
source/analyzer.cpp
source/binarypackage.cpp
source/builder.cpp
source/builder.h
source/component.cpp
source/copy.cpp
source/externalaction.cpp
source/misc.cpp
source/package.cpp
source/pkgconfigaction.cpp
source/sourcefile.cpp
source/sourcepackage.cpp
source/tar.cpp

index 31b13906acee48a3c493e25efc9e2e7aa9a0f30b..72c14a79ae2ac998496e824a9f05f14afa79cb5f 100644 (file)
@@ -5,19 +5,13 @@ Copyright © 2006-2007, 2009  Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
-#include <iomanip>
-#include <iostream>
-#include <sstream>
+#include <msp/io/print.h>
 #include "action.h"
 
+using namespace Msp;
 using namespace std;
 
 void Action::announce(const string &pkg, const string &tool, const string &tgt)
 {
-       ostringstream line;
-       line<<left;
-       line<<'['<<setw(10)<<pkg.substr(0, 10)<<"] ";
-       line<<'['<<setw(4)<<tool<<"] ";
-       line<<tgt;
-       cout<<line.str()<<'\n';
+       IO::print("[%-10s] [%4s] %s\n", pkg.substr(0, 10), tool, tgt);
 }
index 6664477598d653aa3d4a05950a08c62a808e6a42..7d120792591b41b7695e5de93bdbbe34a844e5b7 100644 (file)
@@ -5,10 +5,8 @@ Copyright © 2006-2009  Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
-#include <iomanip>
-#include <iostream>
-#include <sstream>
 #include <msp/fs/utils.h>
+#include <msp/io/print.h>
 #include "analyzer.h"
 #include "builder.h"
 #include "install.h"
@@ -108,15 +106,14 @@ void Analyzer::print_table() const
 
        for(Table::const_iterator i=table.begin(); i!=table.end(); ++i)
        {
-               ostringstream ss;
-               ss<<left;
+               string line;
                for(unsigned j=0; j<i->size(); ++j)
                {
                        if(j>0)
-                               ss<<"  ";
-                       ss<<setw(col_width[j])<<(*i)[j];
+                               line+="  ";
+                       line+=lexical_cast((*i)[j], Fmt("%-s").width(col_width[j]));
                }
-               cout<<ss.str()<<'\n';
+               IO::print("%s\n", line);
        }
 }
 
index e1dc9dfd5177bf98c60a21933fb7fdb941e437ec..4589e2440337e7a5095bea223f5b1004be7a8abc 100644 (file)
@@ -5,7 +5,7 @@ Copyright © 2007-2009  Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
-#include <iostream>
+#include <msp/io/print.h>
 #include <msp/strings/utils.h>
 #include "binarypackage.h"
 #include "builder.h"
@@ -45,7 +45,7 @@ BinaryPackage *BinaryPackage::from_pkgconfig(Builder &builder, const string &nam
        argv.push_back("--libs");
        argv.push_back(name);
        if(builder.get_verbose()>=4)
-               cout<<"Running "<<join(argv.begin(), argv.end())<<'\n';
+               IO::print("Running %s\n", join(argv.begin(), argv.end()));
        string info=run_command(argv);
 
        if(info.empty())
index cf335c1a93a6c0f7248e20b2f46cb19d3c4efafb..de8375919e17678de591cdff9452cc36bf25057e 100644 (file)
@@ -5,7 +5,6 @@ Copyright © 2006-2009  Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
-#include <iostream>
 #include <set>
 #include <sys/utsname.h>
 #include <msp/core/except.h>
@@ -17,6 +16,7 @@ Distributed under the LGPL
 #include <msp/io/buffered.h>
 #include <msp/io/except.h>
 #include <msp/io/file.h>
+#include <msp/io/print.h>
 #include <msp/strings/formatter.h>
 #include <msp/strings/regex.h>
 #include <msp/strings/utils.h>
@@ -77,26 +77,27 @@ Builder::Builder(int argc, char **argv):
        string arch;
 
        GetOpt getopt;
-       getopt.add_option('a', "analyze",    analyze_mode, GetOpt::REQUIRED_ARG);
-       getopt.add_option('b', "build",      build,        GetOpt::NO_ARG);
-       getopt.add_option('c', "clean",      clean,        GetOpt::NO_ARG);
-       getopt.add_option('f', "file",       build_file,   GetOpt::REQUIRED_ARG);
-       getopt.add_option('h', "help",       help,         GetOpt::NO_ARG);
-       getopt.add_option('j', "jobs",       jobs,         GetOpt::REQUIRED_ARG);
-       getopt.add_option('n', "dry-run",    dry_run,      GetOpt::NO_ARG);
-       getopt.add_option('v', "verbose",    verbose,      GetOpt::NO_ARG);
-       getopt.add_option('A', "conf-all",   conf_all,     GetOpt::NO_ARG);
-       getopt.add_option('B', "build-all",  build_all,    GetOpt::NO_ARG);
-       getopt.add_option('C', "chdir",      work_dir,     GetOpt::REQUIRED_ARG);
-       getopt.add_option('P', "progress",   show_progress, GetOpt::NO_ARG);
-       getopt.add_option('W', "what-if",    what_if,      GetOpt::REQUIRED_ARG);
-       getopt.add_option(     "arch",       arch,         GetOpt::REQUIRED_ARG);
-       getopt.add_option(     "conf-only",  conf_only,    GetOpt::NO_ARG);
-       getopt.add_option(     "full-paths", full_paths,   GetOpt::NO_ARG);
-       //getopt.add_option(     "makefile",   create_makefile, GetOpt::NO_ARG);
-       getopt.add_option(     "max-depth",  max_depth,    GetOpt::REQUIRED_ARG);
-       getopt.add_option(     "prefix",     prfx,         GetOpt::REQUIRED_ARG);
-       getopt.add_option(     "warnings",   cmdline_warn, GetOpt::REQUIRED_ARG);
+       getopt.add_option('a', "analyze",    analyze_mode,  GetOpt::REQUIRED_ARG).set_help("Perform analysis.  MODE can be deps, alldeps or rebuild.", "MODE");
+       getopt.add_option('b', "build",      build,         GetOpt::NO_ARG).set_help("Perform build even if doing analysis.");
+       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 info from FILE instead of Build.", "FILE");
+       getopt.add_option('h', "help",       help,          GetOpt::NO_ARG).set_help("Print this message.");
+       getopt.add_option('j', "jobs",       jobs,          GetOpt::REQUIRED_ARG).set_help("Run NUM commands at once, whenever possible.", "NUM");
+       getopt.add_option('n', "dry-run",    dry_run,       GetOpt::NO_ARG).set_help("Don't actually do anything, only show what would be done.");
+       getopt.add_option('v', "verbose",    verbose,       GetOpt::NO_ARG).set_help("Print more information about what's going on.");
+       getopt.add_option('A', "conf-all",   conf_all,      GetOpt::NO_ARG).set_help("Apply configuration to all packages.");
+       getopt.add_option('B', "build-all",  build_all,     GetOpt::NO_ARG).set_help("Build all targets unconditionally.");
+       getopt.add_option('C', "chdir",      work_dir,      GetOpt::REQUIRED_ARG).set_help("Change to DIR before doing anything else.", "DIR");
+       getopt.add_option('P', "progress",   show_progress, GetOpt::NO_ARG).set_help("Display progress while building.");
+       getopt.add_option('W', "what-if",    what_if,       GetOpt::REQUIRED_ARG).set_help("Pretend that FILE has changed.", "FILE");
+       getopt.add_option(     "arch",       arch,          GetOpt::REQUIRED_ARG).set_help("Architecture to build for.", "ARCH");
+       getopt.add_option(     "conf-only",  conf_only,     GetOpt::NO_ARG).set_help("Stop after configuring packages.");
+       getopt.add_option(     "full-paths", full_paths,    GetOpt::NO_ARG).set_help("Output full paths in analysis.");
+       getopt.add_option(     "max-depth",  max_depth,     GetOpt::REQUIRED_ARG).set_help("Maximum depth to show in analysis.", "NUM");
+       getopt.add_option(     "prefix",     prfx,          GetOpt::REQUIRED_ARG).set_help("Directory to install things to.", "DIR");
+       getopt.add_option(     "warnings",   cmdline_warn,  GetOpt::REQUIRED_ARG).set_help("Compiler warnings to use.", "LIST");
+       usagemsg=getopt.generate_usage(argv[0])+" [<target> ...]";
+       helpmsg=getopt.generate_help();
        getopt(argc, argv);
 
        if(!analyze_mode.empty())
@@ -196,8 +197,16 @@ int Builder::main()
 {
        if(load_build_file(cwd/build_file))
        {
-               cerr<<"No build info here.\n";
-               return 1;
+               if(help)
+               {
+                       usage(0, "builder", false);
+                       return 0;
+               }
+               else
+               {
+                       IO::print(IO::cerr, "No build info here.\n");
+                       return 1;
+               }
        }
 
        main_pkg->configure(cmdline_options, conf_all?2:1);
@@ -205,7 +214,7 @@ int Builder::main()
        if(help)
        {
                usage(0, "builder", false);
-               cout<<'\n';
+               IO::print("\n");
                package_help();
                return 0;
        }
@@ -219,16 +228,16 @@ int Builder::main()
                return 0;
 
        if(verbose>=2)
-               cout<<"Building on "<<native_arch->get_name()<<", for "<<current_arch->get_name()<<'\n';
+               IO::print("Building on %s, for %s\n", native_arch->get_name(), current_arch->get_name());
        if(verbose>=1)
-               cout<<all_reqs.size()<<" active packages, "<<targets.size()<<" targets\n";
+               IO::print("%d active packages, %d targets\n", all_reqs.size(), targets.size());
        if(verbose>=2)
        {
                for(PackageList::const_iterator i=all_reqs.begin(); i!=all_reqs.end(); ++i)
                {
-                       cout<<' '<<(*i)->get_name();
+                       IO::print(" %s", (*i)->get_name());
                        if(dynamic_cast<SourcePackage *>(*i))
-                               cout<<'*';
+                               IO::print("*");
                        unsigned count=0;
                        unsigned ood_count=0;
                        for(TargetMap::iterator j=targets.begin(); j!=targets.end(); ++j)
@@ -240,12 +249,12 @@ int Builder::main()
                                }
                        if(count)
                        {
-                               cout<<" ("<<count<<" targets";
+                               IO::print(" (%d targets", count);
                                if(ood_count)
-                                       cout<<", "<<ood_count<<" out-of-date";
-                               cout<<')';
+                                       IO::print(", %d out-of-date", ood_count);
+                               IO::print(")");
                        }
-                       cout<<'\n';
+                       IO::print("\n");
                }
        }
 
@@ -254,10 +263,10 @@ int Builder::main()
 
        if(!problems.empty())
        {
-               cerr<<"The following problems were detected:\n";
+               IO::print(IO::cerr, "The following problems were detected:\n");
                for(ProblemList::iterator i=problems.begin(); i!=problems.end(); ++i)
-                       cerr<<"  "<<i->package<<": "<<i->descr<<'\n';
-               cerr<<"Please fix them and try again.\n";
+                       IO::print(IO::cerr, "  %s: %s\n", i->package, i->descr);
+               IO::print(IO::cerr, "Please fix them and try again.\n");
                return 1;
        }
 
@@ -335,12 +344,12 @@ Target *Builder::get_header(const string &include, const FS::Path &from, const l
                        cxx_ver.erase(dot);
                }
                if(verbose>=5)
-                       cout<<"C++ version is "<<cxx_ver<<'\n';
+                       IO::print("C++ version is %s\n", cxx_ver);
        }
 
        string fn=include.substr(1);
        if(verbose>=5)
-               cout<<"Looking for include "<<fn<<" from "<<from<<" with path "<<join(path.begin(), path.end())<<'\n';
+               IO::print("Looking for include %s from %s with path %s\n", fn, from, join(path.begin(), path.end()));
 
        StringList syspath;
        if(current_arch->is_native())
@@ -383,7 +392,7 @@ Target *Builder::get_library(const string &lib, const list<string> &path, LibMod
                syspath.push_back("/usr/"+current_arch->get_prefix()+"/lib");
 
        if(verbose>=5)
-               cout<<"Looking for library "<<lib<<" with path "<<join(path.begin(), path.end())<<'\n';
+               IO::print("Looking for library %s with path %s\n", lib, join(path.begin(), path.end()));
 
        Target *tgt=0;
        for(StringList::const_iterator j=path.begin(); (!tgt && j!=path.end()); ++j)
@@ -433,43 +442,22 @@ void Builder::add_target(Target *t)
 void Builder::usage(const char *reason, const char *argv0, bool brief)
 {
        if(reason)
-               cerr<<reason<<'\n';
+               IO::print(IO::cerr, "%s\n", reason);
 
        if(brief)
-               cerr<<"Usage: "<<argv0<<" [-a|--analyze MODE] [-b|--build] [-c|--clean] [-f|--file FILE] [-h|--help] [-j|--jobs NUM] [-n||--dry-run] [-v|--verbose] [-A|--conf-all] [-B|--build-all] [-C|--chdir DIRECTORY] [-W|--what-if FILE] [--chrome] [--conf-only] [--full-paths] [--max-depth NUM] [<target> ...]\n";
+               IO::print(IO::cerr, "Usage: %s\n", usagemsg);
        else
        {
-               cerr<<
-                       "Usage: "<<argv0<<" [options] [<target> ...]\n"
-                       "\n"
-                       "Options:\n"
-                       "  -a, --analyze MODE  Perform analysis.  MODE can be deps, alldeps or rebuild.\n"
-                       "  -b, --build         Perform build even if doing analysis.\n"
-                       "  -c, --clean         Clean buildable targets.\n"
-                       "  -f, --file FILE     Read info from FILE instead of Build.\n"
-                       "  -h, --help          Print this message.\n"
-                       "  -j, --jobs NUM      Run NUM commands at once, whenever possible.\n"
-                       "  -n, --dry-run       Don't actually do anything, only show what would be done.\n"
-                       "  -v, --verbose       Print more information about what's going on.\n"
-                       "  -A, --conf-all      Apply configuration to all packages.\n"
-                       "  -B, --build-all     Build all targets unconditionally.\n"
-                       "  -C, --chdir DIR     Change to DIR before doing anything else.\n"
-                       "  -P, --progress      Display progress while building.\n"
-                       "  -W, --what-if FILE  Pretend that FILE has changed.\n"
-                       "  --arch ARCH         Architecture to build for.\n"
-                       "  --conf-only         Stop after configuring packages.\n"
-                       "  --full-paths        Output full paths in analysis.\n"
-                       //"  --makefile          Create a makefile for this package.\n"
-                       "  --max-depth NUM     Maximum depth to show in analysis.\n"
-                       "  --prefix DIR        Directory to install things to.\n"
-                       "  --warnings LIST     Compiler warnings to use.\n";
+               IO::print(IO::cerr, "Usage: %s [options] [<target> ...]\n\n", argv0);
+               IO::print(IO::cerr, "Options:\n");
+               IO::print(IO::cerr, helpmsg);
        }
 }
 
 FS::Path Builder::get_package_location(const string &name)
 {
        if(verbose>=3)
-               cout<<"Looking for package "<<name<<'\n';
+               IO::print("Looking for package %s\n", name);
 
        // Try to get source directory with pkgconfig
        list<string> argv;
@@ -477,7 +465,7 @@ FS::Path Builder::get_package_location(const string &name)
        argv.push_back("--variable=source");
        argv.push_back(name);
        if(verbose>=4)
-               cout<<"Running "<<join(argv.begin(), argv.end())<<'\n';
+               IO::print("Running %s\n", join(argv.begin(), argv.end()));
        string srcdir=strip(run_command(argv));
        if(!srcdir.empty())
                return srcdir;
@@ -495,7 +483,7 @@ FS::Path Builder::get_package_location(const string &name)
                        }
                }
                if(verbose>=3)
-                       cout<<pkg_dirs.size()<<" packages found in path\n";
+                       IO::print("%d packages found in path\n", pkg_dirs.size());
        }
 
        bool msp=!name.compare(0, 3, "msp");
@@ -520,7 +508,7 @@ int Builder::load_build_file(const FS::Path &fn)
                IO::BufferedFile in(fn.str());
 
                if(verbose>=3)
-                       cout<<"Reading "<<fn<<'\n';
+                       IO::print("Reading %s\n", fn);
 
                DataFile::Parser parser(in, fn.str());
                Loader loader(*this, fn.subpath(0, fn.size()-1));
@@ -583,7 +571,7 @@ int Builder::create_targets()
                Target *tgt=get_target((cwd/ *i).str());
                if(!tgt)
                {
-                       cerr<<"Unknown what-if target "<<*i<<'\n';
+                       IO::print(IO::cerr, "Unknown what-if target %s\n", *i);
                        return -1;
                }
                tgt->touch();
@@ -599,7 +587,7 @@ int Builder::create_targets()
                        tgt=get_target((cwd/ *i).str());
                if(!tgt)
                {
-                       cerr<<"I don't know anything about "<<*i<<'\n';
+                       IO::print("I don't know anything about %s\n", *i);
                        return -1;
                }
                if(tgt==world)
@@ -697,11 +685,11 @@ int Builder::do_build()
        unsigned total=cmdline->count_rebuild();
        if(!total)
        {
-               cout<<"Already up to date\n";
+               IO::print("Already up to date\n");
                return 0;
        }
        if(verbose>=1)
-               cout<<"Will build "<<total<<" target(s)\n";
+               IO::print("Will build %d target%s\n", total, (total!=1 ? "s" : ""));
 
        vector<Action *> actions;
 
@@ -722,10 +710,7 @@ int Builder::do_build()
                                        actions.push_back(action);
 
                                if(show_progress)
-                               {
-                                       cout<<count<<" of "<<total<<" targets built\033[1G";
-                                       cout.flush();
-                               }
+                                       IO::print("%d of %d target%s built\033[1G", count, total, (total!=1 ? "s" : ""));
                        }
                        else if(actions.empty())
                                finish=true;
@@ -753,13 +738,13 @@ int Builder::do_build()
        }
 
        if(show_progress)
-               cout<<"\033[K";
+               IO::print("\033[K");
        if(fail)
-               cout<<"Build failed\n";
+               IO::print("Build failed\n");
        else if(show_progress)
-               cout<<"Build complete\n";
+               IO::print("Build complete\n");
 
-       return fail?1:0;
+       return fail;
 }
 
 int Builder::do_clean()
@@ -800,24 +785,28 @@ void Builder::package_help()
        const Config &config=main_pkg->get_config();
        const Config::OptionMap &options=config.get_options();
 
-       cout<<"Required packages:\n  ";
+       IO::print("Required packages:\n  ");
        const PackageList &requires=main_pkg->get_requires();
        for(PackageList::const_iterator i=requires.begin(); i!=requires.end(); ++i)
        {
                if(i!=requires.begin())
-                       cout<<", ";
-               cout<<(*i)->get_name();
+                       IO::print(", ");
+               IO::print((*i)->get_name());
        }
-       cout<<"\n\n";
-       cout<<"Package configuration:\n";
+       IO::print("\n\nPackage configuration:\n");
        for(Config::OptionMap::const_iterator i=options.begin(); i!=options.end(); ++i)
        {
                const Config::Option &opt=i->second;
-               cout<<"  "<<opt.name<<": "<<opt.descr<<" ("<<opt.value<<") ["<<opt.defv<<"]\n";
+               IO::print("  %s: %s (%s)", opt.name, opt.descr, opt.value);
+               if(opt.value!=opt.defv)
+                       IO::print(" [%s]", opt.defv);
+               IO::print("\n");
        }
 }
 
 Application::RegApp<Builder> Builder::reg;
+string Builder::usagemsg;
+string Builder::helpmsg;
 
 
 Builder::Loader::Loader(Builder &b, const FS::Path &s):
index 0ebf2df1eb0ddada01c1651bc4baeb44045d2b95..81f5f13678be09d432d46ae53d2bb785357285ac 100644 (file)
@@ -99,6 +99,8 @@ private:
        StringList warnings;
 
        static Msp::Application::RegApp<Builder> reg;
+       static std::string usagemsg;
+       static std::string helpmsg;
 
 public:
        Builder(int, char **);
index 338b44f43c0e83c10ebd62133533d7bf2b642db0..6bef63651d9ec88f42fbe639010bc9a7935cc73b 100644 (file)
@@ -5,11 +5,11 @@ Copyright © 2006-2009  Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
-#include <iostream>
 #include <msp/core/except.h>
 #include <msp/fs/dir.h>
 #include <msp/fs/stat.h>
 #include <msp/fs/utils.h>
+#include <msp/io/print.h>
 #include <msp/strings/lexicalcast.h>
 #include "builder.h"
 #include "component.h"
@@ -230,7 +230,7 @@ void Component::Loader::host(const string &n)
 
 void Component::Loader::install_headers(const string &p)
 {
-       cout<<get_source()<<": Note: install_headers is deprecated\n";
+       IO::print("%s: Note: install_headers is deprecated\n", get_source());
        if(comp.type==HEADERS)
        {
                comp.name=p;
index 483b9261d9f87af53be9e085ecc7cb6ef474288d..4cb42b707be686f59bd2725f089272f63b4e07d4 100644 (file)
@@ -6,11 +6,11 @@ Distributed under the LGPL
 */
 
 #include <errno.h>
-#include <iostream>
 #include <msp/fs/dir.h>
 #include <msp/fs/stat.h>
 #include <msp/fs/utils.h>
 #include <msp/io/file.h>
+#include <msp/io/print.h>
 #include "builder.h"
 #include "copy.h"
 #include "package.h"
@@ -25,7 +25,7 @@ Copy::Copy(Builder &b, const Package &pkg, const FS::Path &s, const FS::Path &d)
 {
        announce(pkg.get_name(), "COPY", dest[-1]);
        if(builder.get_verbose()>=2)
-               cout<<s<<" -> "<<d<<'\n';
+               IO::print("%s -> %s\n", s, d);
 
        if(!builder.get_dry_run())
                worker=new Worker(*this);
@@ -51,7 +51,7 @@ void Copy::Worker::main()
        {
                if(e.get_error_code()!=ENOENT)
                {
-                       cerr<<e.what()<<'\n';
+                       IO::print(IO::cerr, "%s\n", e.what());
                        done=error=true;
                        return;
                }
@@ -72,7 +72,7 @@ void Copy::Worker::main()
        }
        catch(const Exception &e)
        {
-               cerr<<e.what()<<'\n';
+               IO::print(IO::cerr, "%s\n", e.what());
                done=error=true;
                return;
        }
index 88c7e544e7907671daa82a6d8381f29f46257356..7e0a23de5021bcd7f3211fe201e7f85169727106 100644 (file)
@@ -5,11 +5,12 @@ Copyright © 2006-2009  Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
-#include <sys/wait.h>
-#include <iostream>
 #include <cstring>
 #include <cstdlib>
+#include <sys/wait.h>
 #include <msp/fs/dir.h>
+#include <msp/io/print.h>
+#include <msp/strings/utils.h>
 #include "builder.h"
 #include "externalaction.h"
 
@@ -19,15 +20,7 @@ using namespace Msp;
 void ExternalAction::launch()
 {
        if(builder.get_verbose()>=2)
-       {
-               for(StringList::const_iterator i=argv.begin(); i!=argv.end(); ++i)
-               {
-                       if(i!=argv.begin())
-                               cout<<' ';
-                       cout<<*i;
-               }
-               cout<<'\n';
-       }
+               IO::print("%s\n", join(argv.begin(), argv.end()));
 
        if(builder.get_dry_run())
                pid=-1;
@@ -46,7 +39,7 @@ void ExternalAction::launch()
                        if(!work_dir.empty())
                                FS::chdir(work_dir);
                        execvp(argv_[0], argv_);
-                       cout<<"Couldn't execute "<<argv.front()<<'\n';
+                       IO::print("Couldn't execute %s\n", argv.front());
                        exit(1);
                }
                else if(pid<0)
index cf180ce1beada0ab0a4ce2dc23e829fdd3d258a9..cf97c5506db3526535cfdbbfe3e3a9390224e8e6 100644 (file)
@@ -5,11 +5,11 @@ Copyright © 2006-2009  Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
-#include <iostream>
 #include <sys/wait.h>
 #include <fcntl.h>
 #include <cstdlib>
 #include <cstring>
+#include <msp/io/print.h>
 #include "misc.h"
 
 using namespace std;
@@ -43,7 +43,7 @@ string run_command(const StringList &argv)
                ::exit(1);
        }
        else if(pid==-1)
-               cerr<<"Failed to execute "<<argv.front()<<'\n';
+               IO::print(IO::cerr, "Failed to execute %s\n", argv.front());
        else
        {
                close(pfd[1]);
index b35a0d8f0ab0af20eaa65acd03636592b86493ce..6e60b76992b4cc9123eca2906644deab8445cac4 100644 (file)
@@ -5,6 +5,7 @@ Copyright © 2006-2007, 2009  Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
+#include <msp/io/print.h>
 #include <msp/strings/lexicalcast.h>
 #include <msp/strings/utils.h>
 #include "builder.h"
@@ -14,8 +15,6 @@ Distributed under the LGPL
 using namespace std;
 using namespace Msp;
 
-#include <iostream>
-
 Package::Package(Builder &b, const string &n):
        builder(b),
        name(n),
@@ -45,7 +44,7 @@ void Package::configure(const StringMap &opts, unsigned flag)
                return;
 
        if(builder.get_verbose()>=3)
-               cout<<"Configuring "<<name<<'\n';
+               IO::print("Configuring %s\n", name);
 
        do_configure(opts, flag);
 
index b21c6b74bde2e79664b19ae0836aa69953d451bf..991bd3516a704abbe10a948a9cdfa1be7f1b493c 100644 (file)
@@ -5,7 +5,6 @@ Copyright © 2006-2009  Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
-#include <iostream>
 #include <msp/fs/utils.h>
 #include <msp/io/file.h>
 #include <msp/io/print.h>
index a5cacce44e92b2df956c1f593bcab082aee8fba5..0fc6d696c2394776a10b7692b381f1dabcc9c2ec 100644 (file)
@@ -5,9 +5,9 @@ Copyright © 2006-2009  Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
-#include <iostream>
 #include <msp/fs/utils.h>
 #include <msp/io/except.h>
+#include <msp/io/print.h>
 #include <msp/strings/regex.h>
 #include "builder.h"
 #include "component.h"
@@ -49,7 +49,7 @@ void SourceFile::find_depends()
                        IO::BufferedFile in(name);
 
                        if(builder.get_verbose()>=4)
-                               cout<<"Reading includes from "<<name<<'\n';
+                               IO::print("Reading includes from %s\n", name);
 
                        Regex r_include("^[ \t]*#include[ \t]+([\"<].*)[\">]");
 
index 432575f400db29633003b115013d78e361adaaa0..3f38acf39c1eba37024d751ef840543195d2ee1d 100644 (file)
@@ -5,7 +5,7 @@ Copyright © 2007-2009  Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
-#include <iostream>
+#include <msp/io/print.h>
 #include <msp/strings/lexicalcast.h>
 #include <msp/strings/utils.h>
 #include "binarypackage.h"
@@ -82,7 +82,7 @@ void SourcePackage::do_configure(const StringMap &opts, unsigned flag)
        if(flag && config.update(opts))
        {
                if(builder.get_verbose()>=2)
-                       cout<<"Configuration of "<<name<<" changed\n";
+                       IO::print("Configuration of %s changed\n", name);
                if(!builder.get_dry_run())
                        config.save();
        }
index 6f7b154feabba71b738c66623080d4d02b68c1a6..75018fb0850b138c93b00d4fad09595f7643490f 100644 (file)
@@ -5,11 +5,11 @@ Copyright © 2007-2009  Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
-#include <iostream>
 #include <cstring>
 #include <msp/fs/stat.h>
 #include <msp/fs/utils.h>
 #include <msp/io/file.h>
+#include <msp/io/print.h>
 #include "builder.h"
 #include "sourcepackage.h"
 #include "tar.h"
@@ -25,7 +25,7 @@ Tar::Tar(Builder &b, const TarBall &t):
        string basename=FS::basename(tarball.get_path());
        announce(tarball.get_package()->get_name(), "TAR ", basename);
        if(builder.get_verbose()>=2)
-               cout<<"Create "<<basename<<'\n';
+               IO::print("Create %s\n", basename);
 
        if(!builder.get_dry_run())
                worker=new Worker(*this);
@@ -57,7 +57,7 @@ void Tar::Worker::main()
                string rel_path=(basedir/relative(ft->get_path(), pkg_src)).str();
                if(rel_path.size()>99)
                {
-                       cout<<"Can't store "<<rel_path<<" in tar archive - too long name\n";
+                       IO::print("Can't store %s in tar archive - too long name\n", rel_path);
                        error=true;
                        break;
                }