]> git.tdb.fi Git - builder.git/commitdiff
Further changes for library compatibility
authorMikko Rasa <tdb@tdb.fi>
Tue, 6 Sep 2011 11:47:24 +0000 (11:47 +0000)
committerMikko Rasa <tdb@tdb.fi>
Tue, 6 Sep 2011 11:47:24 +0000 (11:47 +0000)
19 files changed:
Build
source/architecture.cpp
source/binary.cpp
source/builder.cpp
source/component.cpp
source/config.cpp
source/copy.cpp
source/dependencycache.cpp
source/feature.cpp
source/feature.h
source/filetarget.cpp
source/install.cpp
source/sharedlibrary.cpp
source/sourcefile.cpp
source/sourcepackage.cpp
source/sourcepackage.h
source/tar.cpp
source/target.cpp
source/unlink.cpp

diff --git a/Build b/Build
index a446a23658b8033700fc2573c5d94526c3171f40..ac0982a2eeca537a2446a802e30900128650a9cf 100644 (file)
--- a/Build
+++ b/Build
@@ -7,7 +7,6 @@ package "builder"
 
        require "mspcore";
        require "mspdatafile";
-       require "mspfs";
        require "sigc++-2.0";
 
        program "builder"
index 9c96e8a512bdee0ad144c230a4f14ef907e12161..fbb246191af4ad0a6a627dd16e5977df01c6dc20 100644 (file)
@@ -9,7 +9,7 @@ Distributed under the LGPL
 #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"
@@ -152,7 +152,7 @@ std::string Architecture::get_tool(const string &t) const
                        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
@@ -189,7 +189,7 @@ void Architecture::parse_specification(const string &spec)
                        if(part==types[j])
                        {
                                if(!type.empty() && part!=type)
-                                       throw InvalidParameterValue("Conflicting type specification");
+                                       throw invalid_argument("Conflicting type specification");
                                type = part;
                                ok = true;
                        }
@@ -200,7 +200,7 @@ void Architecture::parse_specification(const string &spec)
                                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;
                        }
@@ -219,7 +219,7 @@ void Architecture::parse_specification(const string &spec)
                }
 
                if(!ok)
-                       throw InvalidParameterValue("Unrecognized part in arch specification: "+*i);
+                       throw invalid_argument("Unrecognized part in arch specification: "+*i);
        }
 }
 
index 636def98a295f318e0926cec71b39a277b7f3e21..59dc1f9d190991a4bf5fbbfd9f7761515f932aff 100644 (file)
@@ -6,7 +6,7 @@ Distributed under the LGPL
 */
 
 #include <msp/fs/utils.h>
-#include <msp/strings/formatter.h>
+#include <msp/strings/format.h>
 #include "binary.h"
 #include "builder.h"
 #include "component.h"
index 3c58f0245ecc773fa4945a9f6c614409b94151c6..c8091ffd822eb2de8bf28b3a70551641ecd280e1 100644 (file)
@@ -7,17 +7,15 @@ Distributed under the LGPL
 
 #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>
@@ -114,7 +112,7 @@ Builder::Builder(int argc, char **argv):
                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);
@@ -337,7 +335,7 @@ string Builder::run_pkgconfig(const string &pkg, const string &what)
        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;
 }
index e48e4f518477ff285d8b2878e8739d0f6b5147ca..d1ab8589c8261f30bf5ebb057f5664c7c2e9fcb7 100644 (file)
@@ -6,7 +6,6 @@ Distributed under the LGPL
 */
 
 #include <algorithm>
-#include <msp/core/except.h>
 #include <msp/fs/dir.h>
 #include <msp/fs/stat.h>
 #include <msp/fs/utils.h>
index 0676dedd94a8e2e486e619a529e1be65679fe5cb..87573e22360d5a765a12e5412616364b6f0ffa18 100644 (file)
@@ -5,10 +5,9 @@ Copyright © 2006-2009  Mikko Rasa, Mikkosoft Productions
 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>
@@ -31,11 +30,7 @@ void Config::add_option(const string &n, const string &v, const string &d)
 
 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
@@ -137,7 +132,7 @@ void Config::load()
        {
                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);
index 581221a516e04246a7c1e048ccfe4896cc16d584..11d72c607bcd4fd4bd228867bab0e22c988fc260 100644 (file)
@@ -6,6 +6,7 @@ Distributed under the LGPL
 */
 
 #include <errno.h>
+#include <sys/stat.h>
 #include <msp/fs/dir.h>
 #include <msp/fs/stat.h>
 #include <msp/fs/utils.h>
@@ -49,7 +50,7 @@ void Copy::Worker::main()
                {
                        unlink(copy.dest);
                }
-               catch(const Exception &e)
+               catch(const exception &e)
                {
                        IO::print(IO::cerr, "%s\n", e.what());
                        done = error = true;
@@ -70,7 +71,7 @@ void Copy::Worker::main()
                        out.write(buf, len);
                }
        }
-       catch(const Exception &e)
+       catch(const exception &e)
        {
                IO::print(IO::cerr, "%s\n", e.what());
                done = error = true;
@@ -78,8 +79,9 @@ void Copy::Worker::main()
        }
 
        // 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;
 }
index 7505e9889a15154b35a05313f8ed13b7e8db0e13..f691d540190f65da3444ec97823562b3fb05afcd 100644 (file)
@@ -5,8 +5,8 @@ Copyright © 2007-2009  Mikko Rasa, Mikkosoft Productions
 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>
@@ -30,11 +30,7 @@ void DependencyCache::set_deps(const string &tgt, const StringList &d)
 
 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
@@ -68,7 +64,7 @@ void DependencyCache::load()
                        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 &)
        { }
index 7c19af5c40b5af674b00ff1f0068cc35134a8ae1..54ed5147f622796ba3e6a6d5ae13444b764ab559 100644 (file)
@@ -8,7 +8,7 @@ Distributed under the LGPL
 #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);
index 1d4bf51a90bf46348a0278640de00ccbdc9fbce8..e5176c46083a48d0b9cb6fbd439cebf3bc1c1a3d 100644 (file)
@@ -8,11 +8,11 @@ Distributed under the LGPL
 #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 &);
index 061a3ae20968750a70a589d21618059cb150c913..da5cd7a1bf5c4f38c66ec43217117bf25ca8fca6 100644 (file)
@@ -22,11 +22,10 @@ FileTarget::FileTarget(Builder &b, const Package *p, const FS::Path &a):
 {
        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();
        }
 }
 
index 0578ba7173db105f0e983ceed43d8d4a185a5fa0..ecf50ee6cfa1e73f8c8e62d4f7d05f4a6778fc01 100644 (file)
@@ -51,7 +51,7 @@ Action *Install::create_action()
 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());
@@ -62,7 +62,7 @@ FS::Path Install::generate_target_path(const FileTarget &tgt, const std::string
        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))
@@ -87,7 +87,7 @@ FS::Path Install::generate_target_path(const FileTarget &tgt, const std::string
                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();
 }
index a3225171836eafb10a67f30e3191ccc660d8901c..868e822159847deebf24a76ff23867442485c142 100644 (file)
@@ -5,7 +5,7 @@ Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
-#include <msp/strings/formatter.h>
+#include <msp/strings/format.h>
 #include "component.h"
 #include "sharedlibrary.h"
 #include "sourcepackage.h"
index 0fc989d0f5a78927acce28f38050c0feddc7f09d..bc2d993f819d1dbed22c7ca868697e3dd4f0139e 100644 (file)
@@ -5,8 +5,8 @@ Copyright © 2006-2009  Mikko Rasa, Mikkosoft Productions
 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"
@@ -46,7 +46,7 @@ void SourceFile::find_depends()
                        includes = deps_cache.get_deps(relname);
                        deps_found = true;
                }
-               catch(const KeyError &)
+               catch(const key_error &)
                { }
        }
 
index a466089ae75aad13b049d5e5e3660a930f597ec3..7160013b4267bf19cbebbb7cc521efcb104def67 100644 (file)
@@ -76,7 +76,7 @@ LibMode SourcePackage::get_library_mode() const
        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
@@ -87,7 +87,7 @@ 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;
@@ -95,7 +95,7 @@ string SourcePackage::expand_string(const string &str) const
                {
                        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;
                }
index 5218592ff9d0a0743957b17bf24e70fbe8cf2315..6793d255bdd90898878e5e994cd338478dff9328 100644 (file)
@@ -8,6 +8,7 @@ Distributed under the LGPL
 #ifndef SOURCEPACKAGE_H_
 #define SOURCEPACKAGE_H_
 
+#include <stdexcept>
 #include <string>
 #include "buildinfo.h"
 #include "component.h"
@@ -19,6 +20,13 @@ Distributed under the LGPL
 
 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.
 */
index bfb4f5f9761f245dfa83cd8279a0b7a01c05bab0..1869865b93bc1426f6e5afc75dfc82ef2bcb323d 100644 (file)
@@ -64,12 +64,12 @@ void Tar::Worker::main()
 
                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);
@@ -81,7 +81,7 @@ void Tar::Worker::main()
 
                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;
index 0760f531d8a91af342d6e4cc13c3e20bc0eab2f8..bfb78672afb08e4e787236452b831b060a78632e 100644 (file)
@@ -52,7 +52,7 @@ Target *Target::get_buildable_target()
 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);
 }
 
index f1a548660e93da200102c255382e84853d0fe7bf..d047dbdc629fcb45a863a81975ba33449450f216 100644 (file)
@@ -5,6 +5,7 @@ Copyright © 2007-2009  Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
+#include <msp/core/systemerror.h>
 #include <msp/fs/utils.h>
 #include "filetarget.h"
 #include "sourcepackage.h"
@@ -21,7 +22,7 @@ Unlink::Unlink(Builder &b, const FileTarget &t):
        {
                unlink(t.get_path());
        }
-       catch(const Msp::SystemError &)
+       catch(const Msp::system_error &)
        { }
 }