require "mspcore";
require "mspdatafile";
- require "mspfs";
require "sigc++-2.0";
program "builder"
#ifndef WIN32
#include <sys/utsname.h>
#endif
-#include <msp/strings/formatter.h>
+#include <msp/strings/format.h>
#include <msp/strings/utils.h>
#include "architecture.h"
#include "builder.h"
return native_arch.get_tool(t);
}
else
- throw KeyError("Unknown tool", t);
+ throw invalid_argument("Unknown tool");
}
bool Architecture::match_name(const string &pattern) const
if(part==types[j])
{
if(!type.empty() && part!=type)
- throw InvalidParameterValue("Conflicting type specification");
+ throw invalid_argument("Conflicting type specification");
type = part;
ok = true;
}
if(type.empty())
type = cpus[j+1];
else if(cpus[j+1]!=type)
- throw InvalidParameterValue("Conflicting CPU specification");
+ throw invalid_argument("Conflicting CPU specification");
cpu = part;
ok = true;
}
}
if(!ok)
- throw InvalidParameterValue("Unrecognized part in arch specification: "+*i);
+ throw invalid_argument("Unrecognized part in arch specification: "+*i);
}
}
*/
#include <msp/fs/utils.h>
-#include <msp/strings/formatter.h>
+#include <msp/strings/format.h>
#include "binary.h"
#include "builder.h"
#include "component.h"
#include <set>
#include <cstdlib>
-#include <msp/core/except.h>
#include <msp/core/getopt.h>
#include <msp/datafile/parser.h>
#include <msp/fs/dir.h>
#include <msp/fs/stat.h>
#include <msp/fs/utils.h>
#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/format.h>
#include <msp/strings/regex.h>
#include <msp/strings/utils.h>
#include <msp/time/units.h>
else if(analyze_mode=="rdeps")
analyzer->set_mode(Analyzer::RDEPS);
else
- throw UsageError("Invalid analyze mode");
+ throw usage_error("Invalid analyze mode");
analyzer->set_max_depth(max_depth);
analyzer->set_full_paths(full_paths);
int status;
string res = run_command(argv, &status);
if(status)
- throw Exception(format("pkg-config for package %s failed", pkg));
+ throw runtime_error(format("pkg-config for package %s failed", pkg));
return res;
}
*/
#include <algorithm>
-#include <msp/core/except.h>
#include <msp/fs/dir.h>
#include <msp/fs/stat.h>
#include <msp/fs/utils.h>
Distributed under the LGPL
*/
-#include <msp/core/except.h>
+#include <msp/core/maputils.h>
#include <msp/fs/stat.h>
#include <msp/fs/utils.h>
-#include <msp/io/except.h>
#include <msp/io/file.h>
#include <msp/io/print.h>
#include <msp/time/utils.h>
const Config::Option &Config::get_option(const string &name) const
{
- OptionMap::const_iterator i = options.find(name);
- if(i==options.end())
- throw KeyError("Unknown option", name);
-
- return i->second;
+ return get_item(options, name);
}
bool Config::is_option(const string &name) const
{
IO::BufferedFile in(fn.str());
- mtime = Time::TimeStamp::from_unixtime(FS::stat(fn).st_mtime);
+ mtime = FS::stat(fn).get_modify_time();
DataFile::Parser parser(in, fn.str());
Loader loader(*this);
*/
#include <errno.h>
+#include <sys/stat.h>
#include <msp/fs/dir.h>
#include <msp/fs/stat.h>
#include <msp/fs/utils.h>
{
unlink(copy.dest);
}
- catch(const Exception &e)
+ catch(const exception &e)
{
IO::print(IO::cerr, "%s\n", e.what());
done = error = true;
out.write(buf, len);
}
}
- catch(const Exception &e)
+ catch(const exception &e)
{
IO::print(IO::cerr, "%s\n", e.what());
done = error = true;
}
// Preserve file permissions
- struct stat st = FS::stat(copy.src);
- chmod(copy.dest.str().c_str(), st.st_mode&0777);
+ struct stat st;
+ if(stat(copy.src.str().c_str(), &st)==0)
+ chmod(copy.dest.str().c_str(), st.st_mode&0777);
done = true;
}
Distributed under the LGPL
*/
+#include <msp/core/maputils.h>
#include <msp/fs/stat.h>
-#include <msp/io/except.h>
#include <msp/io/file.h>
#include <msp/io/print.h>
#include <msp/strings/utils.h>
const StringList &DependencyCache::get_deps(const string &tgt) const
{
- DepsMap::const_iterator i = deps.find(tgt);
- if(i==deps.end())
- throw KeyError("Unknown dependencies", tgt);
-
- return i->second;
+ return get_item(deps, tgt);
}
void DependencyCache::save() const
deps[parts[0]] = StringList(parts.begin()+1, parts.end());
}
- mtime = Time::TimeStamp::from_unixtime(FS::stat(fn).st_mtime);
+ mtime = FS::stat(fn).get_modify_time();
}
catch(const IO::file_not_found &)
{ }
#include "feature.h"
Feature::Loader::Loader(Feature &f):
- Msp::DataFile::BasicLoader<Feature>(f)
+ Msp::DataFile::ObjectLoader<Feature>(f)
{
add("description", &Feature::descr);
add("default", &Feature::def_value);
#ifndef FEATURE_H_
#define FEATURE_H_
-#include <msp/datafile/loader.h>
+#include <msp/datafile/objectloader.h>
struct Feature
{
- class Loader: public Msp::DataFile::BasicLoader<Feature>
+ class Loader: public Msp::DataFile::ObjectLoader<Feature>
{
public:
Loader(Feature &);
{
builder.add_target(this);
- struct stat st;
- if(!FS::lstat(path, st))
+ if(FS::Stat st = FS::lstat(path))
{
- mtime = Time::TimeStamp::from_unixtime(st.st_mtime);
- size = st.st_size;
+ mtime = st.get_modify_time();
+ size = st.get_size();
}
}
FS::Path Install::generate_target_path(const FileTarget &tgt, const std::string &loc)
{
if(!tgt.get_package())
- throw InvalidParameterValue("Can't install package-less targets");
+ throw invalid_argument("Can't install package-less targets");
FS::Path base = tgt.get_package()->get_builder().get_prefix();
string tgtname = FS::basename(tgt.get_path());
else if(const Header *hdr = dynamic_cast<const Header *>(&tgt))
{
if(hdr->get_component()->get_type()!=Component::HEADERS)
- throw Exception("Header install from non-header component?");
+ throw logic_error("Header install from non-header component?");
mid = "include/"+hdr->get_component()->get_name();
}
else if(dynamic_cast<const Executable *>(&tgt))
mid = "share/"+tgt.get_package()->get_name();
if(mid.empty())
- throw InvalidParameterValue("Don't know where to install "+tgtname);
+ throw invalid_argument("Don't know where to install "+tgtname);
return (base/mid/tgtname).str();
}
Distributed under the LGPL
*/
-#include <msp/strings/formatter.h>
+#include <msp/strings/format.h>
#include "component.h"
#include "sharedlibrary.h"
#include "sourcepackage.h"
Distributed under the LGPL
*/
+#include <msp/core/maputils.h>
#include <msp/fs/utils.h>
-#include <msp/io/except.h>
#include <msp/io/print.h>
#include <msp/strings/regex.h>
#include "builder.h"
includes = deps_cache.get_deps(relname);
deps_found = true;
}
- catch(const KeyError &)
+ catch(const key_error &)
{ }
}
else if(mode=="none")
return DYNAMIC;
else
- throw Exception("Unknown library mode");
+ throw runtime_error("unknown library mode");
}
string SourcePackage::expand_string(const string &str) const
while((dollar = result.find('$'))!=string::npos)
{
if(n>1000)
- throw Exception("Too much variable expansions");
+ throw bad_expansion("nested too deep");
string::size_type end;
string var;
{
end = result.find('}', dollar+2);
if(end==string::npos)
- throw Exception("Unterminated variable reference");
+ throw bad_expansion("unterminated variable reference");
var = result.substr(dollar+2, end-dollar-2);
++end;
}
#ifndef SOURCEPACKAGE_H_
#define SOURCEPACKAGE_H_
+#include <stdexcept>
#include <string>
#include "buildinfo.h"
#include "component.h"
class Builder;
+class bad_expansion: public std::runtime_error
+{
+public:
+ bad_expansion(const std::string &w): std::runtime_error(w) { }
+ virtual ~bad_expansion() throw() { }
+};
+
/**
A package that can be built by Builder.
*/
memcpy(buf, rel_path.data(), rel_path.size());
- struct stat st = FS::stat(ft->get_path());
- store_number(buf+100, st.st_mode, 7);
- store_number(buf+108, st.st_uid, 7);
- store_number(buf+116, st.st_gid, 7);
- store_number(buf+124, st.st_size, 11);
- store_number(buf+136, st.st_mtime, 11);
+ FS::Stat st = FS::stat(ft->get_path());
+ store_number(buf+100, 0666, 7);
+ store_number(buf+108, 0, 7);
+ store_number(buf+116, 0, 7);
+ store_number(buf+124, st.get_size(), 11);
+ store_number(buf+136, st.get_modify_time().to_unixtime(), 11);
buf[156] = '0';
memset(buf+148, ' ', 8);
out.write(buf, 512);
IO::File in(ft->get_path().str());
- for(int j=0; j<st.st_size; j+=4096)
+ for(unsigned j=0; j<st.get_size(); j+=4096)
{
unsigned len = in.read(buf, 4096);
len += ((~len)+1)&0777;
void Target::add_depend(Target *dep)
{
if(dep==this)
- throw InvalidParameterValue("A target can't depend on itself");
+ throw invalid_argument("Target::add_depend");
depends.push_back(dep);
}
Distributed under the LGPL
*/
+#include <msp/core/systemerror.h>
#include <msp/fs/utils.h>
#include "filetarget.h"
#include "sourcepackage.h"
{
unlink(t.get_path());
}
- catch(const Msp::SystemError &)
+ catch(const Msp::system_error &)
{ }
}