clean(0),
dry_run(false),
help(false),
- verbose(1),
show_progress(false),
build_file("Build"),
jobs(1),
string prfx;
string arch;
bool no_externals = false;
+ unsigned verbose = 1;
+ bool silent = false;
+ list<string> log_channels;
GetOpt getopt;
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('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('l', "log", log_channels, GetOpt::REQUIRED_ARG).set_help("Set log channels to be displayed.", "LIST");
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('s', "silent", silent, GetOpt::NO_ARG).set_help("Don't print any messages other than errors.");
getopt.add_option('v', "verbose", verbose, GetOpt::NO_ARG).set_help("Print more information about what's going on.");
getopt.add_option('x', "no-externals", no_externals, GetOpt::NO_ARG).set_help("Do not load external source packages.");
getopt.add_option('A', "conf-all", conf_all, GetOpt::NO_ARG).set_help("Apply configuration to all packages.");
helpmsg = getopt.generate_help();
getopt(argc, argv);
+ if(silent)
+ --verbose;
+ if(verbose>=1)
+ {
+ logger.enable_channel("summary");
+ logger.enable_channel("tasks");
+ }
+ if(verbose>=2)
+ {
+ logger.enable_channel("packages");
+ 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, ',');
+ for(vector<string>::const_iterator j=parts.begin(); j!=parts.end(); ++j)
+ logger.enable_channel(*j);
+ }
+
if(!analyze_mode.empty())
{
analyzer = new Analyzer(*this);
if(create_targets())
return 1;
- if(verbose>=2)
- {
- IO::print("Building on %s, for %s%s\n", native_arch.get_name(),
- current_arch->get_name(), (current_arch->is_native() ? " (native)" : ""));
- IO::print("Prefix is %s\n", prefix);
- }
+ logger.log("environment", format("Building on %s, for %s%s", native_arch.get_name(),
+ current_arch->get_name(), (current_arch->is_native() ? " (native)" : "")));
+ logger.log("environment", format("Prefix is %s", prefix));
- if(verbose>=1)
+ const PackageManager::PackageMap &packages = package_manager.get_packages();
+ list<string> package_details;
+ for(PackageManager::PackageMap::const_iterator i=packages.begin(); i!=packages.end(); ++i)
{
- const PackageManager::PackageMap &packages = package_manager.get_packages();
- unsigned n_packages = 0;
- for(PackageManager::PackageMap::const_iterator i=packages.begin(); i!=packages.end(); ++i)
- if(i->second && i->second->is_configured())
- ++n_packages;
- IO::print("%d active packages, %d targets\n", n_packages, targets.size());
- }
+ if(!i->second || !i->second->is_configured())
+ continue;
- if(verbose>=2)
- {
- const PackageManager::PackageMap &packages = package_manager.get_packages();
- for(PackageManager::PackageMap::const_iterator i=packages.begin(); i!=packages.end(); ++i)
+ string line = i->second->get_name();
+ if(dynamic_cast<SourcePackage *>(i->second))
{
- if(!i->second->is_configured())
- continue;
+ line += '*';
- IO::print(" %s", i->second->get_name());
- if(dynamic_cast<SourcePackage *>(i->second))
- IO::print("*");
unsigned count = 0;
unsigned to_be_built = 0;
for(TargetMap::iterator j=targets.begin(); j!=targets.end(); ++j)
}
if(count)
{
- IO::print(" (%d targets", count);
+ line += format(" (%d targets", count);
if(to_be_built)
- IO::print(", %d to be built", to_be_built);
- IO::print(")");
+ line += format(", %d to be built", to_be_built);
+ line += ')';
}
- IO::print("\n");
}
+
+ package_details.push_back(line);
}
+ logger.log("summary", format("%d active packages, %d targets", package_details.size(), targets.size()));
+ for(list<string>::const_iterator i=package_details.begin(); i!=package_details.end(); ++i)
+ logger.log("packages", *i);
+
if(analyzer)
analyzer->analyze();
IO::BufferedFile in(fn.str());
- if(verbose>=3)
- IO::print("Reading %s\n", fn);
+ logger.log("files", format("Reading %s", fn));
DataFile::Parser parser(in, fn.str());
Loader loader(*this, fn.subpath(0, fn.size()-1));
if(!total)
{
- IO::print("Already up to date\n");
+ logger.log("summary", "Already up to date");
return 0;
}
- if(verbose>=1)
- IO::print("Will build %d target%s\n", total, (total!=1 ? "s" : ""));
+ logger.log("summary", format("Will build %d target%s", total, (total!=1 ? "s" : "")));
vector<Task *> tasks;
if(tgt)
{
if(tgt->get_tool())
- IO::print("%-4s %s\n", tgt->get_tool()->get_tag(), tgt->get_name());
+ logger.log("tasks", format("%-4s %s", tgt->get_tool()->get_tag(), tgt->get_name()));
Task *task = tgt->build();
if(task)
{
- if(verbose>=2)
- IO::print("%s\n", task->get_command());
+ logger.log("commands", format("%s", task->get_command()));
if(dry_run)
{
task->signal_finished.emit(true);
if(show_progress)
IO::print("\033[K");
if(fail)
- IO::print("Build failed\n");
+ logger.log("summary", "Build failed");
else if(show_progress)
- IO::print("Build complete\n");
+ logger.log("summary", "Build complete");
return fail;
}