]> git.tdb.fi Git - builder.git/commitdiff
Migrate from msppath to mspfs
authorMikko Rasa <tdb@tdb.fi>
Thu, 7 Aug 2008 05:48:35 +0000 (05:48 +0000)
committerMikko Rasa <tdb@tdb.fi>
Thu, 7 Aug 2008 05:48:35 +0000 (05:48 +0000)
New way of using custom loaders

31 files changed:
Build
source/analyzer.cpp
source/archive.cpp
source/binarypackage.cpp
source/binarypackage.h
source/builder.cpp
source/builder.h
source/compile.cpp
source/compile.h
source/component.cpp
source/component.h
source/config.cpp
source/config.h
source/copy.cpp
source/copy.h
source/dependencycache.cpp
source/executable.cpp
source/externalaction.cpp
source/externalaction.h
source/install.cpp
source/link.cpp
source/misc.h
source/objectfile.cpp
source/pkgconfigaction.cpp
source/sourcepackage.cpp
source/sourcepackage.h
source/systemlibrary.cpp
source/tar.cpp
source/target.cpp
source/unlink.cpp
source/virtualtarget.cpp

diff --git a/Build b/Build
index 75c735503b6272b8f2518143aa633cb64724b854..59d2e7af8f46d1b254e815727eb0e4ce8edd6be9 100644 (file)
--- a/Build
+++ b/Build
@@ -11,7 +11,7 @@ package "builder"
        require "mspcore";
        require "mspstrings";
        require "mspdatafile";
-       require "msppath";
+       require "mspfs";
        require "sigc++-2.0";
 
        program "builder"
index f694edb96198494aadcceeb258950417bb708c90..a86a9a219125d3458a22d349bfead7ed2aedc5e5 100644 (file)
@@ -8,8 +8,7 @@ Distributed under the LGPL
 #include <iomanip>
 #include <iostream>
 #include <sstream>
-#include <msp/path/path.h>
-#include <msp/path/utils.h>
+#include <msp/fs/utils.h>
 #include "analyzer.h"
 #include "builder.h"
 #include "install.h"
@@ -71,7 +70,7 @@ void Analyzer::build_depend_table(Target &tgt, unsigned depth)
        if(full_paths)
                fn=tgt.get_name();
        else
-               fn=basename(tgt.get_name());
+               fn=FS::basename(tgt.get_name());
        row.push_back(string(depth*2, ' ')+fn);
 
        const Package *pkg=tgt.get_package();
index 63d1635bee578e37f0bf6c75c786ebcf6294e168..175a0ae385cf9113d2b29a516741919d607422cf 100644 (file)
@@ -5,7 +5,8 @@ Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
-#include <msp/path/utils.h>
+#include <msp/fs/dir.h>
+#include <msp/fs/utils.h>
 #include "archive.h"
 #include "builder.h"
 #include "component.h"
@@ -33,9 +34,9 @@ Archive::Archive(Builder &b, const StaticLibrary &lib):
                if(dynamic_cast<ObjectFile *>(*i))
                        argv.push_back(relative((*i)->get_name(), work_dir).str());
 
-       Path lpath=lib.get_name();
+       FS::Path lpath=lib.get_name();
        if(!builder.get_dry_run())
-               mkpath(lpath.subpath(0, lpath.size()-1), 0755);
+               FS::mkpath(FS::dirname(lpath), 0755);
 
        announce(comp.get_package().get_name(), tool, relative(lpath, work_dir).str());
 
index aaeb3e556ab02a92b305fe4434696e1fd2095233..f63bff882439c3f8174479d7ff18232e6110f5b2 100644 (file)
@@ -24,7 +24,7 @@ BinaryPackage::BinaryPackage(Builder &b, const string &n):
 Sets the path where the package files were installed.  This is only useful if
 the package doesn't use pkg-config.
 */
-void BinaryPackage::set_path(const Msp::Path &p)
+void BinaryPackage::set_path(const Msp::FS::Path &p)
 {
        path=builder.get_cwd()/p;
 }
index 0be063393107915c0c97aaafa6d5cf56c7ac854e..a0f20e86e273f4ba79f23119afa04f13c3e0682f 100644 (file)
@@ -27,13 +27,13 @@ public:
        };
 
        BinaryPackage(Builder &, const std::string &);
-       void set_path(const Msp::Path &);
+       void set_path(const Msp::FS::Path &);
        bool get_need_path() const { return need_path; }
 
        static BinaryPackage *from_pkgconfig(Builder &, const std::string &);
 private:
        bool need_path;
-       Msp::Path path;
+       Msp::FS::Path path;
 
        virtual void create_build_info();
 };
index 147371cd22519524683df31378fc0b6597d118f7..257c931732b556cde8e5b17078dcb91d57f13cd7 100644 (file)
@@ -10,10 +10,12 @@ Distributed under the LGPL
 #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/path/utils.h>
 #include <msp/strings/formatter.h>
 #include <msp/strings/regex.h>
 #include <msp/strings/utils.h>
@@ -60,6 +62,7 @@ Builder::Builder(int argc, char **argv):
        bool     full_paths=false;
        unsigned max_depth=5;
        StringList cmdline_warn;
+       string   prfx;
 
        GetOpt getopt;
        getopt.add_option('a', "analyze",    analyze_mode, GetOpt::REQUIRED_ARG);
@@ -80,7 +83,7 @@ Builder::Builder(int argc, char **argv):
        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",     prefix,       GetOpt::REQUIRED_ARG);
+       getopt.add_option(     "prefix",     prfx,         GetOpt::REQUIRED_ARG);
        getopt.add_option(     "warnings",   cmdline_warn, GetOpt::REQUIRED_ARG);
        getopt(argc, argv);
 
@@ -121,7 +124,7 @@ Builder::Builder(int argc, char **argv):
        if(!work_dir.empty())
                chdir(work_dir.c_str());
 
-       cwd=getcwd();
+       cwd=FS::getcwd();
 
        Architecture &native_arch=archs.insert(ArchMap::value_type("native", Architecture(*this, "native"))).first->second;
        native_arch.set_tool("CC",  "gcc");
@@ -130,15 +133,17 @@ Builder::Builder(int argc, char **argv):
        native_arch.set_tool("LXX", "g++");
        native_arch.set_tool("AR",  "ar");
 
-       load_build_file((get_home_dir()/".builderrc").str());
+       load_build_file((FS::get_home_dir()/".builderrc").str());
 
-       if(prefix.empty())
+       if(prfx.empty())
        {
                if(current_arch=="native")
-                       prefix=(get_home_dir()/"local").str();
+                       prefix=(FS::get_home_dir()/"local").str();
                else
-                       prefix=(get_home_dir()/"local"/current_arch).str();
+                       prefix=(FS::get_home_dir()/"local"/current_arch).str();
        }
+       else
+               prefix=prfx;
 
        warnings.push_back("all");
        warnings.push_back("extra");
@@ -246,7 +251,7 @@ Target *Builder::get_header(const string &include, const string &from, const lis
                argv.push_back(get_current_arch().get_tool("CXX"));
                argv.push_back("--version");
                cxx_ver=Regex("[0-9]\\.[0-9.]+").match(run_command(argv))[0].str;
-               while(!cxx_ver.empty() && !exists(Path("/usr/include/c++")/cxx_ver))
+               while(!cxx_ver.empty() && !FS::is_dir(FS::Path("/usr/include/c++")/cxx_ver))
                {
                        unsigned dot=cxx_ver.rfind('.');
                        if(dot==string::npos)
@@ -266,15 +271,15 @@ Target *Builder::get_header(const string &include, const string &from, const lis
                syspath.push_back("/usr/include");
        else
                syspath.push_back("/usr/"+get_architecture(current_arch).get_prefix()+"/include");
-       syspath.push_back((Path("/usr/include/c++/")/cxx_ver/fn).str());
+       syspath.push_back((FS::Path("/usr/include/c++/")/cxx_ver/fn).str());
 
        Target *tgt=0;
        if(include[0]=='\"')
-               tgt=get_header(Path(from)/fn);
+               tgt=get_header(FS::Path(from)/fn);
        for(list<string>::const_iterator j=path.begin(); (!tgt && j!=path.end()); ++j)
                tgt=get_header(cwd/ *j/fn);
        for(list<string>::const_iterator j=syspath.begin(); (!tgt && j!=syspath.end()); ++j)
-               tgt=get_header(Path(*j)/fn);
+               tgt=get_header(FS::Path(*j)/fn);
 
        includes.insert(TargetMap::value_type(id, tgt));
 
@@ -497,7 +502,7 @@ Loads the given build file.
 
 @return  0 on success, -1 if the file could not be opened
 */
-int Builder::load_build_file(const Path &fn)
+int Builder::load_build_file(const FS::Path &fn)
 {
        try
        {
@@ -620,12 +625,12 @@ int Builder::create_targets()
 Check if a header exists, either as a target or a file.  Either an existing
 target or a new SystemHeader target will be returned.
 */
-Target *Builder::get_header(const Msp::Path &fn)
+Target *Builder::get_header(const Msp::FS::Path &fn)
 {
        Target *tgt=get_target(fn.str());
        if(tgt) return tgt;
 
-       if(exists(fn))
+       if(FS::is_reg(fn))
        {
                tgt=new SystemHeader(*this, fn.str());
                return tgt;
@@ -633,7 +638,7 @@ Target *Builder::get_header(const Msp::Path &fn)
        return 0;
 }
 
-Target *Builder::get_library(const string &lib, const Path &path, LibMode mode)
+Target *Builder::get_library(const string &lib, const FS::Path &path, LibMode mode)
 {
        // Populate a list of candidate filenames
        StringList candidates;
@@ -673,7 +678,7 @@ Target *Builder::get_library(const string &lib, const Path &path, LibMode mode)
                        else if(tgt)
                                return tgt;
                }
-               else if(exists(full))
+               else if(FS::is_reg(full))
                {
                        tgt=new SystemLibrary(*this, full);
                        return tgt;
@@ -831,7 +836,7 @@ void Builder::package_help()
 Application::RegApp<Builder> Builder::reg;
 
 
-Builder::Loader::Loader(Builder &b, const Path &s):
+Builder::Loader::Loader(Builder &b, const FS::Path &s):
        bld(b),
        src(s)
 {
@@ -858,7 +863,8 @@ void Builder::Loader::binpkg(const string &n)
 void Builder::Loader::profile(const string &n)
 {
        StringMap prf;
-       load_sub<ProfileLoader>(prf);
+       ProfileLoader ldr(prf);
+       load_sub_with(ldr);
        bld.profile_tmpl.insert(ProfileTemplateMap::value_type(n, prf));
 }
 
index 010b93fcc5ddec56044e1e3f6d2cc2d111d77476..2bfa32a429c7c9c137c19312616cd0f42972c643 100644 (file)
@@ -13,7 +13,7 @@ Distributed under the LGPL
 #include <string>
 #include <msp/core/application.h>
 #include <msp/datafile/loader.h>
-#include <msp/path/path.h>
+#include <msp/fs/path.h>
 #include "architecture.h"
 #include "config.h"
 #include "misc.h"
@@ -41,10 +41,10 @@ public:
        const TargetMap &get_targets() const { return targets; }
        Target   *get_header(const std::string &, const std::string &, const StringList &);
        Target   *get_library(const std::string &, const StringList &, LibMode);
-       const Msp::Path &get_cwd() const { return cwd; }
+       const Msp::FS::Path &get_cwd() const { return cwd; }
        const Architecture &get_architecture(const std::string &) const;
        const Architecture &get_current_arch() const;
-       const std::string &get_prefix() const { return prefix; }
+       const Msp::FS::Path &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 *);
@@ -57,10 +57,10 @@ private:
        class Loader: public Msp::DataFile::Loader
        {
        public:
-               Loader(Builder &, const Msp::Path &);
+               Loader(Builder &, const Msp::FS::Path &);
        private:
-               Builder         &bld;
-               Msp::Path src;
+               Builder       &bld;
+               Msp::FS::Path src;
 
                void architecture(const std::string &);
                void binpkg(const std::string &);
@@ -84,7 +84,7 @@ private:
 
        StringList   cmdline_targets;
        StringMap    cmdline_options;
-       Msp::Path    cwd;
+       Msp::FS::Path cwd;
 
        PackageMap   packages;
        SourcePackage *main_pkg;
@@ -113,13 +113,13 @@ private:
        bool            build_all;
        bool            create_makefile;
        std::string     current_arch;
-       std::string     prefix;
+       Msp::FS::Path   prefix;
        StringList      warnings;
 
-       int    load_build_file(const Msp::Path &);
+       int    load_build_file(const Msp::FS::Path &);
        int    create_targets();
-       Target *get_header(const Msp::Path &);
-       Target *get_library(const std::string &, const Msp::Path &, LibMode);
+       Target *get_header(const Msp::FS::Path &);
+       Target *get_library(const std::string &, const Msp::FS::Path &, LibMode);
        void   update_hash(std::string &, const std::string &);
        int    do_build();
        int    do_clean();
index c98353ba04cc6726dc171c9a84bf30380a70aee0..634ccd81ff433cc31d6d7febe4a11cc3da36b98f 100644 (file)
@@ -5,7 +5,8 @@ Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
-#include <msp/path/utils.h>
+#include <msp/fs/dir.h>
+#include <msp/fs/utils.h>
 #include "builder.h"
 #include "buildinfo.h"
 #include "compile.h"
@@ -24,9 +25,9 @@ Compile::Compile(Builder &b, const ObjectFile &obj):
        work_dir=comp.get_package().get_source();
 
        const TargetList &deps=obj.get_depends();
-       Path spath=deps.front()->get_name();
+       FS::Path spath=deps.front()->get_name();
 
-       string ext=splitext(spath.str()).ext;
+       string ext=FS::extpart(spath.str());
        const char *tool=0;
        if(ext==".cpp" || ext==".cc")
                tool="CXX";
@@ -46,13 +47,13 @@ Compile::Compile(Builder &b, const ObjectFile &obj):
        for(list<string>::const_iterator i=binfo.defines.begin(); i!=binfo.defines.end(); ++i)
                argv.push_back("-D"+*i);
 
-       Path opath=obj.get_name();
+       FS::Path opath=obj.get_name();
        argv.push_back("-o");
        argv.push_back(relative(opath, work_dir).str());
        argv.push_back(relative(spath, work_dir).str());
 
        if(!builder.get_dry_run())
-               mkpath(opath.subpath(0, opath.size()-1), 0755);
+               FS::mkpath(FS::dirname(opath), 0755);
 
        announce(comp.get_package().get_name(), tool, relative(opath, work_dir).str());
 
index 08c6407c98984685dfe667892ac7174b8fc6a3f7..d58b91bfe215cd3bb3d4fd8925437bb41d5f4ac3 100644 (file)
@@ -8,7 +8,7 @@ Distributed under the LGPL
 #ifndef COMPILE_H_
 #define COMPILE_H_
 
-#include <msp/path/path.h>
+#include <msp/fs/path.h>
 #include "externalaction.h"
 
 class Component;
index e674b018aabf42c338585ef6072e76f70221f111..29bf9d10e692445bafe68c2e7095d46afa3fbadf 100644 (file)
@@ -6,7 +6,9 @@ Distributed under the LGPL
 */
 
 #include <msp/core/except.h>
-#include <msp/path/utils.h>
+#include <msp/fs/dir.h>
+#include <msp/fs/stat.h>
+#include <msp/fs/utils.h>
 #include <msp/strings/lexicalcast.h>
 #include "builder.h"
 #include "component.h"
@@ -85,8 +87,7 @@ void Component::create_targets() const
        list<Target *> inst_tgts;
        for(PathList::const_iterator i=files.begin(); i!=files.end(); ++i)
        {
-               string basename=(*i)[-1];
-               string ext=splitext(basename).ext;
+               string ext=FS::extpart(FS::basename(*i));
                if((ext==".cpp" || ext==".c") && build_exe)
                {
                        SourceFile *src=new SourceFile(builder, this, i->str());
@@ -151,8 +152,7 @@ PathList Component::collect_source_files() const
        PathList files;
        for(PathList::const_iterator i=sources.begin(); i!=sources.end(); ++i)
        {
-               struct stat st=stat(*i);
-               if(S_ISDIR(st.st_mode))
+               if(FS::is_dir(*i))
                {
                        list<string> sfiles=list_files(*i);
                        for(list<string>::iterator j=sfiles.begin(); j!=sfiles.end(); ++j)
index 8dec23912f41d5ef8f6c067d932a11851bb5d2cd..6fb231d1d247899103172aaab1720c06377cdbd8 100644 (file)
@@ -10,7 +10,7 @@ Distributed under the LGPL
 
 #include <string>
 #include <msp/datafile/loader.h>
-#include <msp/path/path.h>
+#include <msp/fs/path.h>
 #include "buildinfo.h"
 #include "misc.h"
 #include "package.h"
index 4cc9149efe6deb4f672e29e0cfc5ed9e01f4a525..fbb36ac3d5cc32b1e3bec7fb63b917cc3879ab03 100644 (file)
@@ -7,10 +7,11 @@ Distributed under the LGPL
 
 #include <cstdlib>
 #include <msp/core/except.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/path/utils.h>
 #include <msp/time/utils.h>
 #include "builder.h"
 #include "config.h"
@@ -177,7 +178,7 @@ void Config::finish()
 
 void Config::save() const
 {
-       Path fn=package.get_source()/".options.cache";
+       FS::Path fn=package.get_source()/".options.cache";
 
        OptionMap::const_iterator i=options.find("profile");
        if(i!=options.end())
@@ -206,7 +207,7 @@ bool Config::set_option(const string &opt, const string &val)
 
 void Config::load()
 {
-       Path fn=package.get_source()/".options.cache";
+       FS::Path fn=package.get_source()/".options.cache";
 
        OptionMap::iterator i=options.find("profile");
        if(i!=options.end())
@@ -217,7 +218,7 @@ void Config::load()
                IO::File inf(fn.str());
                IO::Buffered in(inf);
 
-               mtime=Time::TimeStamp::from_unixtime(stat(fn).st_mtime);
+               mtime=Time::TimeStamp::from_unixtime(FS::stat(fn).st_mtime);
 
                DataFile::Parser parser(in, fn.str());
                Loader loader(*this);
index ba23462c00e53a63196fcb0cb08fdae72fa40d2a..38ac5e44d98ac15f6079871e1a39d0ac9fbd4a80 100644 (file)
@@ -11,7 +11,7 @@ Distributed under the LGPL
 #include <map>
 #include <string>
 #include <msp/datafile/loader.h>
-#include <msp/path/path.h>
+#include <msp/fs/path.h>
 #include <msp/time/timestamp.h>
 #include "misc.h"
 
index bdcd0a94a8006ec108c31ecfbea5e3ce7d4d97bc..f8c581bd5664ca123f4f657da77883c7dff1003b 100644 (file)
@@ -8,7 +8,9 @@ Distributed under the LGPL
 #include <errno.h>
 #include <fstream>
 #include <iostream>
-#include <msp/path/utils.h>
+#include <msp/fs/dir.h>
+#include <msp/fs/stat.h>
+#include <msp/fs/utils.h>
 #include "builder.h"
 #include "copy.h"
 #include "package.h"
@@ -16,7 +18,7 @@ Distributed under the LGPL
 using namespace std;
 using namespace Msp;
 
-Copy::Copy(Builder &b, const Package &pkg, const Path &s, const Path &d):
+Copy::Copy(Builder &b, const Package &pkg, const FS::Path &s, const FS::Path &d):
        InternalAction(b),
        src(s),
        dest(d)
@@ -38,7 +40,7 @@ Copy::Worker::Worker(Copy &c):
 
 void Copy::Worker::main()
 {
-       mkpath(copy.dest.subpath(0, copy.dest.size()-1), 0755);
+       FS::mkpath(FS::dirname(copy.dest), 0755);
 
        try
        {
@@ -80,7 +82,7 @@ void Copy::Worker::main()
        }
 
        // Preserve file permissions
-       struct stat st=stat(copy.src);
+       struct stat st=FS::stat(copy.src);
        chmod(copy.dest.str().c_str(), st.st_mode&0777);
 
        done=true;
index deb60209b7cbc4b3ab4aa551fe60c2d2318355ce..445de7bb9841433d573f60ca5c02794667de75de 100644 (file)
@@ -9,7 +9,7 @@ Distributed under the LGPL
 #define COPY_H_
 
 #include <msp/core/thread.h>
-#include <msp/path/path.h>
+#include <msp/fs/path.h>
 #include "internalaction.h"
 
 class Package;
@@ -20,7 +20,7 @@ Copies a file to another place.  Used by the Install target.
 class Copy: public InternalAction
 {
 public:
-       Copy(Builder &, const Package &, const Msp::Path &, const Msp::Path &);
+       Copy(Builder &, const Package &, const Msp::FS::Path &, const Msp::FS::Path &);
 private:
        /**
        A worker thread that actually does the data transfer.
@@ -35,8 +35,8 @@ private:
                void main();
        };
 
-       Msp::Path src;
-       Msp::Path dest;
+       Msp::FS::Path src;
+       Msp::FS::Path dest;
 };
 
 #endif
index 85ed4fd656b20a74746e0513d7dd11e13c2ad365..3afbf009c6a4cf42d203d68d75274ba918dce945 100644 (file)
@@ -6,7 +6,7 @@ Distributed under the LGPL
 */
 
 #include <fstream>
-#include <msp/path/utils.h>
+#include <msp/fs/stat.h>
 #include <msp/strings/utils.h>
 #include "builder.h"
 #include "dependencycache.h"
@@ -73,5 +73,5 @@ void DependencyCache::load()
                deps[parts[0]]=StringList(parts.begin()+1, parts.end());
        }
 
-       mtime=Time::TimeStamp::from_unixtime(stat(fn).st_mtime);
+       mtime=Time::TimeStamp::from_unixtime(FS::stat(fn).st_mtime);
 }
index 5d1e1c8f24fbf428a8dff009c886a3efde3f7c58..25353cf23282576e4280a189d213aafa1354e7cc 100644 (file)
@@ -5,7 +5,7 @@ Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
-#include <msp/path/utils.h>
+#include <msp/fs/utils.h>
 #include <msp/strings/formatter.h>
 #include "builder.h"
 #include "component.h"
@@ -62,7 +62,7 @@ void Executable::find_depends()
                                        queue.push_back(&stlib->get_component());
                        }
                        else
-                               builder.problem(comp.get_package().get_name(), format("Couldn't find library %s for %s", *i, basename(name)));
+                               builder.problem(comp.get_package().get_name(), format("Couldn't find library %s for %s", *i, FS::basename(name)));
                }
        }
 
index 14657a04ab2c05cfa71d059be4b6c1bbad75a7ca..5d01f4f701071fd4b330b26618b897899a59110d 100644 (file)
@@ -9,7 +9,7 @@ Distributed under the LGPL
 #include <iostream>
 #include <cstring>
 #include <cstdlib>
-#include <msp/path/utils.h>
+#include <msp/fs/dir.h>
 #include "builder.h"
 #include "externalaction.h"
 
@@ -73,7 +73,7 @@ void ExternalAction::launch()
                        argv_[j]=0;
 
                        if(!work_dir.empty())
-                               chdir(work_dir);
+                               FS::chdir(work_dir);
                        execvp(argv_[0], argv_);
                        cout<<"Couldn't execute "<<argv.front()<<'\n';
                        exit(1);
index 232e0847c1770dd0c3dec2d586758e7cc080c6b7..26dbbfa5fa2220386efc7eafb28a63ccd7c81da8 100644 (file)
@@ -22,7 +22,7 @@ public:
        int check();
 protected:
        StringList argv;
-       Msp::Path  work_dir;
+       Msp::FS::Path  work_dir;
        int        pid;
        int        exit_code;
        
index 721f9636460f7d0b92a558733d5384443eb1e553..dcc46773ca39a66997512c855f0224a51b5d746a 100644 (file)
@@ -5,7 +5,7 @@ Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
-#include <msp/path/utils.h>
+#include <msp/fs/utils.h>
 #include "builder.h"
 #include "copy.h"
 #include "executable.h"
@@ -33,9 +33,9 @@ void Install::check_rebuild()
        {
                Target *dep=depends.front();
                if(dep->get_mtime()>mtime)
-                       mark_rebuild(basename(dep->get_name())+" has changed");
+                       mark_rebuild(FS::basename(dep->get_name())+" has changed");
                else if(dep->get_rebuild())
-                       mark_rebuild(basename(dep->get_name())+" needs rebuilding");
+                       mark_rebuild(FS::basename(dep->get_name())+" needs rebuilding");
        }
 }
 
@@ -48,7 +48,7 @@ string Install::generate_target_name(const Target &tgt)
 {
        const SourcePackage *spkg=dynamic_cast<const SourcePackage *>(tgt.get_package());
 
-       Path base=spkg->get_builder().get_prefix();
+       FS::Path base=spkg->get_builder().get_prefix();
        string tgtname=tgt.get_name().substr(tgt.get_name().rfind('/')+1);
 
        string mid;
index f775158cea53d73ab9b9f676b49b77f4f59fe0cb..95dfaa64ef6582615a8fe28927d804e855fc614a 100644 (file)
@@ -5,7 +5,8 @@ Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
-#include <msp/path/utils.h>
+#include <msp/fs/dir.h>
+#include <msp/fs/utils.h>
 #include "builder.h"
 #include "component.h"
 #include "executable.h"
@@ -61,9 +62,9 @@ Link::Link(Builder &b, const Executable &exe):
                        argv.push_back("-l"+syslib->get_libname());
        }
 
-       Path epath=exe.get_name();
+       FS::Path epath=exe.get_name();
        if(!builder.get_dry_run())
-               mkpath(epath.subpath(0, epath.size()-1), 0755);
+               FS::mkpath(FS::dirname(epath), 0755);
 
        announce(comp.get_package().get_name(), tool, relative(epath, work_dir).str());
 
index 692ad6f4f3f3f3e7a59565301dd95e20620587cb..6bbf7a0328568d95e4c9b59b2277eb94bed50671 100644 (file)
@@ -11,7 +11,7 @@ Distributed under the LGPL
 #include <list>
 #include <map>
 #include <string>
-#include <msp/path/path.h>
+#include <msp/fs/path.h>
 
 enum LibMode
 {
@@ -21,7 +21,7 @@ enum LibMode
 };
 
 typedef std::list<std::string>     StringList;
-typedef std::list<Msp::Path> PathList;
+typedef std::list<Msp::FS::Path> PathList;
 typedef std::map<std::string, std::string> StringMap;
 
 std::string run_command(const StringList &);
index c5a87fde883117e61d2cafdce85bae1a4656213e..778f74642acc72ca476f2a70224db1e886f7bd2e 100644 (file)
@@ -6,7 +6,7 @@ Distributed under the LGPL
 */
 
 #include <algorithm>
-#include <msp/path/utils.h>
+#include <msp/fs/utils.h>
 #include "builder.h"
 #include "compile.h"
 #include "component.h"
@@ -96,5 +96,5 @@ Action *ObjectFile::create_action()
 string ObjectFile::generate_target_name(const Component &comp, const string &src)
 {
        const SourcePackage &pkg=comp.get_package();
-       return (pkg.get_temp_dir()/comp.get_name()/(splitext(basename(src)).base+".o")).str();
+       return (pkg.get_temp_dir()/comp.get_name()/(FS::basepart(FS::basename(src))+".o")).str();
 }
index dfa4cba113eae4a0dae492a8c1bdf8c038778699..b5678a962684d50290f64d7e03353872c21ecb25 100644 (file)
@@ -7,7 +7,7 @@ Distributed under the LGPL
 
 #include <fstream>
 #include <iostream>
-#include <msp/path/utils.h>
+#include <msp/fs/utils.h>
 #include "package.h"
 #include "pkgconfig.h"
 #include "pkgconfigaction.h"
index d8142038d1e65756f5ad7ccae68f693dc86bf525..48ded5da7f2e1d7ca01427f3032064b94013dc8f 100644 (file)
@@ -19,7 +19,7 @@ using namespace Msp;
 /**
 Creates a buildable package.
 */
-SourcePackage::SourcePackage(Builder &b, const string &n, const Path &s):
+SourcePackage::SourcePackage(Builder &b, const string &n, const FS::Path &s):
        Package(b, n),
        source(s),
        config(*this),
@@ -28,12 +28,12 @@ SourcePackage::SourcePackage(Builder &b, const string &n, const Path &s):
        tar_files.push_back(source/"Build");
 }
 
-Msp::Path SourcePackage::get_temp_dir() const
+Msp::FS::Path SourcePackage::get_temp_dir() const
 {
        return source/config.get_option("tempdir").value/builder.get_current_arch().get_name()/config.get_option("profile").value;
 }
 
-Msp::Path SourcePackage::get_out_dir() const
+Msp::FS::Path SourcePackage::get_out_dir() const
 {
        return source/config.get_option("outdir").value;
 }
@@ -178,13 +178,13 @@ void SourcePackage::create_build_info()
 
        unsigned flags=get_install_flags();
 
-       build_info.incpath.push_back((Path(builder.get_prefix())/"include").str());
-       build_info.libpath.push_back((Path(builder.get_prefix())/"lib").str());
+       build_info.incpath.push_back((builder.get_prefix()/"include").str());
+       build_info.libpath.push_back((builder.get_prefix()/"lib").str());
 
        if(flags&INCLUDE)
-               export_binfo.incpath.push_back((Path(builder.get_prefix())/"include").str());
+               export_binfo.incpath.push_back((builder.get_prefix()/"include").str());
        if(flags&LIB)
-               export_binfo.libpath.push_back((Path(builder.get_prefix())/"lib").str());
+               export_binfo.libpath.push_back((builder.get_prefix()/"lib").str());
 
        string optimize=config.get_option("optimize").value;
        if(lexical_cast<unsigned>(optimize))
index bcdd74cbbfb30aae55b60e0ec9971720efc529b5..18d1395aa8e7d019a79ac9c090ec727b9fced281 100644 (file)
@@ -50,13 +50,13 @@ public:
                void tar_file(const std::string &);
        };
 
-       SourcePackage(Builder &, const std::string &, const Msp::Path &);
+       SourcePackage(Builder &, const std::string &, const Msp::FS::Path &);
        const std::string   &get_name() const           { return name; }
        const std::string   &get_version() const        { return version; }
        const std::string   &get_description() const    { return description; }
-       const Msp::Path &get_source() const       { return source; }
-       Msp::Path     get_temp_dir() const;
-       Msp::Path     get_out_dir() const;
+       const Msp::FS::Path &get_source() const       { return source; }
+       Msp::FS::Path     get_temp_dir() const;
+       Msp::FS::Path     get_out_dir() const;
        const ComponentList &get_components() const     { return components; }
        const Config        &get_config() const         { return config; }
        const BuildInfo     &get_build_info() const     { return build_info; }
@@ -70,7 +70,7 @@ private:
        std::string   version;
        std::string   description;
 
-       Msp::Path source;
+       Msp::FS::Path source;
        PackageList   base_reqs;
        FeatureList   features;
        BuildInfo     build_info;
index 0af4910dbc1dcd08d5c15c9a14db7bafd0bfdcfa..cbeab4a70d3100e17ba0b5b04e8d414a05d96311 100644 (file)
@@ -5,7 +5,8 @@ Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
-#include <msp/path/utils.h>
+#include <msp/fs/path.h>
+#include <msp/fs/utils.h>
 #include "systemlibrary.h"
 
 using namespace std;
@@ -14,7 +15,7 @@ using namespace Msp;
 SystemLibrary::SystemLibrary(Builder &b, const string &n):
        Target(b, 0, n)
 {
-       libname=splitext(basename(n)).base;
+       libname=FS::basepart(FS::basename(n));
        if(!libname.compare(0, 3, "lib"))
                libname.erase(0, 3);
 }
index d43a5b0cbb24e0e49dc384591f9300201e6a58ff..04beabfdd83d52828c6ccb6e34a68fa8518345bc 100644 (file)
@@ -7,8 +7,9 @@ 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/path/utils.h>
 #include "builder.h"
 #include "sourcepackage.h"
 #include "tar.h"
@@ -39,8 +40,8 @@ Tar::Worker::Worker(Tar &t):
 
 void Tar::Worker::main()
 {
-       const Path &pkg_src=tar.tarball.get_package()->get_source();
-       Path basedir=splitext(basename(tar.tarball.get_name())).base;
+       const FS::Path &pkg_src=tar.tarball.get_package()->get_source();
+       FS::Path basedir=FS::basepart(FS::basename(tar.tarball.get_name()));
 
        IO::File out(tar.tarball.get_name(), IO::M_WRITE);
        const TargetList &deps=tar.tarball.get_depends();
@@ -59,7 +60,7 @@ void Tar::Worker::main()
 
                memcpy(buf, rel_path.data(), rel_path.size());
 
-               struct stat st=stat((*i)->get_name());
+               struct stat st=FS::stat((*i)->get_name());
                store_number(buf+100, st.st_mode, 7);
                store_number(buf+108, st.st_uid, 7);
                store_number(buf+116, st.st_gid, 7);
index f17b88e103c6a8a3725d079ecaf046339b1c0824..07620502f4be2cbe21eafde8b5dab5de870d9668 100644 (file)
@@ -5,7 +5,8 @@ Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
-#include <msp/path/utils.h>
+#include <msp/fs/stat.h>
+#include <msp/fs/utils.h>
 #include <msp/time/utils.h>
 #include "action.h"
 #include "builder.h"
@@ -76,8 +77,8 @@ Action *Target::build()
                return 0;
        }
 
-       if(!builder.get_dry_run() && exists(name))
-               unlink(name);
+       if(!builder.get_dry_run() && FS::exists(name))
+               FS::unlink(name);
 
        Action *action=create_action();
        if(action)
@@ -128,7 +129,7 @@ Target::Target(Builder &b, const Package *p, const string &n):
        builder.add_target(this);
 
        struct stat st;
-       if(!stat(name, st))
+       if(!FS::stat(name, st))
                mtime=Time::TimeStamp::from_unixtime(st.st_mtime);
 }
 
@@ -155,9 +156,9 @@ void Target::check_rebuild()
                for(TargetList::iterator i=depends.begin(); (i!=depends.end() && !rebuild); ++i)
                {
                        if((*i)->get_mtime()>mtime)
-                               mark_rebuild(basename((*i)->get_name())+" has changed");
+                               mark_rebuild(FS::basename((*i)->get_name())+" has changed");
                        else if((*i)->get_rebuild())
-                               mark_rebuild(basename((*i)->get_name())+" needs rebuilding");
+                               mark_rebuild(FS::basename((*i)->get_name())+" needs rebuilding");
                }
        }
 
index 2860357475e455d9e650d28d6a163045c995be3b..90ccd4cc334b6fd2b67fe38c0373744010319c01 100644 (file)
@@ -5,7 +5,7 @@ Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
-#include <msp/path/utils.h>
+#include <msp/fs/utils.h>
 #include "sourcepackage.h"
 #include "target.h"
 #include "unlink.h"
index 3f0081ce0dd7b4a0dd45d3329345f150d1c1191f..9b41a80a667f7b872b7031a723d52f0a7aedba41 100644 (file)
@@ -5,10 +5,12 @@ Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
-#include <msp/path/utils.h>
+#include <msp/fs/path.h>
+#include <msp/fs/utils.h>
 #include "virtualtarget.h"
 
 using namespace std;
+using namespace Msp;
 
 /**
 Virtual targets are only rebuilt if their dependencies need rebuilding.
@@ -17,7 +19,7 @@ void VirtualTarget::check_rebuild()
 {
        for(TargetList::iterator i=depends.begin(); (i!=depends.end() && !rebuild); ++i)
                if((*i)->get_rebuild())
-                       mark_rebuild(Msp::basename((*i)->get_name())+" needs rebuilding");
+                       mark_rebuild(FS::basename((*i)->get_name())+" needs rebuilding");
 }
 
 /**