string work_dir;
bool full_paths=false;
unsigned max_depth=5;
+ StringList cmdline_warn;
GetOpt getopt;
getopt.add_option('a', "analyze", analyze_mode, GetOpt::REQUIRED_ARG);
//getopt.add_option( "makefile", create_makefile, GetOpt::NO_ARG);
getopt.add_option( "max-depth", max_depth, GetOpt::REQUIRED_ARG);
getopt.add_option( "prefix", prefix, GetOpt::REQUIRED_ARG);
+ getopt.add_option( "warnings", cmdline_warn, GetOpt::REQUIRED_ARG);
getopt(argc, argv);
if(!analyze_mode.empty())
else
prefix=(get_home_dir()/"local"/current_arch).str();
}
+
+ warnings.push_back("all");
+ warnings.push_back("extra");
+ warnings.push_back("shadow");
+ warnings.push_back("pointer-arith");
+ warnings.push_back("error");
+ for(StringList::iterator i=cmdline_warn.begin(); i!=cmdline_warn.end(); ++i)
+ {
+ vector<string> warns=split(*i, ',');
+ warnings.insert(warnings.end(), warns.begin(), warns.end());
+ }
}
/**
cerr<<reason<<'\n';
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> ...]";
+ 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";
else
{
cerr<<
" -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";
+ " --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";
}
}
const Architecture &get_architecture(const std::string &) const;
const Architecture &get_current_arch() const;
const std::string &get_prefix() const { return prefix; }
+ const StringList &get_warnings() const { return warnings; }
void apply_profile_template(Config &, const std::string &) const;
void add_target(Target *);
void problem(const std::string &, const std::string &);
bool create_makefile;
std::string current_arch;
std::string prefix;
+ StringList warnings;
int load_build_file(const Msp::Path &);
int create_targets();
#include <algorithm>
#include "buildinfo.h"
+using namespace std;
using namespace Msp;
/**
ldflags.insert(ldflags.end(), bi.ldflags.begin(), bi.ldflags.end());
libpath.insert(libpath.end(), bi.libpath.begin(), bi.libpath.end());
libs.insert(libs.end(), bi.libs.begin(), bi.libs.end());
+ warnings.insert(warnings.end(), bi.warnings.begin(), bi.warnings.end());
}
/**
unique(ldflags);
unique(libpath);
unique(libs);
+
+ for(StringList::iterator i=warnings.begin(); i!=warnings.end(); ++i)
+ {
+ bool flag=i->compare(0, 3, "no-");
+
+ string warn=(flag ? *i : i->substr(3));
+ string no_warn="no-"+warn;
+
+ for(StringList::iterator j=i; j!=warnings.end();)
+ {
+ if(j!=i && (*j==warn || *j==no_warn))
+ {
+ flag=(*j==warn);
+ j=warnings.erase(j);
+ }
+ else
+ ++j;
+ }
+
+ *i=(flag ? warn : no_warn);
+ }
}
/**
*/
void BuildInfo::unique(StringList &l)
{
- StringList l2;
for(StringList::iterator i=l.begin(); i!=l.end(); ++i)
- if(find(l2.begin(), l2.end(), *i)==l2.end())
- l2.push_back(*i);
- swap(l, l2);
+ for(StringList::iterator j=i; j!=l.end();)
+ {
+ if(j!=i && *j==*i)
+ j=l.erase(j);
+ else
+ ++j;
+ }
}
BuildInfo::Loader::Loader(BuildInfo &bi):
add("ldflag", &Loader::ldflag);
add("libpath", &Loader::libpath);
add("library", &Loader::library);
+ add("warning", &Loader::warning);
}
void ldflag(const std::string &s) { binfo.ldflags.push_back(s); }
void libpath(const std::string &s) { binfo.libpath.push_back(s); }
void library(const std::string &s) { binfo.libs.push_back(s); }
+ void warning(const std::string &s) { binfo.warnings.push_back(s); }
};
StringList cflags;
StringList ldflags;
StringList libpath;
StringList libs;
+ StringList warnings;
void add(const BuildInfo &);
void unique();
argv.push_back("-c");
const BuildInfo &binfo=comp.get_build_info();
+ for(list<string>::const_iterator i=binfo.warnings.begin(); i!=binfo.warnings.end(); ++i)
+ argv.push_back("-W"+*i);
for(list<string>::const_iterator i=binfo.cflags.begin(); i!=binfo.cflags.end(); ++i)
argv.push_back(*i);
for(list<string>::const_iterator i=binfo.incpath.begin(); i!=binfo.incpath.end(); ++i)
export_binfo.defines.insert(export_binfo.defines.end(), ebi.defines.begin(), ebi.defines.end());
}
- build_info.cflags.push_back("-Wall");
- build_info.cflags.push_back("-Wshadow");
- build_info.cflags.push_back("-Wextra");
- build_info.cflags.push_back("-Wpointer-arith");
- //build_info.cflags.push_back("-Wconversion");
- build_info.cflags.push_back("-Werror");
+ // XXX Currently, a package-specific settings will override cmdline. This might or might not be desirable.
+ const StringList &warnings=builder.get_warnings();
+ build_info.warnings.insert(build_info.warnings.begin(), warnings.begin(), warnings.end());
unsigned flags=get_install_flags();