From: Mikko Rasa Date: Thu, 7 Aug 2008 05:48:35 +0000 (+0000) Subject: Migrate from msppath to mspfs X-Git-Tag: 0.9~6 X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=a2adbd9c0a8d7a7567848c4c6bdbf0de6ba32bb1;p=builder.git Migrate from msppath to mspfs New way of using custom loaders --- diff --git a/Build b/Build index 75c7355..59d2e7a 100644 --- 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" diff --git a/source/analyzer.cpp b/source/analyzer.cpp index f694edb..a86a9a2 100644 --- a/source/analyzer.cpp +++ b/source/analyzer.cpp @@ -8,8 +8,7 @@ Distributed under the LGPL #include #include #include -#include -#include +#include #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(); diff --git a/source/archive.cpp b/source/archive.cpp index 63d1635..175a0ae 100644 --- a/source/archive.cpp +++ b/source/archive.cpp @@ -5,7 +5,8 @@ Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions Distributed under the LGPL */ -#include +#include +#include #include "archive.h" #include "builder.h" #include "component.h" @@ -33,9 +34,9 @@ Archive::Archive(Builder &b, const StaticLibrary &lib): if(dynamic_cast(*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()); diff --git a/source/binarypackage.cpp b/source/binarypackage.cpp index aaeb3e5..f63bff8 100644 --- a/source/binarypackage.cpp +++ b/source/binarypackage.cpp @@ -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; } diff --git a/source/binarypackage.h b/source/binarypackage.h index 0be0633..a0f20e8 100644 --- a/source/binarypackage.h +++ b/source/binarypackage.h @@ -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(); }; diff --git a/source/builder.cpp b/source/builder.cpp index 147371c..257c931 100644 --- a/source/builder.cpp +++ b/source/builder.cpp @@ -10,10 +10,12 @@ Distributed under the LGPL #include #include #include +#include +#include +#include #include #include #include -#include #include #include #include @@ -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::const_iterator j=path.begin(); (!tgt && j!=path.end()); ++j) tgt=get_header(cwd/ *j/fn); for(list::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::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(prf); + ProfileLoader ldr(prf); + load_sub_with(ldr); bld.profile_tmpl.insert(ProfileTemplateMap::value_type(n, prf)); } diff --git a/source/builder.h b/source/builder.h index 010b93f..2bfa32a 100644 --- a/source/builder.h +++ b/source/builder.h @@ -13,7 +13,7 @@ Distributed under the LGPL #include #include #include -#include +#include #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(); diff --git a/source/compile.cpp b/source/compile.cpp index c98353b..634ccd8 100644 --- a/source/compile.cpp +++ b/source/compile.cpp @@ -5,7 +5,8 @@ Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions Distributed under the LGPL */ -#include +#include +#include #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::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()); diff --git a/source/compile.h b/source/compile.h index 08c6407..d58b91b 100644 --- a/source/compile.h +++ b/source/compile.h @@ -8,7 +8,7 @@ Distributed under the LGPL #ifndef COMPILE_H_ #define COMPILE_H_ -#include +#include #include "externalaction.h" class Component; diff --git a/source/component.cpp b/source/component.cpp index e674b01..29bf9d1 100644 --- a/source/component.cpp +++ b/source/component.cpp @@ -6,7 +6,9 @@ Distributed under the LGPL */ #include -#include +#include +#include +#include #include #include "builder.h" #include "component.h" @@ -85,8 +87,7 @@ void Component::create_targets() const list 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 sfiles=list_files(*i); for(list::iterator j=sfiles.begin(); j!=sfiles.end(); ++j) diff --git a/source/component.h b/source/component.h index 8dec239..6fb231d 100644 --- a/source/component.h +++ b/source/component.h @@ -10,7 +10,7 @@ Distributed under the LGPL #include #include -#include +#include #include "buildinfo.h" #include "misc.h" #include "package.h" diff --git a/source/config.cpp b/source/config.cpp index 4cc9149..fbb36ac 100644 --- a/source/config.cpp +++ b/source/config.cpp @@ -7,10 +7,11 @@ Distributed under the LGPL #include #include +#include +#include #include #include #include -#include #include #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); diff --git a/source/config.h b/source/config.h index ba23462..38ac5e4 100644 --- a/source/config.h +++ b/source/config.h @@ -11,7 +11,7 @@ Distributed under the LGPL #include #include #include -#include +#include #include #include "misc.h" diff --git a/source/copy.cpp b/source/copy.cpp index bdcd0a9..f8c581b 100644 --- a/source/copy.cpp +++ b/source/copy.cpp @@ -8,7 +8,9 @@ Distributed under the LGPL #include #include #include -#include +#include +#include +#include #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; diff --git a/source/copy.h b/source/copy.h index deb6020..445de7b 100644 --- a/source/copy.h +++ b/source/copy.h @@ -9,7 +9,7 @@ Distributed under the LGPL #define COPY_H_ #include -#include +#include #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 diff --git a/source/dependencycache.cpp b/source/dependencycache.cpp index 85ed4fd..3afbf00 100644 --- a/source/dependencycache.cpp +++ b/source/dependencycache.cpp @@ -6,7 +6,7 @@ Distributed under the LGPL */ #include -#include +#include #include #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); } diff --git a/source/executable.cpp b/source/executable.cpp index 5d1e1c8..25353cf 100644 --- a/source/executable.cpp +++ b/source/executable.cpp @@ -5,7 +5,7 @@ Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions Distributed under the LGPL */ -#include +#include #include #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))); } } diff --git a/source/externalaction.cpp b/source/externalaction.cpp index 14657a0..5d01f4f 100644 --- a/source/externalaction.cpp +++ b/source/externalaction.cpp @@ -9,7 +9,7 @@ Distributed under the LGPL #include #include #include -#include +#include #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 "< +#include #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(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; diff --git a/source/link.cpp b/source/link.cpp index f775158..95dfaa6 100644 --- a/source/link.cpp +++ b/source/link.cpp @@ -5,7 +5,8 @@ Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions Distributed under the LGPL */ -#include +#include +#include #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()); diff --git a/source/misc.h b/source/misc.h index 692ad6f..6bbf7a0 100644 --- a/source/misc.h +++ b/source/misc.h @@ -11,7 +11,7 @@ Distributed under the LGPL #include #include #include -#include +#include enum LibMode { @@ -21,7 +21,7 @@ enum LibMode }; typedef std::list StringList; -typedef std::list PathList; +typedef std::list PathList; typedef std::map StringMap; std::string run_command(const StringList &); diff --git a/source/objectfile.cpp b/source/objectfile.cpp index c5a87fd..778f746 100644 --- a/source/objectfile.cpp +++ b/source/objectfile.cpp @@ -6,7 +6,7 @@ Distributed under the LGPL */ #include -#include +#include #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(); } diff --git a/source/pkgconfigaction.cpp b/source/pkgconfigaction.cpp index dfa4cba..b5678a9 100644 --- a/source/pkgconfigaction.cpp +++ b/source/pkgconfigaction.cpp @@ -7,7 +7,7 @@ Distributed under the LGPL #include #include -#include +#include #include "package.h" #include "pkgconfig.h" #include "pkgconfigaction.h" diff --git a/source/sourcepackage.cpp b/source/sourcepackage.cpp index d814203..48ded5d 100644 --- a/source/sourcepackage.cpp +++ b/source/sourcepackage.cpp @@ -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(optimize)) diff --git a/source/sourcepackage.h b/source/sourcepackage.h index bcdd74c..18d1395 100644 --- a/source/sourcepackage.h +++ b/source/sourcepackage.h @@ -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; diff --git a/source/systemlibrary.cpp b/source/systemlibrary.cpp index 0af4910..cbeab4a 100644 --- a/source/systemlibrary.cpp +++ b/source/systemlibrary.cpp @@ -5,7 +5,8 @@ Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions Distributed under the LGPL */ -#include +#include +#include #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); } diff --git a/source/tar.cpp b/source/tar.cpp index d43a5b0..04beabf 100644 --- a/source/tar.cpp +++ b/source/tar.cpp @@ -7,8 +7,9 @@ Distributed under the LGPL #include #include +#include +#include #include -#include #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); diff --git a/source/target.cpp b/source/target.cpp index f17b88e..0762050 100644 --- a/source/target.cpp +++ b/source/target.cpp @@ -5,7 +5,8 @@ Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions Distributed under the LGPL */ -#include +#include +#include #include #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"); } } diff --git a/source/unlink.cpp b/source/unlink.cpp index 2860357..90ccd4c 100644 --- a/source/unlink.cpp +++ b/source/unlink.cpp @@ -5,7 +5,7 @@ Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions Distributed under the LGPL */ -#include +#include #include "sourcepackage.h" #include "target.h" #include "unlink.h" diff --git a/source/virtualtarget.cpp b/source/virtualtarget.cpp index 3f0081c..9b41a80 100644 --- a/source/virtualtarget.cpp +++ b/source/virtualtarget.cpp @@ -5,10 +5,12 @@ Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions Distributed under the LGPL */ -#include +#include +#include #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"); } /**